From 4cb5566a9c2d68006ffa97e2f8082ae3ef6c8de4 Mon Sep 17 00:00:00 2001 From: Valentin Ignatev Date: Thu, 10 Oct 2019 00:37:48 +0300 Subject: Add --hold CLI flag This implements --hold flag which keeps Alacritty open after its child process exits. Fixes #1165. --- alacritty_terminal/src/config/mod.rs | 4 ++++ alacritty_terminal/src/event_loop.rs | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'alacritty_terminal/src') diff --git a/alacritty_terminal/src/config/mod.rs b/alacritty_terminal/src/config/mod.rs index f810b519..26432415 100644 --- a/alacritty_terminal/src/config/mod.rs +++ b/alacritty_terminal/src/config/mod.rs @@ -130,6 +130,10 @@ pub struct Config { #[serde(flatten)] pub ui_config: T, + /// Remain open after child process exits + #[serde(skip)] + pub hold: bool, + // TODO: DEPRECATED #[serde(default, deserialize_with = "failure_default")] pub render_timer: Option, diff --git a/alacritty_terminal/src/event_loop.rs b/alacritty_terminal/src/event_loop.rs index ed78d79e..3e762840 100644 --- a/alacritty_terminal/src/event_loop.rs +++ b/alacritty_terminal/src/event_loop.rs @@ -13,6 +13,7 @@ use mio::{self, Events, PollOpt, Ready}; use mio_extras::channel::{self, Receiver, Sender}; use crate::ansi; +use crate::config::Config; use crate::event::{self, Event, EventListener}; use crate::sync::FairMutex; use crate::term::Term; @@ -43,6 +44,7 @@ pub struct EventLoop { tx: Sender, terminal: Arc>>, event_proxy: U, + hold: bool, ref_test: bool, } @@ -143,11 +145,11 @@ where U: EventListener + Send + 'static, { /// Create a new event loop - pub fn new( + pub fn new( terminal: Arc>>, event_proxy: U, pty: T, - ref_test: bool, + config: &Config, ) -> EventLoop { let (tx, rx) = channel::channel(); EventLoop { @@ -157,7 +159,8 @@ where rx, terminal, event_proxy, - ref_test, + hold: config.hold, + ref_test: config.debug.ref_test, } } @@ -327,7 +330,9 @@ where #[cfg(unix)] token if token == self.pty.child_event_token() => { if let Some(tty::ChildEvent::Exited) = self.pty.next_child_event() { - self.terminal.lock().exit(); + if !self.hold { + self.terminal.lock().exit(); + } self.event_proxy.send_event(Event::Wakeup); break 'event_loop; } -- cgit v1.2.3-54-g00ecf