mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Rename function to event_loop to key_capture
This commit is contained in:
parent
4ca68100b4
commit
fa33e1515e
2 changed files with 13 additions and 5 deletions
|
@ -1301,9 +1301,9 @@ impl TTApp {
|
|||
}
|
||||
},
|
||||
Key::Char('e') => {
|
||||
events.pause_event_loop(terminal);
|
||||
events.pause_key_capture(terminal);
|
||||
let r = self.task_edit();
|
||||
events.resume_event_loop(terminal);
|
||||
events.resume_key_capture(terminal);
|
||||
match r {
|
||||
Ok(_) => self.update()?,
|
||||
Err(e) => {
|
||||
|
|
14
src/util.rs
14
src/util.rs
|
@ -146,19 +146,27 @@ impl Events {
|
|||
*self.pause_ticker.lock().unwrap() = false;
|
||||
}
|
||||
|
||||
pub fn pause_event_loop(&self, terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) {
|
||||
pub fn pause_event_loop(&self) {
|
||||
*self.pause_stdin.lock().unwrap() = true;
|
||||
}
|
||||
|
||||
pub fn resume_event_loop(&self) {
|
||||
*self.pause_stdin.lock().unwrap() = false;
|
||||
}
|
||||
|
||||
pub fn pause_key_capture(&self, terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) {
|
||||
self.pause_event_loop();
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
disable_raw_mode().unwrap();
|
||||
execute!(io::stdout(), LeaveAlternateScreen, DisableMouseCapture).unwrap();
|
||||
terminal.show_cursor().unwrap();
|
||||
}
|
||||
|
||||
pub fn resume_event_loop(&self, terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) {
|
||||
pub fn resume_key_capture(&self, terminal: &mut Terminal<CrosstermBackend<io::Stdout>>) {
|
||||
enable_raw_mode().unwrap();
|
||||
execute!(io::stdout(), EnterAlternateScreen, EnableMouseCapture).unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
*self.pause_stdin.lock().unwrap() = false;
|
||||
self.resume_event_loop();
|
||||
terminal.resize(terminal.size().unwrap()).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue