aboutsummaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/editors/vi.c b/editors/vi.c
index b81f2b92d..e5ca3adfa 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -30,7 +30,7 @@
30//config: you may wish to use something else. 30//config: you may wish to use something else.
31//config: 31//config:
32//config:config FEATURE_VI_MAX_LEN 32//config:config FEATURE_VI_MAX_LEN
33//config: int "Maximum screen width in vi" 33//config: int "Maximum screen width"
34//config: range 256 16384 34//config: range 256 16384
35//config: default 4096 35//config: default 4096
36//config: depends on VI 36//config: depends on VI
@@ -39,7 +39,7 @@
39//config: Make it smaller than 4k only if you are very limited on memory. 39//config: Make it smaller than 4k only if you are very limited on memory.
40//config: 40//config:
41//config:config FEATURE_VI_8BIT 41//config:config FEATURE_VI_8BIT
42//config: bool "Allow vi to display 8-bit chars (otherwise shows dots)" 42//config: bool "Allow to display 8-bit chars (otherwise shows dots)"
43//config: default n 43//config: default n
44//config: depends on VI 44//config: depends on VI
45//config: help 45//config: help
@@ -53,7 +53,7 @@
53//config: default y 53//config: default y
54//config: depends on VI 54//config: depends on VI
55//config: help 55//config: help
56//config: Enable a limited set of colon commands for vi. This does not 56//config: Enable a limited set of colon commands. This does not
57//config: provide an "ex" mode. 57//config: provide an "ex" mode.
58//config: 58//config:
59//config:config FEATURE_VI_YANKMARK 59//config:config FEATURE_VI_YANKMARK
@@ -61,16 +61,14 @@
61//config: default y 61//config: default y
62//config: depends on VI 62//config: depends on VI
63//config: help 63//config: help
64//config: This will enable you to use yank and put, as well as mark in 64//config: This will enable you to use yank and put, as well as mark.
65//config: busybox vi.
66//config: 65//config:
67//config:config FEATURE_VI_SEARCH 66//config:config FEATURE_VI_SEARCH
68//config: bool "Enable search and replace cmds" 67//config: bool "Enable search and replace cmds"
69//config: default y 68//config: default y
70//config: depends on VI 69//config: depends on VI
71//config: help 70//config: help
72//config: Select this if you wish to be able to do search and replace in 71//config: Select this if you wish to be able to do search and replace.
73//config: busybox vi.
74//config: 72//config:
75//config:config FEATURE_VI_REGEX_SEARCH 73//config:config FEATURE_VI_REGEX_SEARCH
76//config: bool "Enable regex in search and replace" 74//config: bool "Enable regex in search and replace"
@@ -84,16 +82,15 @@
84//config: default y 82//config: default y
85//config: depends on VI 83//config: depends on VI
86//config: help 84//config: help
87//config: Selecting this option will make busybox vi signal aware. This will 85//config: Selecting this option will make vi signal aware. This will support
88//config: make busybox vi support SIGWINCH to deal with Window Changes, catch 86//config: SIGWINCH to deal with Window Changes, catch ^Z and ^C and alarms.
89//config: Ctrl-Z and Ctrl-C and alarms.
90//config: 87//config:
91//config:config FEATURE_VI_DOT_CMD 88//config:config FEATURE_VI_DOT_CMD
92//config: bool "Remember previous cmd and \".\" cmd" 89//config: bool "Remember previous cmd and \".\" cmd"
93//config: default y 90//config: default y
94//config: depends on VI 91//config: depends on VI
95//config: help 92//config: help
96//config: Make busybox vi remember the last command and be able to repeat it. 93//config: Make vi remember the last command and be able to repeat it.
97//config: 94//config:
98//config:config FEATURE_VI_READONLY 95//config:config FEATURE_VI_READONLY
99//config: bool "Enable -R option and \"view\" mode" 96//config: bool "Enable -R option and \"view\" mode"
@@ -104,25 +101,23 @@
104//config: open a file in read-only mode. 101//config: open a file in read-only mode.
105//config: 102//config:
106//config:config FEATURE_VI_SETOPTS 103//config:config FEATURE_VI_SETOPTS
107//config: bool "Enable set-able options, ai ic showmatch" 104//config: bool "Enable settable options, ai ic showmatch"
108//config: default y 105//config: default y
109//config: depends on VI 106//config: depends on VI
110//config: help 107//config: help
111//config: Enable the editor to set some (ai, ic, showmatch) options. 108//config: Enable the editor to set some (ai, ic, showmatch) options.
112//config: 109//config:
113//config:config FEATURE_VI_SET 110//config:config FEATURE_VI_SET
114//config: bool "Support for :set" 111//config: bool "Support :set"
115//config: default y 112//config: default y
116//config: depends on VI 113//config: depends on VI
117//config: help
118//config: Support for ":set".
119//config: 114//config:
120//config:config FEATURE_VI_WIN_RESIZE 115//config:config FEATURE_VI_WIN_RESIZE
121//config: bool "Handle window resize" 116//config: bool "Handle window resize"
122//config: default y 117//config: default y
123//config: depends on VI 118//config: depends on VI
124//config: help 119//config: help
125//config: Make busybox vi behave nicely with terminals that get resized. 120//config: Behave nicely with terminals that get resized.
126//config: 121//config:
127//config:config FEATURE_VI_ASK_TERMINAL 122//config:config FEATURE_VI_ASK_TERMINAL
128//config: bool "Use 'tell me cursor position' ESC sequence to measure window" 123//config: bool "Use 'tell me cursor position' ESC sequence to measure window"
@@ -133,15 +128,16 @@
133//config: this option makes vi perform a last-ditch effort to find it: 128//config: this option makes vi perform a last-ditch effort to find it:
134//config: position cursor to 999,999 and ask terminal to report real 129//config: position cursor to 999,999 and ask terminal to report real
135//config: cursor position using "ESC [ 6 n" escape sequence, then read stdin. 130//config: cursor position using "ESC [ 6 n" escape sequence, then read stdin.
136//config:
137//config: This is not clean but helps a lot on serial lines and such. 131//config: This is not clean but helps a lot on serial lines and such.
132//config:
138//config:config FEATURE_VI_UNDO 133//config:config FEATURE_VI_UNDO
139//config: bool "Support undo command 'u'" 134//config: bool "Support undo command \"u\""
140//config: default y 135//config: default y
141//config: depends on VI 136//config: depends on VI
142//config: help 137//config: help
143//config: Support the 'u' command to undo insertion, deletion, and replacement 138//config: Support the 'u' command to undo insertion, deletion, and replacement
144//config: of text. 139//config: of text.
140//config:
145//config:config FEATURE_VI_UNDO_QUEUE 141//config:config FEATURE_VI_UNDO_QUEUE
146//config: bool "Enable undo operation queuing" 142//config: bool "Enable undo operation queuing"
147//config: default y 143//config: default y
@@ -152,6 +148,7 @@
152//config: reached, the contents of the queue are committed to the undo stack. 148//config: reached, the contents of the queue are committed to the undo stack.
153//config: This increases the size of the undo code and allows some undo 149//config: This increases the size of the undo code and allows some undo
154//config: operations (especially un-typing/backspacing) to be far more useful. 150//config: operations (especially un-typing/backspacing) to be far more useful.
151//config:
155//config:config FEATURE_VI_UNDO_QUEUE_MAX 152//config:config FEATURE_VI_UNDO_QUEUE_MAX
156//config: int "Maximum undo character queue size" 153//config: int "Maximum undo character queue size"
157//config: default 256 154//config: default 256
@@ -357,7 +354,7 @@ struct globals {
357#if ENABLE_FEATURE_VI_USE_SIGNALS 354#if ENABLE_FEATURE_VI_USE_SIGNALS
358 sigjmp_buf restart; // catch_sig() 355 sigjmp_buf restart; // catch_sig()
359#endif 356#endif
360 struct termios term_orig, term_vi; // remember what the cooked mode was 357 struct termios term_orig; // remember what the cooked mode was
361#if ENABLE_FEATURE_VI_COLON 358#if ENABLE_FEATURE_VI_COLON
362 char *initial_cmds[3]; // currently 2 entries, NULL terminated 359 char *initial_cmds[3]; // currently 2 entries, NULL terminated
363#endif 360#endif
@@ -465,7 +462,6 @@ struct globals {
465#define context_end (G.context_end ) 462#define context_end (G.context_end )
466#define restart (G.restart ) 463#define restart (G.restart )
467#define term_orig (G.term_orig ) 464#define term_orig (G.term_orig )
468#define term_vi (G.term_vi )
469#define initial_cmds (G.initial_cmds ) 465#define initial_cmds (G.initial_cmds )
470#define readbuffer (G.readbuffer ) 466#define readbuffer (G.readbuffer )
471#define scr_out_buf (G.scr_out_buf ) 467#define scr_out_buf (G.scr_out_buf )
@@ -1461,7 +1457,7 @@ static void colon(char *buf)
1461 } 1457 }
1462#endif /* FEATURE_VI_SEARCH */ 1458#endif /* FEATURE_VI_SEARCH */
1463 } else if (strncmp(cmd, "version", i) == 0) { // show software version 1459 } else if (strncmp(cmd, "version", i) == 0) { // show software version
1464 status_line(BB_VER " " BB_BT); 1460 status_line(BB_VER);
1465 } else if (strncmp(cmd, "write", i) == 0 // write text to file 1461 } else if (strncmp(cmd, "write", i) == 0 // write text to file
1466 || strncmp(cmd, "wq", i) == 0 1462 || strncmp(cmd, "wq", i) == 0
1467 || strncmp(cmd, "wn", i) == 0 1463 || strncmp(cmd, "wn", i) == 0
@@ -2734,15 +2730,9 @@ static char *swap_context(char *p) // goto new context for '' command make this
2734//----- Set terminal attributes -------------------------------- 2730//----- Set terminal attributes --------------------------------
2735static void rawmode(void) 2731static void rawmode(void)
2736{ 2732{
2737 tcgetattr(0, &term_orig); 2733 // no TERMIOS_CLEAR_ISIG: leave ISIG on - allow signals
2738 term_vi = term_orig; 2734 set_termios_to_raw(STDIN_FILENO, &term_orig, TERMIOS_RAW_CRNL);
2739 term_vi.c_lflag &= (~ICANON & ~ECHO); // leave ISIG on - allow intr's 2735 erase_char = term_orig.c_cc[VERASE];
2740 term_vi.c_iflag &= (~IXON & ~ICRNL);
2741 term_vi.c_oflag &= (~ONLCR);
2742 term_vi.c_cc[VMIN] = 1;
2743 term_vi.c_cc[VTIME] = 0;
2744 erase_char = term_vi.c_cc[VERASE];
2745 tcsetattr_stdin_TCSANOW(&term_vi);
2746} 2736}
2747 2737
2748static void cookmode(void) 2738static void cookmode(void)