From 401c2aab964b60e8c3b072e5098ba8e366d04944 Mon Sep 17 00:00:00 2001 From: Dustin Date: Mon, 14 Oct 2019 13:50:58 -0400 Subject: Add support for title stack escape sequences This commit adds the concept of a "title stack" to the terminal. Some programs (e.g. vim) send control sequences `CSI 22 ; 0` (push title) and `CSI 23 ; 0` (pop title). The title stack is just a history of previous titles. Applications can push the current title onto the stack, and pop it back off (setting the window title in the process). Fixes #2840. --- alacritty/src/cli.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'alacritty/src/cli.rs') diff --git a/alacritty/src/cli.rs b/alacritty/src/cli.rs index 99387a61..b0e3cc94 100644 --- a/alacritty/src/cli.rs +++ b/alacritty/src/cli.rs @@ -266,9 +266,12 @@ impl Options { config.window.dimensions = self.dimensions.unwrap_or(config.window.dimensions); config.window.position = self.position.or(config.window.position); - config.window.title = self.title.or(config.window.title); config.window.embed = self.embed.and_then(|embed| embed.parse().ok()); + if let Some(title) = self.title { + config.window.title = title.clone(); + } + if let Some(class) = self.class { let parts: Vec<_> = class.split(',').collect(); config.window.class.instance = parts[0].into(); @@ -277,7 +280,7 @@ impl Options { } } - config.set_dynamic_title(config.dynamic_title() && config.window.title.is_none()); + config.set_dynamic_title(config.dynamic_title() && config.window.title == DEFAULT_NAME); config.debug.print_events = self.print_events || config.debug.print_events; config.debug.log_level = max(config.debug.log_level, self.log_level); @@ -298,7 +301,8 @@ mod test { #[test] fn dynamic_title_ignoring_options_by_default() { - let config = Config::default(); + let mut config = Config::default(); + config.window.title = "Alacritty".to_string(); let old_dynamic_title = config.dynamic_title(); let config = Options::default().into_config(config); @@ -321,7 +325,7 @@ mod test { fn dynamic_title_overridden_by_config() { let mut config = Config::default(); - config.window.title = Some("foo".to_owned()); + config.window.title = "foo".to_owned(); let config = Options::default().into_config(config); assert!(!config.dynamic_title()); -- cgit