diff options
author | Elliott Hughes <enh@google.com> | 2019-02-13 14:46:54 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-02-13 20:17:36 -0600 |
commit | 8e7b298b17e53ac0f35f5e425f72836f729a10d6 (patch) | |
tree | 7af679838232f3657fc4cea055be16e1da08e865 | |
parent | 6b018bc0ff306766c6e9dfc0ac737cfb904b22e1 (diff) | |
download | toybox-8e7b298b17e53ac0f35f5e425f72836f729a10d6.tar.gz |
top: hide the cursor in interactive mode.
Matches traditional top.
-rw-r--r-- | toys/posix/ps.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c index eff980f3..ce13d4f6 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1431,6 +1431,11 @@ static int header_line(int line, int rev) return line-1; } +static void top_cursor_cleanup(void) +{ + tty_esc("?25h"); +} + static void top_common( int (*filter)(long long *oslot, long long *nslot, int milis)) { @@ -1447,8 +1452,12 @@ static void top_common( int i, lines, topoff = 0, done = 0; char stdout_buf[BUFSIZ]; - // Avoid flicker in interactive mode. - if (!FLAG(b)) setbuf(stdout, stdout_buf); + // Avoid flicker and hide the cursor in interactive mode. + if (!FLAG(b)) { + setbuf(stdout, stdout_buf); + tty_esc("?25l"); + sigatexit(top_cursor_cleanup); + } toys.signal = SIGWINCH; TT.bits = get_headers(TT.fields, toybuf, sizeof(toybuf)); |