diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-16 23:42:13 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-16 23:42:13 +0200 |
commit | d9a3e89f501800c3e7c779b7e9545a5c80134593 (patch) | |
tree | ba3b65ce2d512542a27e78f4820d799008bc0b4c | |
parent | 26e2c1db0df35df1affa558efc12d2bcfd7718e2 (diff) | |
download | busybox-w32-d9a3e89f501800c3e7c779b7e9545a5c80134593.tar.gz busybox-w32-d9a3e89f501800c3e7c779b7e9545a5c80134593.tar.bz2 busybox-w32-d9a3e89f501800c3e7c779b7e9545a5c80134593.zip |
consolidate ESC sequences
function old new delta
bell 2 - -2
CMdown 2 - -2
Ceos 4 - -4
Ceol 4 - -4
CMup 4 - -4
SOs 5 - -5
SOn 5 - -5
CMrc 9 - -9
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | console-tools/clear.c | 3 | ||||
-rw-r--r-- | console-tools/reset.c | 10 | ||||
-rw-r--r-- | editors/vi.c | 16 | ||||
-rw-r--r-- | libbb/lineedit.c | 2 | ||||
-rw-r--r-- | miscutils/fbsplash.c | 4 | ||||
-rw-r--r-- | miscutils/less.c | 10 | ||||
-rw-r--r-- | procps/top.c | 8 | ||||
-rw-r--r-- | procps/watch.c | 3 |
8 files changed, 29 insertions, 27 deletions
diff --git a/console-tools/clear.c b/console-tools/clear.c index 8b727b39b..b0c6d65d2 100644 --- a/console-tools/clear.c +++ b/console-tools/clear.c | |||
@@ -15,5 +15,6 @@ | |||
15 | int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 15 | int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
16 | int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | 16 | int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) |
17 | { | 17 | { |
18 | return printf("\033[H\033[J") != 6; | 18 | /* home; clear to the end of screen */ |
19 | return printf("\033[H""\033[J") != 6; | ||
19 | } | 20 | } |
diff --git a/console-tools/reset.c b/console-tools/reset.c index 6917eda42..f0ea5cb20 100644 --- a/console-tools/reset.c +++ b/console-tools/reset.c | |||
@@ -28,11 +28,11 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
28 | 28 | ||
29 | if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { | 29 | if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) { |
30 | /* See 'man 4 console_codes' for details: | 30 | /* See 'man 4 console_codes' for details: |
31 | * "ESC c" -- Reset | 31 | * "ESC c" -- Reset |
32 | * "ESC ( K" -- Select user mapping | 32 | * "ESC ( K" -- Select user mapping |
33 | * "ESC [ J" -- Erase display | 33 | * "ESC [ J" -- Erase to the end of screen |
34 | * "ESC [ 0 m" -- Reset all display attributes | 34 | * "ESC [ 0 m" -- Reset all display attributes |
35 | * "ESC [ ? 25 h" -- Make cursor visible. | 35 | * "ESC [ ? 25 h" -- Make cursor visible |
36 | */ | 36 | */ |
37 | printf("\033c\033(K\033[J\033[0m\033[?25h"); | 37 | printf("\033c\033(K\033[J\033[0m\033[?25h"); |
38 | /* http://bugs.busybox.net/view.php?id=1414: | 38 | /* http://bugs.busybox.net/view.php?id=1414: |
diff --git a/editors/vi.c b/editors/vi.c index b8cacb43f..d9124fd76 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -60,18 +60,18 @@ enum { | |||
60 | 60 | ||
61 | /* vt102 typical ESC sequence */ | 61 | /* vt102 typical ESC sequence */ |
62 | /* terminal standout start/normal ESC sequence */ | 62 | /* terminal standout start/normal ESC sequence */ |
63 | static const char SOs[] ALIGN1 = "\033[7m"; | 63 | #define SOs "\033[7m" |
64 | static const char SOn[] ALIGN1 = "\033[0m"; | 64 | #define SOn "\033[0m" |
65 | /* terminal bell sequence */ | 65 | /* terminal bell sequence */ |
66 | static const char bell[] ALIGN1 = "\007"; | 66 | #define bell "\007" |
67 | /* Clear-end-of-line and Clear-end-of-screen ESC sequence */ | 67 | /* Clear-end-of-line and Clear-end-of-screen ESC sequence */ |
68 | static const char Ceol[] ALIGN1 = "\033[K"; | 68 | #define Ceol "\033[K" |
69 | static const char Ceos[] ALIGN1 = "\033[J"; | 69 | #define Ceos "\033[J" |
70 | /* Cursor motion arbitrary destination ESC sequence */ | 70 | /* Cursor motion arbitrary destination ESC sequence */ |
71 | static const char CMrc[] ALIGN1 = "\033[%d;%dH"; | 71 | #define CMrc "\033[%u;%uH" |
72 | /* Cursor motion up and down ESC sequence */ | 72 | /* Cursor motion up and down ESC sequence */ |
73 | static const char CMup[] ALIGN1 = "\033[A"; | 73 | #define CMup "\033[A" |
74 | static const char CMdown[] ALIGN1 = "\n"; | 74 | #define CMdown "\n" |
75 | 75 | ||
76 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK | 76 | #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK |
77 | // cmds modifying text[] | 77 | // cmds modifying text[] |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 72a1786ff..bc089ab1c 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -466,7 +466,7 @@ static void input_backward(unsigned num) | |||
466 | cmdedit_x = w * count_y - num; | 466 | cmdedit_x = w * count_y - num; |
467 | } | 467 | } |
468 | /* go to 1st column; go up; go to correct column */ | 468 | /* go to 1st column; go up; go to correct column */ |
469 | printf("\r" "\033[%dA" "\033[%dC", count_y, cmdedit_x); | 469 | printf("\r" "\033[%uA" "\033[%uC", count_y, cmdedit_x); |
470 | } | 470 | } |
471 | 471 | ||
472 | static void put_prompt(void) | 472 | static void put_prompt(void) |
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index 5974006bb..e370d207b 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c | |||
@@ -359,7 +359,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) | |||
359 | 359 | ||
360 | if (fifo_filename && bCursorOff) { | 360 | if (fifo_filename && bCursorOff) { |
361 | // hide cursor (BEFORE any fb ops) | 361 | // hide cursor (BEFORE any fb ops) |
362 | full_write(STDOUT_FILENO, "\x1b" "[?25l", 6); | 362 | full_write(STDOUT_FILENO, "\033[?25l", 6); |
363 | } | 363 | } |
364 | 364 | ||
365 | fb_drawimage(); | 365 | fb_drawimage(); |
@@ -404,7 +404,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) | |||
404 | } | 404 | } |
405 | 405 | ||
406 | if (bCursorOff) // restore cursor | 406 | if (bCursorOff) // restore cursor |
407 | full_write(STDOUT_FILENO, "\x1b" "[?25h", 6); | 407 | full_write(STDOUT_FILENO, "\033[?25h", 6); |
408 | 408 | ||
409 | return EXIT_SUCCESS; | 409 | return EXIT_SUCCESS; |
410 | } | 410 | } |
diff --git a/miscutils/less.c b/miscutils/less.c index e4f8ab979..848266212 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -29,11 +29,11 @@ | |||
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | /* The escape codes for highlighted and normal text */ | 31 | /* The escape codes for highlighted and normal text */ |
32 | #define HIGHLIGHT "\033[7m" | 32 | #define HIGHLIGHT "\033[7m" |
33 | #define NORMAL "\033[0m" | 33 | #define NORMAL "\033[0m" |
34 | /* The escape code to clear the screen */ | 34 | /* The escape code to home and clear to the end of screen */ |
35 | #define CLEAR "\033[H\033[J" | 35 | #define CLEAR "\033[H\033[J" |
36 | /* The escape code to clear to end of line */ | 36 | /* The escape code to clear to the end of line */ |
37 | #define CLEAR_2_EOL "\033[K" | 37 | #define CLEAR_2_EOL "\033[K" |
38 | 38 | ||
39 | enum { | 39 | enum { |
diff --git a/procps/top.c b/procps/top.c index f5c0a123f..e4afafc4c 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -478,8 +478,8 @@ static unsigned long display_header(int scr_width, int *lines_rem_p) | |||
478 | snprintf(scrbuf, scr_width, | 478 | snprintf(scrbuf, scr_width, |
479 | "Mem: %luK used, %luK free, %luK shrd, %luK buff, %luK cached", | 479 | "Mem: %luK used, %luK free, %luK shrd, %luK buff, %luK cached", |
480 | used, mfree, shared, buffers, cached); | 480 | used, mfree, shared, buffers, cached); |
481 | /* clear screen & go to top */ | 481 | /* go to top & clear to the end of screen */ |
482 | printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf); | 482 | printf(OPT_BATCH_MODE ? "%s\n" : "\033[H\033[J%s\n", scrbuf); |
483 | (*lines_rem_p)--; | 483 | (*lines_rem_p)--; |
484 | 484 | ||
485 | /* Display CPU time split as percentage of total time | 485 | /* Display CPU time split as percentage of total time |
@@ -518,7 +518,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
518 | #endif | 518 | #endif |
519 | 519 | ||
520 | /* what info of the processes is shown */ | 520 | /* what info of the processes is shown */ |
521 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, | 521 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, |
522 | " PID PPID USER STAT VSZ %MEM" | 522 | " PID PPID USER STAT VSZ %MEM" |
523 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") | 523 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") |
524 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") | 524 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") |
@@ -772,7 +772,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p) | |||
772 | snprintf(linebuf, sizeof(linebuf), | 772 | snprintf(linebuf, sizeof(linebuf), |
773 | "Mem total:%s anon:%s map:%s free:%s", | 773 | "Mem total:%s anon:%s map:%s free:%s", |
774 | S(total), S(anon), S(map), S(mfree)); | 774 | S(total), S(anon), S(map), S(mfree)); |
775 | printf(OPT_BATCH_MODE ? "%.*s\n" : "\e[H\e[J%.*s\n", scr_width, linebuf); | 775 | printf(OPT_BATCH_MODE ? "%.*s\n" : "\033[H\033[J%.*s\n", scr_width, linebuf); |
776 | 776 | ||
777 | snprintf(linebuf, sizeof(linebuf), | 777 | snprintf(linebuf, sizeof(linebuf), |
778 | " slab:%s buf:%s cache:%s dirty:%s write:%s", | 778 | " slab:%s buf:%s cache:%s dirty:%s write:%s", |
diff --git a/procps/watch.c b/procps/watch.c index 126945c40..a1cde9ea0 100644 --- a/procps/watch.c +++ b/procps/watch.c | |||
@@ -52,7 +52,8 @@ int watch_main(int argc UNUSED_PARAM, char **argv) | |||
52 | width = (unsigned)-1; // make sure first time new_width != width | 52 | width = (unsigned)-1; // make sure first time new_width != width |
53 | header = NULL; | 53 | header = NULL; |
54 | while (1) { | 54 | while (1) { |
55 | printf("\033[H\033[J"); | 55 | /* home; clear to the end of screen */ |
56 | printf("\033[H""\033[J"); | ||
56 | if (!(opt & 0x2)) { // no -t | 57 | if (!(opt & 0x2)) { // no -t |
57 | const unsigned time_len = sizeof("1234-67-90 23:56:89"); | 58 | const unsigned time_len = sizeof("1234-67-90 23:56:89"); |
58 | time_t t; | 59 | time_t t; |