From 8187e0143874e1bf0412263e716cf8c782a5aa16 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 13 Sep 2017 22:48:30 +0200 Subject: *: 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 --- editors/vi.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'editors') diff --git a/editors/vi.c b/editors/vi.c index 116022c..c010f79 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -224,24 +224,25 @@ enum { * See "Xterm Control Sequences" * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html */ +#define ESC "\033" /* Inverse/Normal text */ -#define ESC_BOLD_TEXT "\033[7m" -#define ESC_NORM_TEXT "\033[0m" +#define ESC_BOLD_TEXT ESC"[7m" +#define ESC_NORM_TEXT ESC"[m" /* Bell */ #define ESC_BELL "\007" /* Clear-to-end-of-line */ -#define ESC_CLEAR2EOL "\033[K" +#define ESC_CLEAR2EOL ESC"[K" /* Clear-to-end-of-screen. * (We use default param here. * Full sequence is "ESC [ J", * is 0/1/2 = "erase below/above/all".) */ -#define ESC_CLEAR2EOS "\033[J" +#define ESC_CLEAR2EOS ESC"[J" /* Cursor to given coordinate (1,1: top left) */ -#define ESC_SET_CURSOR_POS "\033[%u;%uH" +#define ESC_SET_CURSOR_POS ESC"[%u;%uH" //UNUSED ///* Cursor up and down */ -//#define ESC_CURSOR_UP "\033[A" +//#define ESC_CURSOR_UP ESC"[A" //#define ESC_CURSOR_DOWN "\n" #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK @@ -696,14 +697,14 @@ int vi_main(int argc, char **argv) save_argc = argc; optind = 0; // "Save cursor, use alternate screen buffer, clear screen" - write1("\033[?1049h"); + write1(ESC"[?1049h"); while (1) { edit_file(argv[optind]); /* param might be NULL */ if (++optind >= argc) break; } // "Use normal screen buffer, restore cursor" - write1("\033[?1049l"); + write1(ESC"[?1049l"); //----------------------------------------------------------- return 0; @@ -772,7 +773,7 @@ static void edit_file(char *fn) #if ENABLE_FEATURE_VI_ASK_TERMINAL if (G.get_rowcol_error /* TODO? && no input on stdin */) { uint64_t k; - write1("\033[999;999H" "\033[6n"); + write1(ESC"[999;999H" ESC"[6n"); fflush_all(); k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); if ((int32_t)k == KEYCODE_CURSOR_POS) { @@ -4454,7 +4455,7 @@ static void crash_dummy() sleeptime = 0; // how fast to type } } - strcat(readbuffer, "\033"); + strcat(readbuffer, ESC); } readbuffer[0] = strlen(readbuffer + 1); cd1: -- cgit v1.1