From 8e7b298b17e53ac0f35f5e425f72836f729a10d6 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 13 Feb 2019 14:46:54 -0800 Subject: top: hide the cursor in interactive mode. Matches traditional top. --- toys/posix/ps.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'toys/posix/ps.c') 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)); -- cgit v1.2.3