vi: fix NUM + "$" handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
023a08f229
commit
35fdb1bc9c
77
editors/vi.c
77
editors/vi.c
@ -3015,17 +3015,17 @@ static void do_cmd(int c)
|
|||||||
case KEYCODE_LEFT: // cursor key Left
|
case KEYCODE_LEFT: // cursor key Left
|
||||||
case 8: // ctrl-H- move left (This may be ERASE char)
|
case 8: // ctrl-H- move left (This may be ERASE char)
|
||||||
case 0x7f: // DEL- 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);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_left();
|
dot_left();
|
||||||
break;
|
break;
|
||||||
case 10: // Newline ^J
|
case 10: // Newline ^J
|
||||||
case 'j': // j- goto next line, same col
|
case 'j': // j- goto next line, same col
|
||||||
case KEYCODE_DOWN: // cursor key Down
|
case KEYCODE_DOWN: // cursor key Down
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_next(); // go to next B-o-l
|
dot_next(); // go to next B-o-l
|
||||||
dot = move_to_col(dot, ccol + offset); // try stay in same col
|
dot = move_to_col(dot, ccol + offset); // try stay in same col
|
||||||
break;
|
break;
|
||||||
@ -3040,9 +3040,9 @@ static void do_cmd(int c)
|
|||||||
break;
|
break;
|
||||||
case 13: // Carriage Return ^M
|
case 13: // Carriage Return ^M
|
||||||
case '+': // +- goto next line
|
case '+': // +- goto next line
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_next();
|
dot_next();
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
break;
|
break;
|
||||||
@ -3062,9 +3062,9 @@ static void do_cmd(int c)
|
|||||||
case ' ': // move right
|
case ' ': // move right
|
||||||
case 'l': // move right
|
case 'l': // move right
|
||||||
case KEYCODE_RIGHT: // Cursor Key Right
|
case KEYCODE_RIGHT: // Cursor Key Right
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_right();
|
dot_right();
|
||||||
break;
|
break;
|
||||||
#if ENABLE_FEATURE_VI_YANKMARK
|
#if ENABLE_FEATURE_VI_YANKMARK
|
||||||
@ -3147,9 +3147,10 @@ static void do_cmd(int c)
|
|||||||
#endif /* FEATURE_VI_YANKMARK */
|
#endif /* FEATURE_VI_YANKMARK */
|
||||||
case '$': // $- goto end of line
|
case '$': // $- goto end of line
|
||||||
case KEYCODE_END: // Cursor Key End
|
case KEYCODE_END: // Cursor Key End
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
|
dot_next();
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot = end_line(dot);
|
dot = end_line(dot);
|
||||||
break;
|
break;
|
||||||
case '%': // %- find matching char of pair () [] {}
|
case '%': // %- find matching char of pair () [] {}
|
||||||
@ -3175,9 +3176,9 @@ static void do_cmd(int c)
|
|||||||
//
|
//
|
||||||
//**** fall through to ... ';'
|
//**** fall through to ... ';'
|
||||||
case ';': // ;- look at rest of line for last forward char
|
case ';': // ;- look at rest of line for last forward char
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(';');
|
do_cmd(';');
|
||||||
} // repeat cnt
|
}
|
||||||
if (last_forward_char == 0)
|
if (last_forward_char == 0)
|
||||||
break;
|
break;
|
||||||
q = dot + 1;
|
q = dot + 1;
|
||||||
@ -3188,9 +3189,9 @@ static void do_cmd(int c)
|
|||||||
dot = q;
|
dot = q;
|
||||||
break;
|
break;
|
||||||
case ',': // repeat latest 'f' in opposite direction
|
case ',': // repeat latest 'f' in opposite direction
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(',');
|
do_cmd(',');
|
||||||
} // repeat cnt
|
}
|
||||||
if (last_forward_char == 0)
|
if (last_forward_char == 0)
|
||||||
break;
|
break;
|
||||||
q = dot - 1;
|
q = dot - 1;
|
||||||
@ -3202,9 +3203,9 @@ static void do_cmd(int c)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case '-': // -- goto prev line
|
case '-': // -- goto prev line
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_prev();
|
dot_prev();
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
break;
|
break;
|
||||||
@ -3238,9 +3239,9 @@ static void do_cmd(int c)
|
|||||||
// user changed mind and erased the "/"- do nothing
|
// user changed mind and erased the "/"- do nothing
|
||||||
break;
|
break;
|
||||||
case 'N': // N- backward search for last pattern
|
case 'N': // N- backward search for last pattern
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dir = BACK; // assume BACKWARD search
|
dir = BACK; // assume BACKWARD search
|
||||||
p = dot - 1;
|
p = dot - 1;
|
||||||
if (last_search_pattern[0] == '?') {
|
if (last_search_pattern[0] == '?') {
|
||||||
@ -3252,9 +3253,9 @@ static void do_cmd(int c)
|
|||||||
case 'n': // n- repeat search for last pattern
|
case 'n': // n- repeat search for last pattern
|
||||||
// search rest of text[] starting at next char
|
// search rest of text[] starting at next char
|
||||||
// if search fails return orignal "p" not the "p+1" address
|
// if search fails return orignal "p" not the "p+1" address
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dc3:
|
dc3:
|
||||||
dir = FORWARD; // assume FORWARD search
|
dir = FORWARD; // assume FORWARD search
|
||||||
p = dot + 1;
|
p = dot + 1;
|
||||||
@ -3405,9 +3406,9 @@ static void do_cmd(int c)
|
|||||||
case 'B': // B- back a blank-delimited Word
|
case 'B': // B- back a blank-delimited Word
|
||||||
case 'E': // E- end of a blank-delimited word
|
case 'E': // E- end of a blank-delimited word
|
||||||
case 'W': // W- forward a blank-delimited word
|
case 'W': // W- forward a blank-delimited word
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dir = FORWARD;
|
dir = FORWARD;
|
||||||
if (c == 'B')
|
if (c == 'B')
|
||||||
dir = BACK;
|
dir = BACK;
|
||||||
@ -3455,9 +3456,9 @@ static void do_cmd(int c)
|
|||||||
if (cmdcnt > (rows - 1)) {
|
if (cmdcnt > (rows - 1)) {
|
||||||
cmdcnt = (rows - 1);
|
cmdcnt = (rows - 1);
|
||||||
}
|
}
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd('+');
|
do_cmd('+');
|
||||||
} // repeat cnt
|
}
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
break;
|
break;
|
||||||
case 'I': // I- insert before first non-blank
|
case 'I': // I- insert before first non-blank
|
||||||
@ -3470,9 +3471,9 @@ static void do_cmd(int c)
|
|||||||
cmd_mode = 1; // start insrting
|
cmd_mode = 1; // start insrting
|
||||||
break;
|
break;
|
||||||
case 'J': // J- join current and next lines together
|
case 'J': // J- join current and next lines together
|
||||||
if (cmdcnt-- > 2) {
|
if (--cmdcnt > 1) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_end(); // move to NL
|
dot_end(); // move to NL
|
||||||
if (dot < end - 1) { // make sure not last char in text[]
|
if (dot < end - 1) { // make sure not last char in text[]
|
||||||
*dot++ = ' '; // replace NL with space
|
*dot++ = ' '; // replace NL with space
|
||||||
@ -3488,9 +3489,9 @@ static void do_cmd(int c)
|
|||||||
if (cmdcnt > (rows - 1)) {
|
if (cmdcnt > (rows - 1)) {
|
||||||
cmdcnt = (rows - 1);
|
cmdcnt = (rows - 1);
|
||||||
}
|
}
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd('-');
|
do_cmd('-');
|
||||||
} // repeat cnt
|
}
|
||||||
dot_begin();
|
dot_begin();
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
break;
|
break;
|
||||||
@ -3524,9 +3525,9 @@ static void do_cmd(int c)
|
|||||||
case 'X': // X- delete char before dot
|
case 'X': // X- delete char before dot
|
||||||
case 'x': // x- delete the current char
|
case 'x': // x- delete the current char
|
||||||
case 's': // s- substitute the current char
|
case 's': // s- substitute the current char
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dir = 0;
|
dir = 0;
|
||||||
if (c == 'X')
|
if (c == 'X')
|
||||||
dir = -1;
|
dir = -1;
|
||||||
@ -3568,9 +3569,9 @@ static void do_cmd(int c)
|
|||||||
break;
|
break;
|
||||||
case 'b': // b- back a word
|
case 'b': // b- back a word
|
||||||
case 'e': // e- end of word
|
case 'e': // e- end of word
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dir = FORWARD;
|
dir = FORWARD;
|
||||||
if (c == 'b')
|
if (c == 'b')
|
||||||
dir = BACK;
|
dir = BACK;
|
||||||
@ -3669,9 +3670,9 @@ static void do_cmd(int c)
|
|||||||
}
|
}
|
||||||
case 'k': // k- goto prev line, same col
|
case 'k': // k- goto prev line, same col
|
||||||
case KEYCODE_UP: // cursor key Up
|
case KEYCODE_UP: // cursor key Up
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
dot_prev();
|
dot_prev();
|
||||||
dot = move_to_col(dot, ccol + offset); // try stay in same col
|
dot = move_to_col(dot, ccol + offset); // try stay in same col
|
||||||
break;
|
break;
|
||||||
@ -3691,9 +3692,9 @@ static void do_cmd(int c)
|
|||||||
last_forward_char = 0;
|
last_forward_char = 0;
|
||||||
break;
|
break;
|
||||||
case 'w': // w- forward a word
|
case 'w': // w- forward a word
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
if (isalnum(*dot) || *dot == '_') { // we are on ALNUM
|
if (isalnum(*dot) || *dot == '_') { // we are on ALNUM
|
||||||
dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
|
dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
|
||||||
} else if (ispunct(*dot)) { // we are on PUNCT
|
} else if (ispunct(*dot)) { // we are on PUNCT
|
||||||
@ -3719,9 +3720,9 @@ static void do_cmd(int c)
|
|||||||
dot = move_to_col(dot, cmdcnt - 1); // try to move to column
|
dot = move_to_col(dot, cmdcnt - 1); // try to move to column
|
||||||
break;
|
break;
|
||||||
case '~': // ~- flip the case of letters a-z -> A-Z
|
case '~': // ~- flip the case of letters a-z -> A-Z
|
||||||
if (cmdcnt-- > 1) {
|
if (--cmdcnt > 0) {
|
||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
}
|
||||||
if (islower(*dot)) {
|
if (islower(*dot)) {
|
||||||
*dot = toupper(*dot);
|
*dot = toupper(*dot);
|
||||||
file_modified++;
|
file_modified++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user