Matches traditional top.
---
toys/posix/ps.c | 13 +++++++++++--
1 file 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));
--
2.20.1.791.gb4d0f1c61a-goog
From 1558d2a4864f6506914f6585ad6975d152d8b33b Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Wed, 13 Feb 2019 14:46:54 -0800
Subject: [PATCH] top: hide the cursor in interactive mode.
Matches traditional top.
---
toys/posix/ps.c | 13 +++++++++++--
1 file 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));
--
2.20.1.791.gb4d0f1c61a-goog
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net