diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2022-12-05 04:34:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-05 04:34:19 -0500 |
commit | 1920f4b2e11799bdef4c063a24e551ed5f2dc331 (patch) | |
tree | 904ae83136b7bdbe8413a36ec77d8ff049ea4dac | |
parent | ac5e2ce4a28ccc9689f8ba43fb7dfc3c819a3366 (diff) |
other: add a redraw event on resize (#926)
-rw-r--r-- | src/bin/main.rs | 3 | ||||
-rw-r--r-- | src/lib.rs | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/main.rs b/src/bin/main.rs index f5e2371f..bbad61b3 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -157,6 +157,9 @@ fn main() -> Result<()> { // TODO: Would be good to instead use a mix of is_terminated check + recv. Probably use a termination event instead. if let Ok(recv) = receiver.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) { match recv { + BottomEvent::Resize => { + try_drawing(&mut terminal, &mut app, &mut painter)?; + } BottomEvent::KeyInput(event) => { if handle_key_event_or_break(event, &mut app, &collection_thread_ctrl_sender) { break; @@ -71,6 +71,7 @@ pub type Pid = libc::pid_t; #[derive(Debug)] pub enum BottomEvent { + Resize, KeyInput(KeyEvent), MouseInput(MouseEvent), PasteEvent(String), @@ -431,6 +432,14 @@ pub fn create_input_thread( if let Ok(event) = read() { // FIXME: Handle all other event cases. match event { + // TODO: Might want to debounce this in the future, or take into account the actual resize + // values. Maybe we want to keep the current implementation in case the resize event might + // not fire... not sure. + Event::Resize(_, _) => { + if sender.send(BottomEvent::Resize).is_err() { + break; + } + } Event::Paste(paste) => { if sender.send(BottomEvent::PasteEvent(paste)).is_err() { break; |