diff options
author | Ron Yorston <rmy@pobox.com> | 2017-09-27 10:08:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-09-27 10:11:19 +0100 |
commit | d9383e984da8de72e61e5094a3cf6404c5707ddc (patch) | |
tree | dd42825854fc42aea40d4f7a95548d53721d1733 /editors/vi.c | |
parent | 166b3e4e82799f87d3b002c7177891111eff079e (diff) | |
parent | 0c4dbd481aedb5d22c1048e7f7eb547a3b5e50a5 (diff) | |
download | busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.gz busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.bz2 busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'editors/vi.c')
-rw-r--r-- | editors/vi.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/editors/vi.c b/editors/vi.c index 91e954a87..8393eb825 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -5,7 +5,6 @@ | |||
5 | * | 5 | * |
6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | |||
9 | /* | 8 | /* |
10 | * Things To Do: | 9 | * Things To Do: |
11 | * EXINIT | 10 | * EXINIT |
@@ -19,7 +18,6 @@ | |||
19 | * ":r !cmd" and "!cmd" to filter text through an external command | 18 | * ":r !cmd" and "!cmd" to filter text through an external command |
20 | * An "ex" line oriented mode- maybe using "cmdedit" | 19 | * An "ex" line oriented mode- maybe using "cmdedit" |
21 | */ | 20 | */ |
22 | |||
23 | //config:config VI | 21 | //config:config VI |
24 | //config: bool "vi (22 kb)" | 22 | //config: bool "vi (22 kb)" |
25 | //config: default y | 23 | //config: default y |
@@ -224,24 +222,25 @@ enum { | |||
224 | * See "Xterm Control Sequences" | 222 | * See "Xterm Control Sequences" |
225 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | 223 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html |
226 | */ | 224 | */ |
225 | #define ESC "\033" | ||
227 | /* Inverse/Normal text */ | 226 | /* Inverse/Normal text */ |
228 | #define ESC_BOLD_TEXT "\033[7m" | 227 | #define ESC_BOLD_TEXT ESC"[7m" |
229 | #define ESC_NORM_TEXT "\033[0m" | 228 | #define ESC_NORM_TEXT ESC"[m" |
230 | /* Bell */ | 229 | /* Bell */ |
231 | #define ESC_BELL "\007" | 230 | #define ESC_BELL "\007" |
232 | /* Clear-to-end-of-line */ | 231 | /* Clear-to-end-of-line */ |
233 | #define ESC_CLEAR2EOL "\033[K" | 232 | #define ESC_CLEAR2EOL ESC"[K" |
234 | /* Clear-to-end-of-screen. | 233 | /* Clear-to-end-of-screen. |
235 | * (We use default param here. | 234 | * (We use default param here. |
236 | * Full sequence is "ESC [ <num> J", | 235 | * Full sequence is "ESC [ <num> J", |
237 | * <num> is 0/1/2 = "erase below/above/all".) | 236 | * <num> is 0/1/2 = "erase below/above/all".) |
238 | */ | 237 | */ |
239 | #define ESC_CLEAR2EOS "\033[J" | 238 | #define ESC_CLEAR2EOS ESC"[J" |
240 | /* Cursor to given coordinate (1,1: top left) */ | 239 | /* Cursor to given coordinate (1,1: top left) */ |
241 | #define ESC_SET_CURSOR_POS "\033[%u;%uH" | 240 | #define ESC_SET_CURSOR_POS ESC"[%u;%uH" |
242 | //UNUSED | 241 | //UNUSED |
243 | ///* Cursor up and down */ | 242 | ///* Cursor up and down */ |
244 | //#define ESC_CURSOR_UP "\033[A" | 243 | //#define ESC_CURSOR_UP ESC"[A" |
245 | //#define ESC_CURSOR_DOWN "\n" | 244 | //#define ESC_CURSOR_DOWN "\n" |
246 | 245 | ||
247 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK | 246 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK |
@@ -696,14 +695,14 @@ int vi_main(int argc, char **argv) | |||
696 | save_argc = argc; | 695 | save_argc = argc; |
697 | optind = 0; | 696 | optind = 0; |
698 | // "Save cursor, use alternate screen buffer, clear screen" | 697 | // "Save cursor, use alternate screen buffer, clear screen" |
699 | write1("\033[?1049h"); | 698 | write1(ESC"[?1049h"); |
700 | while (1) { | 699 | while (1) { |
701 | edit_file(argv[optind]); /* param might be NULL */ | 700 | edit_file(argv[optind]); /* param might be NULL */ |
702 | if (++optind >= argc) | 701 | if (++optind >= argc) |
703 | break; | 702 | break; |
704 | } | 703 | } |
705 | // "Use normal screen buffer, restore cursor" | 704 | // "Use normal screen buffer, restore cursor" |
706 | write1("\033[?1049l"); | 705 | write1(ESC"[?1049l"); |
707 | //----------------------------------------------------------- | 706 | //----------------------------------------------------------- |
708 | 707 | ||
709 | return 0; | 708 | return 0; |
@@ -772,7 +771,7 @@ static void edit_file(char *fn) | |||
772 | #if ENABLE_FEATURE_VI_ASK_TERMINAL | 771 | #if ENABLE_FEATURE_VI_ASK_TERMINAL |
773 | if (G.get_rowcol_error /* TODO? && no input on stdin */) { | 772 | if (G.get_rowcol_error /* TODO? && no input on stdin */) { |
774 | uint64_t k; | 773 | uint64_t k; |
775 | write1("\033[999;999H" "\033[6n"); | 774 | write1(ESC"[999;999H" ESC"[6n"); |
776 | fflush_all(); | 775 | fflush_all(); |
777 | k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); | 776 | k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); |
778 | if ((int32_t)k == KEYCODE_CURSOR_POS) { | 777 | if ((int32_t)k == KEYCODE_CURSOR_POS) { |
@@ -4501,7 +4500,7 @@ static void crash_dummy() | |||
4501 | sleeptime = 0; // how fast to type | 4500 | sleeptime = 0; // how fast to type |
4502 | } | 4501 | } |
4503 | } | 4502 | } |
4504 | strcat(readbuffer, "\033"); | 4503 | strcat(readbuffer, ESC); |
4505 | } | 4504 | } |
4506 | readbuffer[0] = strlen(readbuffer + 1); | 4505 | readbuffer[0] = strlen(readbuffer + 1); |
4507 | cd1: | 4506 | cd1: |