summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console-tools/clear.c3
-rw-r--r--console-tools/reset.c10
-rw-r--r--editors/vi.c16
-rw-r--r--libbb/lineedit.c2
-rw-r--r--miscutils/fbsplash.c4
-rw-r--r--miscutils/less.c10
-rw-r--r--procps/top.c8
-rw-r--r--procps/watch.c3
8 files changed, 29 insertions, 27 deletions
diff --git a/console-tools/clear.c b/console-tools/clear.c
index 8b727b3..b0c6d65 100644
--- a/console-tools/clear.c
+++ b/console-tools/clear.c
@@ -15,5 +15,6 @@
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- return printf("\033[H\033[J") != 6;
+ /* home; clear to the end of screen */
+ return printf("\033[H""\033[J") != 6;
}
diff --git a/console-tools/reset.c b/console-tools/reset.c
index 6917eda..f0ea5cb 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)
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
/* See 'man 4 console_codes' for details:
- * "ESC c" -- Reset
- * "ESC ( K" -- Select user mapping
- * "ESC [ J" -- Erase display
- * "ESC [ 0 m" -- Reset all display attributes
- * "ESC [ ? 25 h" -- Make cursor visible.
+ * "ESC c" -- Reset
+ * "ESC ( K" -- Select user mapping
+ * "ESC [ J" -- Erase to the end of screen
+ * "ESC [ 0 m" -- Reset all display attributes
+ * "ESC [ ? 25 h" -- Make cursor visible
*/
printf("\033c\033(K\033[J\033[0m\033[?25h");
/* http://bugs.busybox.net/view.php?id=1414:
diff --git a/editors/vi.c b/editors/vi.c
index b8cacb4..d9124fd 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -60,18 +60,18 @@ enum {
/* vt102 typical ESC sequence */
/* terminal standout start/normal ESC sequence */
-static const char SOs[] ALIGN1 = "\033[7m";
-static const char SOn[] ALIGN1 = "\033[0m";
+#define SOs "\033[7m"
+#define SOn "\033[0m"
/* terminal bell sequence */
-static const char bell[] ALIGN1 = "\007";
+#define bell "\007"
/* Clear-end-of-line and Clear-end-of-screen ESC sequence */
-static const char Ceol[] ALIGN1 = "\033[K";
-static const char Ceos[] ALIGN1 = "\033[J";
+#define Ceol "\033[K"
+#define Ceos "\033[J"
/* Cursor motion arbitrary destination ESC sequence */
-static const char CMrc[] ALIGN1 = "\033[%d;%dH";
+#define CMrc "\033[%u;%uH"
/* Cursor motion up and down ESC sequence */
-static const char CMup[] ALIGN1 = "\033[A";
-static const char CMdown[] ALIGN1 = "\n";
+#define CMup "\033[A"
+#define CMdown "\n"
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
// cmds modifying text[]
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 72a1786..bc089ab 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -466,7 +466,7 @@ static void input_backward(unsigned num)
cmdedit_x = w * count_y - num;
}
/* go to 1st column; go up; go to correct column */
- printf("\r" "\033[%dA" "\033[%dC", count_y, cmdedit_x);
+ printf("\r" "\033[%uA" "\033[%uC", count_y, cmdedit_x);
}
static void put_prompt(void)
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 5974006..e370d20 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -359,7 +359,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
if (fifo_filename && bCursorOff) {
// hide cursor (BEFORE any fb ops)
- full_write(STDOUT_FILENO, "\x1b" "[?25l", 6);
+ full_write(STDOUT_FILENO, "\033[?25l", 6);
}
fb_drawimage();
@@ -404,7 +404,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv)
}
if (bCursorOff) // restore cursor
- full_write(STDOUT_FILENO, "\x1b" "[?25h", 6);
+ full_write(STDOUT_FILENO, "\033[?25h", 6);
return EXIT_SUCCESS;
}
diff --git a/miscutils/less.c b/miscutils/less.c
index e4f8ab9..8482662 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -29,11 +29,11 @@
#endif
/* The escape codes for highlighted and normal text */
-#define HIGHLIGHT "\033[7m"
-#define NORMAL "\033[0m"
-/* The escape code to clear the screen */
-#define CLEAR "\033[H\033[J"
-/* The escape code to clear to end of line */
+#define HIGHLIGHT "\033[7m"
+#define NORMAL "\033[0m"
+/* The escape code to home and clear to the end of screen */
+#define CLEAR "\033[H\033[J"
+/* The escape code to clear to the end of line */
#define CLEAR_2_EOL "\033[K"
enum {
diff --git a/procps/top.c b/procps/top.c
index f5c0a12..e4afafc 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)
snprintf(scrbuf, scr_width,
"Mem: %luK used, %luK free, %luK shrd, %luK buff, %luK cached",
used, mfree, shared, buffers, cached);
- /* clear screen & go to top */
- printf(OPT_BATCH_MODE ? "%s\n" : "\e[H\e[J%s\n", scrbuf);
+ /* go to top & clear to the end of screen */
+ printf(OPT_BATCH_MODE ? "%s\n" : "\033[H\033[J%s\n", scrbuf);
(*lines_rem_p)--;
/* 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)
#endif
/* what info of the processes is shown */
- printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width,
+ printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width,
" PID PPID USER STAT VSZ %MEM"
IF_FEATURE_TOP_SMP_PROCESS(" CPU")
IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
@@ -772,7 +772,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p)
snprintf(linebuf, sizeof(linebuf),
"Mem total:%s anon:%s map:%s free:%s",
S(total), S(anon), S(map), S(mfree));
- printf(OPT_BATCH_MODE ? "%.*s\n" : "\e[H\e[J%.*s\n", scr_width, linebuf);
+ printf(OPT_BATCH_MODE ? "%.*s\n" : "\033[H\033[J%.*s\n", scr_width, linebuf);
snprintf(linebuf, sizeof(linebuf),
" slab:%s buf:%s cache:%s dirty:%s write:%s",
diff --git a/procps/watch.c b/procps/watch.c
index 126945c..a1cde9e 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -52,7 +52,8 @@ int watch_main(int argc UNUSED_PARAM, char **argv)
width = (unsigned)-1; // make sure first time new_width != width
header = NULL;
while (1) {
- printf("\033[H\033[J");
+ /* home; clear to the end of screen */
+ printf("\033[H""\033[J");
if (!(opt & 0x2)) { // no -t
const unsigned time_len = sizeof("1234-67-90 23:56:89");
time_t t;