Skip to content

Commit

Permalink
event polling added
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacperacy committed Mar 25, 2024
1 parent f8ce4eb commit df4ab16
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
};

use crossterm::{
event::{read, Event::Key, KeyCode, KeyEvent, KeyModifiers},
event::{poll, read, Event::Key, KeyCode, KeyEvent, KeyModifiers},
terminal::{disable_raw_mode, enable_raw_mode, DisableLineWrap, EnableLineWrap},
};

Expand Down Expand Up @@ -150,6 +150,12 @@ impl Editor {
}

fn process_keypress(&mut self) -> bool {
if let Ok(event) = poll(Duration::from_millis(100)) {
if !event {
return true;
}
}

let c = self.read_key();

if KeyModifiers::CONTROL == c.modifiers {
Expand Down

0 comments on commit df4ab16

Please sign in to comment.