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>
This commit is contained in:
parent
26e2c1db0d
commit
d9a3e89f50
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
16
editors/vi.c
16
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[]
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user