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) |
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 { char erase_char; // the users erase character char last_input_char; // last char read from user - smalluint chars_to_parse; #if ENABLE_FEATURE_VI_DOT_CMD smallint adding2q; // are we currently adding user input to q int lmc_len; // length of last_modifying_cmd @@ -235,7 +234,6 @@ struct globals { #define last_forward_char (G.last_forward_char ) #define erase_char (G.erase_char ) #define last_input_char (G.last_input_char ) -#define chars_to_parse (G.chars_to_parse ) #if ENABLE_FEATURE_VI_READONLY #define readonly_mode (G.readonly_mode ) #else @@ -620,7 +618,7 @@ static void edit_file(char *fn) // poll to see if there is input already waiting. if we are // not able to display output fast enough to keep up, skip // the display update until we catch up with input. - if (!chars_to_parse && mysleep(0) == 0) { + if (!readbuffer[0] && mysleep(0) == 0) { // no input pending - so update output refresh(FALSE); show_status_line(); @@ -2206,7 +2204,7 @@ static int readit(void) // read (maybe cursor) key from stdin int c; fflush(stdout); - c = read_key(STDIN_FILENO, &chars_to_parse, readbuffer); + c = read_key(STDIN_FILENO, readbuffer); if (c == -1) { // EOF/error go_bottom_and_clear_to_eol(); cookmode(); // terminal to "cooked" @@ -3851,10 +3849,11 @@ static void crash_dummy() cmd1 = " \n\r\002\004\005\006\025\0310^$-+wWeEbBhjklHL"; // is there already a command running? - if (chars_to_parse > 0) + if (readbuffer[0] > 0) goto cd1; cd0: - startrbi = rbi = 0; + readbuffer[0] = 'X'; + startrbi = rbi = 1; sleeptime = 0; // how long to pause between commands memset(readbuffer, '\0', sizeof(readbuffer)); // generate a command by percentages @@ -3928,7 +3927,7 @@ static void crash_dummy() } strcat(readbuffer, "\033"); } - chars_to_parse = strlen(readbuffer); + readbuffer[0] = strlen(readbuffer + 1); cd1: totalcmds++; if (sleeptime > 0) |