Skip to content

Commit

Permalink
Auto-repaint when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ewpratten committed Apr 12, 2024
1 parent 3b774a4 commit f3cbc24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ pub struct Args {
#[arg(short, long, default_value = "dark")]
pub theme: Themes,

/// Disable line stripes
#[arg(long)]
pub no_stripes: bool,

/// Enable verbose logging
#[arg(short, long)]
pub verbose: bool,
Expand Down
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod parse;

use std::{
io::BufRead,
sync::{Arc, Mutex},
sync::{Arc, Mutex}, time::Duration,
};

use clap::Parser;
Expand Down Expand Up @@ -151,7 +151,7 @@ pub fn main() {
let mut table = TableBuilder::new(ui)
.cell_layout(Layout::default().with_main_wrap(false))
.vscroll(true)
.striped(true)
.striped(!args.no_stripes)
.stick_to_bottom(true)
.drag_to_scroll(false)
.max_scroll_height(window_height)
Expand Down Expand Up @@ -195,6 +195,11 @@ pub fn main() {
});
});
});

// End each frame by scheduling a repaint in the future to keep data fresh-ish
if is_data_live.load(std::sync::atomic::Ordering::SeqCst) {
ctx.request_repaint_after(Duration::from_millis(500));
}
})
.unwrap();
}

0 comments on commit f3cbc24

Please sign in to comment.