diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-17 16:44:54 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-05-17 16:44:54 +0200 |
commit | 020f40693a08b836abdea74f3823a0bce0378ec5 (patch) | |
tree | 4ae11c9b2156cccc1af8904c11c195b25b2886b0 /editors | |
parent | 071ede1e5de784820f39c2546000c08d74b12f6d (diff) | |
download | busybox-w32-020f40693a08b836abdea74f3823a0bce0378ec5.tar.gz busybox-w32-020f40693a08b836abdea74f3823a0bce0378ec5.tar.bz2 busybox-w32-020f40693a08b836abdea74f3823a0bce0378ec5.zip |
line editing: add an option to emit ESC [ 6 n and use results
This makes line editing able to recognize case when
cursor was not at the beginning of the line. It may also
be adapted later to find out display size (serial line users
would love it).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/vi.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/editors/vi.c b/editors/vi.c index ccc53fb58..ee5b5d98a 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -151,7 +151,6 @@ struct globals { | |||
151 | char erase_char; // the users erase character | 151 | char erase_char; // the users erase character |
152 | char last_input_char; // last char read from user | 152 | char last_input_char; // last char read from user |
153 | 153 | ||
154 | smalluint chars_to_parse; | ||
155 | #if ENABLE_FEATURE_VI_DOT_CMD | 154 | #if ENABLE_FEATURE_VI_DOT_CMD |
156 | smallint adding2q; // are we currently adding user input to q | 155 | smallint adding2q; // are we currently adding user input to q |
157 | int lmc_len; // length of last_modifying_cmd | 156 | int lmc_len; // length of last_modifying_cmd |
@@ -235,7 +234,6 @@ struct globals { | |||
235 | #define last_forward_char (G.last_forward_char ) | 234 | #define last_forward_char (G.last_forward_char ) |
236 | #define erase_char (G.erase_char ) | 235 | #define erase_char (G.erase_char ) |
237 | #define last_input_char (G.last_input_char ) | 236 | #define last_input_char (G.last_input_char ) |
238 | #define chars_to_parse (G.chars_to_parse ) | ||
239 | #if ENABLE_FEATURE_VI_READONLY | 237 | #if ENABLE_FEATURE_VI_READONLY |
240 | #define readonly_mode (G.readonly_mode ) | 238 | #define readonly_mode (G.readonly_mode ) |
241 | #else | 239 | #else |
@@ -620,7 +618,7 @@ static void edit_file(char *fn) | |||
620 | // poll to see if there is input already waiting. if we are | 618 | // poll to see if there is input already waiting. if we are |
621 | // not able to display output fast enough to keep up, skip | 619 | // not able to display output fast enough to keep up, skip |
622 | // the display update until we catch up with input. | 620 | // the display update until we catch up with input. |
623 | if (!chars_to_parse && mysleep(0) == 0) { | 621 | if (!readbuffer[0] && mysleep(0) == 0) { |
624 | // no input pending - so update output | 622 | // no input pending - so update output |
625 | refresh(FALSE); | 623 | refresh(FALSE); |
626 | show_status_line(); | 624 | show_status_line(); |
@@ -2206,7 +2204,7 @@ static int readit(void) // read (maybe cursor) key from stdin | |||
2206 | int c; | 2204 | int c; |
2207 | 2205 | ||
2208 | fflush(stdout); | 2206 | fflush(stdout); |
2209 | c = read_key(STDIN_FILENO, &chars_to_parse, readbuffer); | 2207 | c = read_key(STDIN_FILENO, readbuffer); |
2210 | if (c == -1) { // EOF/error | 2208 | if (c == -1) { // EOF/error |
2211 | go_bottom_and_clear_to_eol(); | 2209 | go_bottom_and_clear_to_eol(); |
2212 | cookmode(); // terminal to "cooked" | 2210 | cookmode(); // terminal to "cooked" |
@@ -3851,10 +3849,11 @@ static void crash_dummy() | |||
3851 | cmd1 = " \n\r\002\004\005\006\025\0310^$-+wWeEbBhjklHL"; | 3849 | cmd1 = " \n\r\002\004\005\006\025\0310^$-+wWeEbBhjklHL"; |
3852 | 3850 | ||
3853 | // is there already a command running? | 3851 | // is there already a command running? |
3854 | if (chars_to_parse > 0) | 3852 | if (readbuffer[0] > 0) |
3855 | goto cd1; | 3853 | goto cd1; |
3856 | cd0: | 3854 | cd0: |
3857 | startrbi = rbi = 0; | 3855 | readbuffer[0] = 'X'; |
3856 | startrbi = rbi = 1; | ||
3858 | sleeptime = 0; // how long to pause between commands | 3857 | sleeptime = 0; // how long to pause between commands |
3859 | memset(readbuffer, '\0', sizeof(readbuffer)); | 3858 | memset(readbuffer, '\0', sizeof(readbuffer)); |
3860 | // generate a command by percentages | 3859 | // generate a command by percentages |
@@ -3928,7 +3927,7 @@ static void crash_dummy() | |||
3928 | } | 3927 | } |
3929 | strcat(readbuffer, "\033"); | 3928 | strcat(readbuffer, "\033"); |
3930 | } | 3929 | } |
3931 | chars_to_parse = strlen(readbuffer); | 3930 | readbuffer[0] = strlen(readbuffer + 1); |
3932 | cd1: | 3931 | cd1: |
3933 | totalcmds++; | 3932 | totalcmds++; |
3934 | if (sleeptime > 0) | 3933 | if (sleeptime > 0) |