case KEYCODE_LEFT: // cursor key Left
case 8: // ctrl-H- move left (This may be ERASE char)
case 0x7f: // DEL- move left (This may be ERASE char)
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_left();
break;
case 10: // Newline ^J
case 'j': // j- goto next line, same col
case KEYCODE_DOWN: // cursor key Down
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_next(); // go to next B-o-l
dot = move_to_col(dot, ccol + offset); // try stay in same col
break;
break;
case 13: // Carriage Return ^M
case '+': // +- goto next line
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_next();
dot_skip_over_ws();
break;
case ' ': // move right
case 'l': // move right
case KEYCODE_RIGHT: // Cursor Key Right
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_right();
break;
#if ENABLE_FEATURE_VI_YANKMARK
#endif /* FEATURE_VI_YANKMARK */
case '$': // $- goto end of line
case KEYCODE_END: // Cursor Key End
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
+ dot_next();
do_cmd(c);
- } // repeat cnt
+ }
dot = end_line(dot);
break;
case '%': // %- find matching char of pair () [] {}
//
//**** fall through to ... ';'
case ';': // ;- look at rest of line for last forward char
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(';');
- } // repeat cnt
+ }
if (last_forward_char == 0)
break;
q = dot + 1;
dot = q;
break;
case ',': // repeat latest 'f' in opposite direction
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(',');
- } // repeat cnt
+ }
if (last_forward_char == 0)
break;
q = dot - 1;
break;
case '-': // -- goto prev line
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_prev();
dot_skip_over_ws();
break;
// user changed mind and erased the "/"- do nothing
break;
case 'N': // N- backward search for last pattern
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = BACK; // assume BACKWARD search
p = dot - 1;
if (last_search_pattern[0] == '?') {
case 'n': // n- repeat search for last pattern
// search rest of text[] starting at next char
// if search fails return orignal "p" not the "p+1" address
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dc3:
dir = FORWARD; // assume FORWARD search
p = dot + 1;
case 'B': // B- back a blank-delimited Word
case 'E': // E- end of a blank-delimited word
case 'W': // W- forward a blank-delimited word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = FORWARD;
if (c == 'B')
dir = BACK;
if (cmdcnt > (rows - 1)) {
cmdcnt = (rows - 1);
}
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd('+');
- } // repeat cnt
+ }
dot_skip_over_ws();
break;
case 'I': // I- insert before first non-blank
cmd_mode = 1; // start insrting
break;
case 'J': // J- join current and next lines together
- if (cmdcnt-- > 2) {
+ if (--cmdcnt > 1) {
do_cmd(c);
- } // repeat cnt
+ }
dot_end(); // move to NL
if (dot < end - 1) { // make sure not last char in text[]
*dot++ = ' '; // replace NL with space
if (cmdcnt > (rows - 1)) {
cmdcnt = (rows - 1);
}
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd('-');
- } // repeat cnt
+ }
dot_begin();
dot_skip_over_ws();
break;
case 'X': // X- delete char before dot
case 'x': // x- delete the current char
case 's': // s- substitute the current char
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = 0;
if (c == 'X')
dir = -1;
break;
case 'b': // b- back a word
case 'e': // e- end of word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dir = FORWARD;
if (c == 'b')
dir = BACK;
}
case 'k': // k- goto prev line, same col
case KEYCODE_UP: // cursor key Up
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
dot_prev();
dot = move_to_col(dot, ccol + offset); // try stay in same col
break;
last_forward_char = 0;
break;
case 'w': // w- forward a word
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
if (isalnum(*dot) || *dot == '_') { // we are on ALNUM
dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
} else if (ispunct(*dot)) { // we are on PUNCT
dot = move_to_col(dot, cmdcnt - 1); // try to move to column
break;
case '~': // ~- flip the case of letters a-z -> A-Z
- if (cmdcnt-- > 1) {
+ if (--cmdcnt > 0) {
do_cmd(c);
- } // repeat cnt
+ }
if (islower(*dot)) {
*dot = toupper(*dot);
file_modified++;