From 33f50f5ff5930815e0a6a6e4af55905df2ec6bdf Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 27 Jan 2016 21:19:12 -0600 Subject: Don't resort or recalculate headers for cursor up/down, do PGUP PGDN, and down move way down past end of list. --- toys/posix/ps.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 3a5c9410..42dd193d 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1185,6 +1185,7 @@ static void top_common( memset(stats, 0, sizeof(stats)); do { struct dirtree *dt; + int recalc = 1; plold = plist+(tock++&1); plnew = plist+(tock&1); @@ -1243,10 +1244,12 @@ static void top_common( for (;;) { char was, is; - qsort(mix.tb, mix.count, sizeof(struct carveup *), (void *)ksort); - lines = TT.height; - if (!(toys.optflags&FLAG_b)) printf("\033[H\033[J"); - if (!(toys.optflags&FLAG_q)) { + if (recalc) { + qsort(mix.tb, mix.count, sizeof(struct carveup *), (void *)ksort); + lines = TT.height; + if (!(toys.optflags&FLAG_b)) printf("\033[H\033[J"); + } + if (recalc && !(toys.optflags&FLAG_q)) { if (*toys.which->name == 't') { struct strawberry alluc; long long ll, up = 0; @@ -1335,6 +1338,8 @@ static void top_common( if (!(toys.optflags&FLAG_b)) terminal_probesize(&TT.width, &TT.height); } + if (!recalc) printf("\033[%dH\033[J", 1+TT.height-lines); + recalc = 1; for (i = 0; imix.count) topoff = mix.count; + } } continue; } @@ -1380,6 +1393,7 @@ static void top_common( for (i=0; icount; i++) free(plold->tb[i]); free(plold->tb); } while (!done); + if (!(toys.optflags&FLAG_b)) tty_reset(); } @@ -1447,7 +1461,7 @@ void iotop_main(void) top_common(iotop_filter); } -// pkill's plumbing wrap's pgrep's and thus mostly takes place in pgrep's flag +// pkill's plumbing wraps pgrep's and thus mostly takes place in pgrep's flag // context, so force pgrep's flags on even when building pkill standalone. // (All the pgrep/pkill functions drop out when building ps standalone.) #define FORCE_FLAGS -- cgit v1.2.3