diff options
author | David Hewitt <1939362+davidhewitt@users.noreply.github.com> | 2019-12-14 21:32:24 +0000 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2019-12-14 22:32:24 +0100 |
commit | 08a122574880d299181c59bec186c0f9e8bef77c (patch) | |
tree | c9dc6350869f89f08b35ca1e3a40a983bb1b53f1 /alacritty_terminal/src/event_loop.rs | |
parent | cb99fd4e4c16e8fe5c36e8be6062658842794ac3 (diff) | |
download | alacritty-08a122574880d299181c59bec186c0f9e8bef77c.tar.gz alacritty-08a122574880d299181c59bec186c0f9e8bef77c.zip |
Send PTY resize messages through event loop
This allows us to clean up the Arcs on windows, as well as tidy up
the code on unix a little too.
Fixes #3086.
Diffstat (limited to 'alacritty_terminal/src/event_loop.rs')
-rw-r--r-- | alacritty_terminal/src/event_loop.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/alacritty_terminal/src/event_loop.rs b/alacritty_terminal/src/event_loop.rs index 00f77c9f..2d55815a 100644 --- a/alacritty_terminal/src/event_loop.rs +++ b/alacritty_terminal/src/event_loop.rs @@ -16,7 +16,7 @@ use crate::ansi; use crate::config::Config; use crate::event::{self, Event, EventListener}; use crate::sync::FairMutex; -use crate::term::Term; +use crate::term::{SizeInfo, Term}; use crate::tty; use crate::util::thread; @@ -31,6 +31,9 @@ pub enum Msg { /// Indicates that the `EventLoop` should shut down, as Alacritty is shutting down Shutdown, + + /// Instruction to resize the pty + Resize(SizeInfo), } /// The main event!.. loop. @@ -76,9 +79,14 @@ impl event::Notify for Notifier { if bytes.len() == 0 { return; } - if self.0.send(Msg::Input(bytes)).is_err() { - panic!("expected send event loop msg"); - } + + self.0.send(Msg::Input(bytes)).expect("send event loop msg"); + } +} + +impl event::OnResize for Notifier { + fn on_resize(&mut self, size: &SizeInfo) { + self.0.send(Msg::Resize(*size)).expect("expected send event loop msg"); } } @@ -141,7 +149,7 @@ impl Writing { impl<T, U> EventLoop<T, U> where - T: tty::EventedPty + Send + 'static, + T: tty::EventedPty + event::OnResize + Send + 'static, U: EventListener + Send + 'static, { /// Create a new event loop @@ -171,11 +179,12 @@ where // Drain the channel // // Returns `false` when a shutdown message was received. - fn drain_recv_channel(&self, state: &mut State) -> bool { + fn drain_recv_channel(&mut self, state: &mut State) -> bool { while let Ok(msg) = self.rx.try_recv() { match msg { Msg::Input(input) => state.write_list.push_back(input), Msg::Shutdown => return false, + Msg::Resize(size) => self.pty.on_resize(&size), } } |