aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-10-14 12:26:30 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-10-14 12:26:30 +0000
commitded6ad34edaa03dcd4b899787c2bbdc2ee3e7988 (patch)
tree077f474b2246d5a0b2ce87eaee7720101375009a
parent267e16c74aa72d0e8fdd90b2a4301b89cdca0e42 (diff)
downloadbusybox-w32-ded6ad34edaa03dcd4b899787c2bbdc2ee3e7988.tar.gz
busybox-w32-ded6ad34edaa03dcd4b899787c2bbdc2ee3e7988.tar.bz2
busybox-w32-ded6ad34edaa03dcd4b899787c2bbdc2ee3e7988.zip
fix recurring "last_cmd overrun", fix [del] handling in insert mode
-rw-r--r--editors/vi.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/editors/vi.c b/editors/vi.c
index a01fa7c46..55dab1f03 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -96,6 +96,12 @@ static const char CMrc[] ALIGN1 = "\033[%d;%dH";
96static const char CMup[] ALIGN1 = "\033[A"; 96static const char CMup[] ALIGN1 = "\033[A";
97static const char CMdown[] ALIGN1 = "\n"; 97static const char CMdown[] ALIGN1 = "\n";
98 98
99#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
100// cmds modifying text[]
101// vda: removed "aAiIs" as they switch us into insert mode
102// and remembering input for replay after them makes no sense
103static const char modifying_cmds[] = "cCdDJoOpPrRxX<>~";
104#endif
99 105
100enum { 106enum {
101 YANKONLY = FALSE, 107 YANKONLY = FALSE,
@@ -180,9 +186,6 @@ struct globals {
180#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME 186#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
181 int my_pid; 187 int my_pid;
182#endif 188#endif
183#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
184 char *modifying_cmds; // cmds that modify text[]
185#endif
186#if ENABLE_FEATURE_VI_SEARCH 189#if ENABLE_FEATURE_VI_SEARCH
187 char *last_search_pattern; // last pattern from a '/' or '?' search 190 char *last_search_pattern; // last pattern from a '/' or '?' search
188#endif 191#endif
@@ -266,7 +269,6 @@ struct globals {
266#define ioq_start (G.ioq_start ) 269#define ioq_start (G.ioq_start )
267#define last_row (G.last_row ) 270#define last_row (G.last_row )
268#define my_pid (G.my_pid ) 271#define my_pid (G.my_pid )
269#define modifying_cmds (G.modifying_cmds )
270#define last_search_pattern (G.last_search_pattern) 272#define last_search_pattern (G.last_search_pattern)
271#define chars_to_parse (G.chars_to_parse ) 273#define chars_to_parse (G.chars_to_parse )
272 274
@@ -429,10 +431,6 @@ int vi_main(int argc, char **argv)
429#endif 431#endif
430 432
431 vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE; 433 vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
432#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
433 modifying_cmds = (char *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
434#endif
435
436 // 1- process $HOME/.exrc file (not inplemented yet) 434 // 1- process $HOME/.exrc file (not inplemented yet)
437 // 2- process EXINIT variable from environment 435 // 2- process EXINIT variable from environment
438 // 3- process command line args 436 // 3- process command line args
@@ -624,6 +622,7 @@ static void edit_file(char *fn)
624 // These are commands that change text[]. 622 // These are commands that change text[].
625 // Remember the input for the "." command 623 // Remember the input for the "." command
626 if (!adding2q && ioq_start == NULL 624 if (!adding2q && ioq_start == NULL
625 && cmd_mode == 0 /* command mode */
627 && c != '\0' && strchr(modifying_cmds, c) 626 && c != '\0' && strchr(modifying_cmds, c)
628 ) { 627 ) {
629 start_new_cmd_q(c); 628 start_new_cmd_q(c);
@@ -2200,12 +2199,12 @@ static char readit(void) // read (maybe cursor) key from stdin
2200 // Known escape sequences for cursor and function keys. 2199 // Known escape sequences for cursor and function keys.
2201 static const struct esc_cmds { 2200 static const struct esc_cmds {
2202 const char seq[4]; 2201 const char seq[4];
2203 char val; 2202 char val; //TODO: int? Need to make it at least 8-bit clean!
2204 } esccmds[] = { 2203 } esccmds[] = {
2205 {"OA" , VI_K_UP }, // cursor key Up 2204 {"OA" , VI_K_UP }, // Cursor Key Up
2206 {"OB" , VI_K_DOWN }, // cursor key Down 2205 {"OB" , VI_K_DOWN }, // Cursor Key Down
2207 {"OC" , VI_K_RIGHT }, // Cursor Key Right 2206 {"OC" , VI_K_RIGHT }, // Cursor Key Right
2208 {"OD" , VI_K_LEFT }, // cursor key Left 2207 {"OD" , VI_K_LEFT }, // Cursor Key Left
2209 {"OH" , VI_K_HOME }, // Cursor Key Home 2208 {"OH" , VI_K_HOME }, // Cursor Key Home
2210 {"OF" , VI_K_END }, // Cursor Key End 2209 {"OF" , VI_K_END }, // Cursor Key End
2211 {"OP" , VI_K_FUN1 }, // Function Key F1 2210 {"OP" , VI_K_FUN1 }, // Function Key F1
@@ -2213,10 +2212,10 @@ static char readit(void) // read (maybe cursor) key from stdin
2213 {"OR" , VI_K_FUN3 }, // Function Key F3 2212 {"OR" , VI_K_FUN3 }, // Function Key F3
2214 {"OS" , VI_K_FUN4 }, // Function Key F4 2213 {"OS" , VI_K_FUN4 }, // Function Key F4
2215 2214
2216 {"[A" , VI_K_UP }, // cursor key Up 2215 {"[A" , VI_K_UP }, // Cursor Key Up
2217 {"[B" , VI_K_DOWN }, // cursor key Down 2216 {"[B" , VI_K_DOWN }, // Cursor Key Down
2218 {"[C" , VI_K_RIGHT }, // Cursor Key Right 2217 {"[C" , VI_K_RIGHT }, // Cursor Key Right
2219 {"[D" , VI_K_LEFT }, // cursor key Left 2218 {"[D" , VI_K_LEFT }, // Cursor Key Left
2220 {"[H" , VI_K_HOME }, // Cursor Key Home 2219 {"[H" , VI_K_HOME }, // Cursor Key Home
2221 {"[F" , VI_K_END }, // Cursor Key End 2220 {"[F" , VI_K_END }, // Cursor Key End
2222 {"[1~" , VI_K_HOME }, // Cursor Key Home 2221 {"[1~" , VI_K_HOME }, // Cursor Key Home
@@ -3003,6 +3002,7 @@ static void do_cmd(char c)
3003 case VI_K_END: 3002 case VI_K_END:
3004 case VI_K_PAGEUP: 3003 case VI_K_PAGEUP:
3005 case VI_K_PAGEDOWN: 3004 case VI_K_PAGEDOWN:
3005 case VI_K_DELETE:
3006 goto key_cmd_mode; 3006 goto key_cmd_mode;
3007 } 3007 }
3008 3008