Skip to content

Commit

Permalink
Suppress flicker
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed Feb 12, 2020
1 parent 6d2e33a commit 9ea7690
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased](https://github.com/dalance/procs/compare/v0.9.6...Unreleased) - ReleaseDate

* [Added] widths of columns are adjusted over iteration in watch mode
* [Fixed] suppress flicker in watch mode

## [v0.9.6](https://github.com/dalance/procs/compare/v0.9.5...v0.9.6) - 2020-02-05

Expand Down
11 changes: 10 additions & 1 deletion src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ impl Watcher {
Local::now().format("%Y/%m/%d %H:%M:%S"),
)
};
let _ = term_info.term.clear_screen();
let _ = term_info.term.write_line(&format!(
"{}\n",
console::style(header).white().bold().underlined()
Expand All @@ -100,6 +99,8 @@ impl Watcher {
let mut sort_offset = 0;
let mut sort_order = None;
let mut min_widths = HashMap::new();
let mut prev_term_width = 0;
let mut prev_term_height = 0;
'outer: loop {
let mut view = View::new(opt, config);

Expand All @@ -116,6 +117,11 @@ impl Watcher {
min_widths.insert(i, c.column.get_width());
}

let resized = prev_term_width != view.term_info.width
|| prev_term_height != view.term_info.height;
if resized {
let _ = term_info.term.clear_screen();
}
Watcher::display_header(&view.term_info, opt, interval);

view.display(opt, config);
Expand Down Expand Up @@ -148,6 +154,9 @@ impl Watcher {
_ => (),
}
}

prev_term_width = view.term_info.width;
prev_term_height = view.term_info.height;
}
Ok(())
}
Expand Down

0 comments on commit 9ea7690

Please sign in to comment.