diff options
author | Marek Polacek | 2010-10-28 21:34:56 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-10-28 21:34:56 +0200 |
commit | 7b18107384d950358e146d42bf02b391fab5ffd6 (patch) | |
tree | 9994e2bcaa038c3128ed8b3bca99486e22f660fb /miscutils/conspy.c | |
parent | 02788ac7e2a44eee889aa1005e89076f928e964a (diff) | |
download | busybox-7b18107384d950358e146d42bf02b391fab5ffd6.zip busybox-7b18107384d950358e146d42bf02b391fab5ffd6.tar.gz |
*: 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>
Diffstat (limited to 'miscutils/conspy.c')
-rw-r--r-- | miscutils/conspy.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 01928b3..040fa86 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c @@ -43,6 +43,9 @@ #include "libbb.h" #include <sys/kd.h> + +#define ESC "\033" + struct screen_info { unsigned char lines, cols, cursor_x, cursor_y; }; @@ -70,7 +73,7 @@ struct globals { unsigned col; unsigned line; smallint curoff; // unknown:0 cursor on:-1 cursor off:1 - char attrbuf[sizeof("\033[0;1;5;30;40m")]; + char attrbuf[sizeof(ESC"[0;1;5;30;40m")]; // remote console struct screen_info remote; // saved local tty terminfo @@ -101,7 +104,7 @@ enum { static void clrscr(void) { // Home, clear till end of screen - fputs("\033[1;1H" "\033[J", stdout); + fputs(ESC"[1;1H" ESC"[J", stdout); G.col = G.line = 0; } @@ -109,7 +112,7 @@ static void set_cursor(int state) { if (G.curoff != state) { G.curoff = state; - fputs("\033[?25", stdout); + fputs(ESC"[?25", stdout); bb_putchar("h?l"[1 + state]); } } @@ -119,7 +122,7 @@ static void gotoxy(int col, int line) if (G.col != col || G.line != line) { G.col = col; G.line = line; - printf("\033[%u;%uH", line + 1, col + 1); + printf(ESC"[%u;%uH", line + 1, col + 1); } } @@ -132,7 +135,7 @@ static void cleanup(int code) } // Reset attributes if (!BW) - fputs("\033[0m", stdout); + fputs(ESC"[0m", stdout); bb_putchar('\n'); if (code > 1) kill_myself_with_sig(code); |