diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 22:48:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 22:48:30 +0200 |
commit | 8187e0143874e1bf0412263e716cf8c782a5aa16 (patch) | |
tree | 289b592b43a7226bbd355728798930c9ead45893 /editors | |
parent | 136946c3ea6a14d391b5045b5eb71fa8ec207077 (diff) | |
download | busybox-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.tar.gz busybox-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.tar.bz2 busybox-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.zip |
*: use ESC define instead of "\033"; use ESC[m instead of ESC[0m
text data bss dec hex filename
922535 481 6832 929848 e3038 busybox_old
922534 481 6832 929847 e3037 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/vi.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/editors/vi.c b/editors/vi.c index 116022c93..c010f7999 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -224,24 +224,25 @@ enum { | |||
224 | * See "Xterm Control Sequences" | 224 | * See "Xterm Control Sequences" |
225 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | 225 | * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html |
226 | */ | 226 | */ |
227 | #define ESC "\033" | ||
227 | /* Inverse/Normal text */ | 228 | /* Inverse/Normal text */ |
228 | #define ESC_BOLD_TEXT "\033[7m" | 229 | #define ESC_BOLD_TEXT ESC"[7m" |
229 | #define ESC_NORM_TEXT "\033[0m" | 230 | #define ESC_NORM_TEXT ESC"[m" |
230 | /* Bell */ | 231 | /* Bell */ |
231 | #define ESC_BELL "\007" | 232 | #define ESC_BELL "\007" |
232 | /* Clear-to-end-of-line */ | 233 | /* Clear-to-end-of-line */ |
233 | #define ESC_CLEAR2EOL "\033[K" | 234 | #define ESC_CLEAR2EOL ESC"[K" |
234 | /* Clear-to-end-of-screen. | 235 | /* Clear-to-end-of-screen. |
235 | * (We use default param here. | 236 | * (We use default param here. |
236 | * Full sequence is "ESC [ <num> J", | 237 | * Full sequence is "ESC [ <num> J", |
237 | * <num> is 0/1/2 = "erase below/above/all".) | 238 | * <num> is 0/1/2 = "erase below/above/all".) |
238 | */ | 239 | */ |
239 | #define ESC_CLEAR2EOS "\033[J" | 240 | #define ESC_CLEAR2EOS ESC"[J" |
240 | /* Cursor to given coordinate (1,1: top left) */ | 241 | /* Cursor to given coordinate (1,1: top left) */ |
241 | #define ESC_SET_CURSOR_POS "\033[%u;%uH" | 242 | #define ESC_SET_CURSOR_POS ESC"[%u;%uH" |
242 | //UNUSED | 243 | //UNUSED |
243 | ///* Cursor up and down */ | 244 | ///* Cursor up and down */ |
244 | //#define ESC_CURSOR_UP "\033[A" | 245 | //#define ESC_CURSOR_UP ESC"[A" |
245 | //#define ESC_CURSOR_DOWN "\n" | 246 | //#define ESC_CURSOR_DOWN "\n" |
246 | 247 | ||
247 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK | 248 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK |
@@ -696,14 +697,14 @@ int vi_main(int argc, char **argv) | |||
696 | save_argc = argc; | 697 | save_argc = argc; |
697 | optind = 0; | 698 | optind = 0; |
698 | // "Save cursor, use alternate screen buffer, clear screen" | 699 | // "Save cursor, use alternate screen buffer, clear screen" |
699 | write1("\033[?1049h"); | 700 | write1(ESC"[?1049h"); |
700 | while (1) { | 701 | while (1) { |
701 | edit_file(argv[optind]); /* param might be NULL */ | 702 | edit_file(argv[optind]); /* param might be NULL */ |
702 | if (++optind >= argc) | 703 | if (++optind >= argc) |
703 | break; | 704 | break; |
704 | } | 705 | } |
705 | // "Use normal screen buffer, restore cursor" | 706 | // "Use normal screen buffer, restore cursor" |
706 | write1("\033[?1049l"); | 707 | write1(ESC"[?1049l"); |
707 | //----------------------------------------------------------- | 708 | //----------------------------------------------------------- |
708 | 709 | ||
709 | return 0; | 710 | return 0; |
@@ -772,7 +773,7 @@ static void edit_file(char *fn) | |||
772 | #if ENABLE_FEATURE_VI_ASK_TERMINAL | 773 | #if ENABLE_FEATURE_VI_ASK_TERMINAL |
773 | if (G.get_rowcol_error /* TODO? && no input on stdin */) { | 774 | if (G.get_rowcol_error /* TODO? && no input on stdin */) { |
774 | uint64_t k; | 775 | uint64_t k; |
775 | write1("\033[999;999H" "\033[6n"); | 776 | write1(ESC"[999;999H" ESC"[6n"); |
776 | fflush_all(); | 777 | fflush_all(); |
777 | k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); | 778 | k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); |
778 | if ((int32_t)k == KEYCODE_CURSOR_POS) { | 779 | if ((int32_t)k == KEYCODE_CURSOR_POS) { |
@@ -4454,7 +4455,7 @@ static void crash_dummy() | |||
4454 | sleeptime = 0; // how fast to type | 4455 | sleeptime = 0; // how fast to type |
4455 | } | 4456 | } |
4456 | } | 4457 | } |
4457 | strcat(readbuffer, "\033"); | 4458 | strcat(readbuffer, ESC); |
4458 | } | 4459 | } |
4459 | readbuffer[0] = strlen(readbuffer + 1); | 4460 | readbuffer[0] = strlen(readbuffer + 1); |
4460 | cd1: | 4461 | cd1: |