main command input routine when not repeating and not executing canned commands; input comes via get_count() which collects repeat count if one is present and returns next non-digit to us */
| 5093 | commands; input comes via get_count() which collects repeat count if one |
| 5094 | is present and returns next non-digit to us */ |
| 5095 | staticfn int |
| 5096 | parse(void) |
| 5097 | { |
| 5098 | int foo; |
| 5099 | struct Cmd_bind *bind; |
| 5100 | |
| 5101 | iflags.in_parse = TRUE; |
| 5102 | gc.command_count = 0; |
| 5103 | svc.context.move = TRUE; /* assume next command will take game time */ |
| 5104 | flush_screen(1); /* Flush screen buffer. Put the cursor on the hero. */ |
| 5105 | |
| 5106 | /* affects readchar() behavior for ESC iff 'altmeta' option is On; |
| 5107 | is always reset to otherInp by readchar() */ |
| 5108 | program_state.input_state = commandInp; |
| 5109 | |
| 5110 | if (!gc.Cmd.num_pad || (foo = readchar()) == gc.Cmd.spkeys[NHKF_COUNT]) { |
| 5111 | /* if 'num_pad' is On then readchar() has just reset input_state; |
| 5112 | set it back to commandInp, so that get_count() supports 'altmeta'; |
| 5113 | otherwise "n<count>ESC<character>" becomes "n<count>ESC" (with |
| 5114 | <character> not read from keyboard yet) rather than intended count |
| 5115 | and meta keystroke "n<count>M-<character>" */ |
| 5116 | program_state.input_state = commandInp; |
| 5117 | |
| 5118 | foo = get_count((char *) 0, '\0', LARGEST_INT, |
| 5119 | &gc.command_count, GC_NOFLAGS); |
| 5120 | } |
| 5121 | gl.last_command_count = gc.command_count; |
| 5122 | |
| 5123 | if (foo == gc.Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ |
| 5124 | clear_nhwindow(WIN_MESSAGE); |
| 5125 | gc.command_count = 0; |
| 5126 | gl.last_command_count = 0; |
| 5127 | } else if (gi.in_doagain) { |
| 5128 | gc.command_count = gl.last_command_count; |
| 5129 | } else if (foo && (bind = cmdbind_get(foo & 0xFF)) != 0 |
| 5130 | /* these shouldn't go into the do-again buffer */ |
| 5131 | && bind && bind->cmd |
| 5132 | && (bind->cmd->ef_funct == do_repeat |
| 5133 | || bind->cmd->ef_funct == doprev_message |
| 5134 | /* this one might get put into the do-again buffer but |
| 5135 | only if the interface code tells the core to do it */ |
| 5136 | || bind->cmd->ef_funct == doextcmd)) { |
| 5137 | /* gc.command_count will be set again when we |
| 5138 | re-enter with gi.in_doagain set true */ |
| 5139 | gc.command_count = gl.last_command_count; |
| 5140 | } |
| 5141 | |
| 5142 | gm.multi = gc.command_count; |
| 5143 | if (gm.multi) |
| 5144 | gm.multi--; |
| 5145 | |
| 5146 | gc.cmd_key = foo; |
| 5147 | clear_nhwindow(WIN_MESSAGE); |
| 5148 | |
| 5149 | iflags.in_parse = FALSE; |
| 5150 | return gc.cmd_key; |
| 5151 | } |
| 5152 |
no test coverage detected