diff options
author | Mark Wong <markwkm@gmail.com> | 2021-01-18 08:05:40 -0800 |
---|---|---|
committer | Mark Wong <markwkm@gmail.com> | 2021-01-18 11:01:02 -0800 |
commit | 84e7bcbe1f4c9e4b06de1cd61559c1f5d836cc69 (patch) | |
tree | 8525b7728468c2ed7db808691fa60d853b4ebe54 /src/pg_top.rs | |
parent | b10ae5fea86ba37520464e09e1e71938fa3ebe0d (diff) |
Clear lines after updating
The amount of data written to a line may be less than what was
previously displayed, so clear the rest of the line after updating it.
Similarly, clear the rest of the screen after the last line is updated.
This also requires the refreshing of the entire screen to be in a
particular order.
Diffstat (limited to 'src/pg_top.rs')
-rw-r--r-- | src/pg_top.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pg_top.rs b/src/pg_top.rs index 8c949e4..e45f492 100644 --- a/src/pg_top.rs +++ b/src/pg_top.rs @@ -92,8 +92,10 @@ fn main() { display::loadavg(terminal_size.0 as usize); processes = display::process_summary(processes, terminal_size.0 as usize); - display::processes(processes, terminal_size.0 as usize); pg_top = display::stat_cpu(pg_top, terminal_size.0 as usize); + display::processes(processes, terminal_size.0 as usize); + write!(stdout, "{}", termion::clear::AfterCursor,).unwrap(); + stdout.flush().unwrap(); count = count - 1; if count == 0 { |