mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Merge pull request #114 from kdheepak/change-timeout
Change timeout to be between 10ms and 25ms
This commit is contained in:
commit
4defc10ffc
1 changed files with 6 additions and 2 deletions
|
@ -79,14 +79,18 @@ impl Events {
|
|||
thread::spawn(move || {
|
||||
let mut last_tick = Instant::now();
|
||||
loop {
|
||||
|
||||
if pause_stdin.load(Ordering::SeqCst) {
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
thread::park();
|
||||
continue;
|
||||
}
|
||||
|
||||
// poll for tick rate duration, if no event, sent tick event.
|
||||
if event::poll(Duration::from_millis(10)).unwrap() {
|
||||
let timeout = Duration::from_millis(25)
|
||||
.checked_sub(last_tick.elapsed())
|
||||
.unwrap_or_else(|| Duration::from_millis(10));
|
||||
|
||||
if event::poll(timeout).unwrap() {
|
||||
if let event::Event::Key(key) = event::read().unwrap() {
|
||||
let key = match key.code {
|
||||
Backspace => Key::Backspace,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue