*: use _exit() in sighandlers; showkey: do not use exit-thru-sighandler
While at it, make ESC sequences more readable; and removed check for isatty(stdin) in reset. Code shrink: text data bss dec hex filename 884771 936 17216 902923 dc70b busybox_old 884723 936 17216 902875 dc6db busybox_unstripped Signed-off-by: Marek Polacek <mmpolacek@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
committed by
Denys Vlasenko
parent
02788ac7e2
commit
7b18107384
@@ -28,13 +28,15 @@
|
||||
#include "xregex.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define ESC "\033"
|
||||
/* The escape codes for highlighted and normal text */
|
||||
#define HIGHLIGHT "\033[7m"
|
||||
#define NORMAL "\033[0m"
|
||||
#define HIGHLIGHT ESC"[7m"
|
||||
#define NORMAL ESC"[0m"
|
||||
/* The escape code to home and clear to the end of screen */
|
||||
#define CLEAR "\033[H\033[J"
|
||||
#define CLEAR ESC"[H\033[J"
|
||||
/* The escape code to clear to the end of line */
|
||||
#define CLEAR_2_EOL "\033[K"
|
||||
#define CLEAR_2_EOL ESC"[K"
|
||||
|
||||
enum {
|
||||
/* Absolute max of lines eaten */
|
||||
@@ -165,12 +167,12 @@ static void set_tty_cooked(void)
|
||||
top-left corner of the console */
|
||||
static void move_cursor(int line, int row)
|
||||
{
|
||||
printf("\033[%u;%uH", line, row);
|
||||
printf(ESC"[%u;%uH", line, row);
|
||||
}
|
||||
|
||||
static void clear_line(void)
|
||||
{
|
||||
printf("\033[%u;0H" CLEAR_2_EOL, max_displayed_line + 2);
|
||||
printf(ESC"[%u;0H" CLEAR_2_EOL, max_displayed_line + 2);
|
||||
}
|
||||
|
||||
static void print_hilite(const char *str)
|
||||
|
Reference in New Issue
Block a user