aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-26 16:10:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-26 16:10:14 +0100
commit35fdb1bc9cb82fa5630c2d40ae49110ecd7c88ea (patch)
tree36e64090e5f689bbbc8dd982118efb0374561be5
parent023a08f2292a5ae6eb6a8350dc8a94fc64bfcb7c (diff)
downloadbusybox-w32-35fdb1bc9cb82fa5630c2d40ae49110ecd7c88ea.tar.gz
busybox-w32-35fdb1bc9cb82fa5630c2d40ae49110ecd7c88ea.tar.bz2
busybox-w32-35fdb1bc9cb82fa5630c2d40ae49110ecd7c88ea.zip
vi: fix NUM + "$" handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c77
1 files changed, 39 insertions, 38 deletions
diff --git a/editors/vi.c b/editors/vi.c
index a22a6a104..633d42a8c 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3015,17 +3015,17 @@ static void do_cmd(int c)
3015 case KEYCODE_LEFT: // cursor key Left 3015 case KEYCODE_LEFT: // cursor key Left
3016 case 8: // ctrl-H- move left (This may be ERASE char) 3016 case 8: // ctrl-H- move left (This may be ERASE char)
3017 case 0x7f: // DEL- move left (This may be ERASE char) 3017 case 0x7f: // DEL- move left (This may be ERASE char)
3018 if (cmdcnt-- > 1) { 3018 if (--cmdcnt > 0) {
3019 do_cmd(c); 3019 do_cmd(c);
3020 } // repeat cnt 3020 }
3021 dot_left(); 3021 dot_left();
3022 break; 3022 break;
3023 case 10: // Newline ^J 3023 case 10: // Newline ^J
3024 case 'j': // j- goto next line, same col 3024 case 'j': // j- goto next line, same col
3025 case KEYCODE_DOWN: // cursor key Down 3025 case KEYCODE_DOWN: // cursor key Down
3026 if (cmdcnt-- > 1) { 3026 if (--cmdcnt > 0) {
3027 do_cmd(c); 3027 do_cmd(c);
3028 } // repeat cnt 3028 }
3029 dot_next(); // go to next B-o-l 3029 dot_next(); // go to next B-o-l
3030 dot = move_to_col(dot, ccol + offset); // try stay in same col 3030 dot = move_to_col(dot, ccol + offset); // try stay in same col
3031 break; 3031 break;
@@ -3040,9 +3040,9 @@ static void do_cmd(int c)
3040 break; 3040 break;
3041 case 13: // Carriage Return ^M 3041 case 13: // Carriage Return ^M
3042 case '+': // +- goto next line 3042 case '+': // +- goto next line
3043 if (cmdcnt-- > 1) { 3043 if (--cmdcnt > 0) {
3044 do_cmd(c); 3044 do_cmd(c);
3045 } // repeat cnt 3045 }
3046 dot_next(); 3046 dot_next();
3047 dot_skip_over_ws(); 3047 dot_skip_over_ws();
3048 break; 3048 break;
@@ -3062,9 +3062,9 @@ static void do_cmd(int c)
3062 case ' ': // move right 3062 case ' ': // move right
3063 case 'l': // move right 3063 case 'l': // move right
3064 case KEYCODE_RIGHT: // Cursor Key Right 3064 case KEYCODE_RIGHT: // Cursor Key Right
3065 if (cmdcnt-- > 1) { 3065 if (--cmdcnt > 0) {
3066 do_cmd(c); 3066 do_cmd(c);
3067 } // repeat cnt 3067 }
3068 dot_right(); 3068 dot_right();
3069 break; 3069 break;
3070#if ENABLE_FEATURE_VI_YANKMARK 3070#if ENABLE_FEATURE_VI_YANKMARK
@@ -3147,9 +3147,10 @@ static void do_cmd(int c)
3147#endif /* FEATURE_VI_YANKMARK */ 3147#endif /* FEATURE_VI_YANKMARK */
3148 case '$': // $- goto end of line 3148 case '$': // $- goto end of line
3149 case KEYCODE_END: // Cursor Key End 3149 case KEYCODE_END: // Cursor Key End
3150 if (cmdcnt-- > 1) { 3150 if (--cmdcnt > 0) {
3151 dot_next();
3151 do_cmd(c); 3152 do_cmd(c);
3152 } // repeat cnt 3153 }
3153 dot = end_line(dot); 3154 dot = end_line(dot);
3154 break; 3155 break;
3155 case '%': // %- find matching char of pair () [] {} 3156 case '%': // %- find matching char of pair () [] {}
@@ -3175,9 +3176,9 @@ static void do_cmd(int c)
3175 // 3176 //
3176 //**** fall through to ... ';' 3177 //**** fall through to ... ';'
3177 case ';': // ;- look at rest of line for last forward char 3178 case ';': // ;- look at rest of line for last forward char
3178 if (cmdcnt-- > 1) { 3179 if (--cmdcnt > 0) {
3179 do_cmd(';'); 3180 do_cmd(';');
3180 } // repeat cnt 3181 }
3181 if (last_forward_char == 0) 3182 if (last_forward_char == 0)
3182 break; 3183 break;
3183 q = dot + 1; 3184 q = dot + 1;
@@ -3188,9 +3189,9 @@ static void do_cmd(int c)
3188 dot = q; 3189 dot = q;
3189 break; 3190 break;
3190 case ',': // repeat latest 'f' in opposite direction 3191 case ',': // repeat latest 'f' in opposite direction
3191 if (cmdcnt-- > 1) { 3192 if (--cmdcnt > 0) {
3192 do_cmd(','); 3193 do_cmd(',');
3193 } // repeat cnt 3194 }
3194 if (last_forward_char == 0) 3195 if (last_forward_char == 0)
3195 break; 3196 break;
3196 q = dot - 1; 3197 q = dot - 1;
@@ -3202,9 +3203,9 @@ static void do_cmd(int c)
3202 break; 3203 break;
3203 3204
3204 case '-': // -- goto prev line 3205 case '-': // -- goto prev line
3205 if (cmdcnt-- > 1) { 3206 if (--cmdcnt > 0) {
3206 do_cmd(c); 3207 do_cmd(c);
3207 } // repeat cnt 3208 }
3208 dot_prev(); 3209 dot_prev();
3209 dot_skip_over_ws(); 3210 dot_skip_over_ws();
3210 break; 3211 break;
@@ -3238,9 +3239,9 @@ static void do_cmd(int c)
3238 // user changed mind and erased the "/"- do nothing 3239 // user changed mind and erased the "/"- do nothing
3239 break; 3240 break;
3240 case 'N': // N- backward search for last pattern 3241 case 'N': // N- backward search for last pattern
3241 if (cmdcnt-- > 1) { 3242 if (--cmdcnt > 0) {
3242 do_cmd(c); 3243 do_cmd(c);
3243 } // repeat cnt 3244 }
3244 dir = BACK; // assume BACKWARD search 3245 dir = BACK; // assume BACKWARD search
3245 p = dot - 1; 3246 p = dot - 1;
3246 if (last_search_pattern[0] == '?') { 3247 if (last_search_pattern[0] == '?') {
@@ -3252,9 +3253,9 @@ static void do_cmd(int c)
3252 case 'n': // n- repeat search for last pattern 3253 case 'n': // n- repeat search for last pattern
3253 // search rest of text[] starting at next char 3254 // search rest of text[] starting at next char
3254 // if search fails return orignal "p" not the "p+1" address 3255 // if search fails return orignal "p" not the "p+1" address
3255 if (cmdcnt-- > 1) { 3256 if (--cmdcnt > 0) {
3256 do_cmd(c); 3257 do_cmd(c);
3257 } // repeat cnt 3258 }
3258 dc3: 3259 dc3:
3259 dir = FORWARD; // assume FORWARD search 3260 dir = FORWARD; // assume FORWARD search
3260 p = dot + 1; 3261 p = dot + 1;
@@ -3405,9 +3406,9 @@ static void do_cmd(int c)
3405 case 'B': // B- back a blank-delimited Word 3406 case 'B': // B- back a blank-delimited Word
3406 case 'E': // E- end of a blank-delimited word 3407 case 'E': // E- end of a blank-delimited word
3407 case 'W': // W- forward a blank-delimited word 3408 case 'W': // W- forward a blank-delimited word
3408 if (cmdcnt-- > 1) { 3409 if (--cmdcnt > 0) {
3409 do_cmd(c); 3410 do_cmd(c);
3410 } // repeat cnt 3411 }
3411 dir = FORWARD; 3412 dir = FORWARD;
3412 if (c == 'B') 3413 if (c == 'B')
3413 dir = BACK; 3414 dir = BACK;
@@ -3455,9 +3456,9 @@ static void do_cmd(int c)
3455 if (cmdcnt > (rows - 1)) { 3456 if (cmdcnt > (rows - 1)) {
3456 cmdcnt = (rows - 1); 3457 cmdcnt = (rows - 1);
3457 } 3458 }
3458 if (cmdcnt-- > 1) { 3459 if (--cmdcnt > 0) {
3459 do_cmd('+'); 3460 do_cmd('+');
3460 } // repeat cnt 3461 }
3461 dot_skip_over_ws(); 3462 dot_skip_over_ws();
3462 break; 3463 break;
3463 case 'I': // I- insert before first non-blank 3464 case 'I': // I- insert before first non-blank
@@ -3470,9 +3471,9 @@ static void do_cmd(int c)
3470 cmd_mode = 1; // start insrting 3471 cmd_mode = 1; // start insrting
3471 break; 3472 break;
3472 case 'J': // J- join current and next lines together 3473 case 'J': // J- join current and next lines together
3473 if (cmdcnt-- > 2) { 3474 if (--cmdcnt > 1) {
3474 do_cmd(c); 3475 do_cmd(c);
3475 } // repeat cnt 3476 }
3476 dot_end(); // move to NL 3477 dot_end(); // move to NL
3477 if (dot < end - 1) { // make sure not last char in text[] 3478 if (dot < end - 1) { // make sure not last char in text[]
3478 *dot++ = ' '; // replace NL with space 3479 *dot++ = ' '; // replace NL with space
@@ -3488,9 +3489,9 @@ static void do_cmd(int c)
3488 if (cmdcnt > (rows - 1)) { 3489 if (cmdcnt > (rows - 1)) {
3489 cmdcnt = (rows - 1); 3490 cmdcnt = (rows - 1);
3490 } 3491 }
3491 if (cmdcnt-- > 1) { 3492 if (--cmdcnt > 0) {
3492 do_cmd('-'); 3493 do_cmd('-');
3493 } // repeat cnt 3494 }
3494 dot_begin(); 3495 dot_begin();
3495 dot_skip_over_ws(); 3496 dot_skip_over_ws();
3496 break; 3497 break;
@@ -3524,9 +3525,9 @@ static void do_cmd(int c)
3524 case 'X': // X- delete char before dot 3525 case 'X': // X- delete char before dot
3525 case 'x': // x- delete the current char 3526 case 'x': // x- delete the current char
3526 case 's': // s- substitute the current char 3527 case 's': // s- substitute the current char
3527 if (cmdcnt-- > 1) { 3528 if (--cmdcnt > 0) {
3528 do_cmd(c); 3529 do_cmd(c);
3529 } // repeat cnt 3530 }
3530 dir = 0; 3531 dir = 0;
3531 if (c == 'X') 3532 if (c == 'X')
3532 dir = -1; 3533 dir = -1;
@@ -3568,9 +3569,9 @@ static void do_cmd(int c)
3568 break; 3569 break;
3569 case 'b': // b- back a word 3570 case 'b': // b- back a word
3570 case 'e': // e- end of word 3571 case 'e': // e- end of word
3571 if (cmdcnt-- > 1) { 3572 if (--cmdcnt > 0) {
3572 do_cmd(c); 3573 do_cmd(c);
3573 } // repeat cnt 3574 }
3574 dir = FORWARD; 3575 dir = FORWARD;
3575 if (c == 'b') 3576 if (c == 'b')
3576 dir = BACK; 3577 dir = BACK;
@@ -3669,9 +3670,9 @@ static void do_cmd(int c)
3669 } 3670 }
3670 case 'k': // k- goto prev line, same col 3671 case 'k': // k- goto prev line, same col
3671 case KEYCODE_UP: // cursor key Up 3672 case KEYCODE_UP: // cursor key Up
3672 if (cmdcnt-- > 1) { 3673 if (--cmdcnt > 0) {
3673 do_cmd(c); 3674 do_cmd(c);
3674 } // repeat cnt 3675 }
3675 dot_prev(); 3676 dot_prev();
3676 dot = move_to_col(dot, ccol + offset); // try stay in same col 3677 dot = move_to_col(dot, ccol + offset); // try stay in same col
3677 break; 3678 break;
@@ -3691,9 +3692,9 @@ static void do_cmd(int c)
3691 last_forward_char = 0; 3692 last_forward_char = 0;
3692 break; 3693 break;
3693 case 'w': // w- forward a word 3694 case 'w': // w- forward a word
3694 if (cmdcnt-- > 1) { 3695 if (--cmdcnt > 0) {
3695 do_cmd(c); 3696 do_cmd(c);
3696 } // repeat cnt 3697 }
3697 if (isalnum(*dot) || *dot == '_') { // we are on ALNUM 3698 if (isalnum(*dot) || *dot == '_') { // we are on ALNUM
3698 dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM); 3699 dot = skip_thing(dot, 1, FORWARD, S_END_ALNUM);
3699 } else if (ispunct(*dot)) { // we are on PUNCT 3700 } else if (ispunct(*dot)) { // we are on PUNCT
@@ -3719,9 +3720,9 @@ static void do_cmd(int c)
3719 dot = move_to_col(dot, cmdcnt - 1); // try to move to column 3720 dot = move_to_col(dot, cmdcnt - 1); // try to move to column
3720 break; 3721 break;
3721 case '~': // ~- flip the case of letters a-z -> A-Z 3722 case '~': // ~- flip the case of letters a-z -> A-Z
3722 if (cmdcnt-- > 1) { 3723 if (--cmdcnt > 0) {
3723 do_cmd(c); 3724 do_cmd(c);
3724 } // repeat cnt 3725 }
3725 if (islower(*dot)) { 3726 if (islower(*dot)) {
3726 *dot = toupper(*dot); 3727 *dot = toupper(*dot);
3727 file_modified++; 3728 file_modified++;