mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-25 14:05:41 -05:00
Adding dynamic_title property to configuration (#819)
This logic is applied in Term's ansi::Handler implementation to avoid unnecessary allocations.
This commit is contained in:
parent
4fb2109497
commit
ed91eb365e
4 changed files with 21 additions and 1 deletions
|
@ -204,6 +204,8 @@ mouse:
|
||||||
selection:
|
selection:
|
||||||
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
|
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
|
||||||
|
|
||||||
|
dynamic_title: true
|
||||||
|
|
||||||
hide_cursor_when_typing: false
|
hide_cursor_when_typing: false
|
||||||
|
|
||||||
# Style of the cursor
|
# Style of the cursor
|
||||||
|
|
|
@ -185,6 +185,8 @@ mouse:
|
||||||
selection:
|
selection:
|
||||||
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
|
semantic_escape_chars: ",│`|:\"' ()[]{}<>"
|
||||||
|
|
||||||
|
dynamic_title: true
|
||||||
|
|
||||||
hide_cursor_when_typing: false
|
hide_cursor_when_typing: false
|
||||||
|
|
||||||
# Style of the cursor
|
# Style of the cursor
|
||||||
|
|
|
@ -307,6 +307,10 @@ pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
visual_bell: VisualBellConfig,
|
visual_bell: VisualBellConfig,
|
||||||
|
|
||||||
|
/// Use dynamic title
|
||||||
|
#[serde(default="true_bool")]
|
||||||
|
dynamic_title: bool,
|
||||||
|
|
||||||
/// Hide cursor when typing
|
/// Hide cursor when typing
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
hide_cursor_when_typing: bool,
|
hide_cursor_when_typing: bool,
|
||||||
|
@ -371,6 +375,7 @@ impl Default for Config {
|
||||||
env: Default::default(),
|
env: Default::default(),
|
||||||
hide_cursor_when_typing: Default::default(),
|
hide_cursor_when_typing: Default::default(),
|
||||||
cursor_style: Default::default(),
|
cursor_style: Default::default(),
|
||||||
|
dynamic_title: Default::default(),
|
||||||
live_config_reload: true,
|
live_config_reload: true,
|
||||||
window: Default::default(),
|
window: Default::default(),
|
||||||
}
|
}
|
||||||
|
@ -1240,6 +1245,11 @@ impl Config {
|
||||||
self.live_config_reload
|
self.live_config_reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn dynamic_title(&self) -> bool {
|
||||||
|
self.dynamic_title
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load_from<P: Into<PathBuf>>(path: P) -> Result<Config> {
|
pub fn load_from<P: Into<PathBuf>>(path: P) -> Result<Config> {
|
||||||
let path = path.into();
|
let path = path.into();
|
||||||
let raw = Config::read_file(path.as_path())?;
|
let raw = Config::read_file(path.as_path())?;
|
||||||
|
|
|
@ -703,6 +703,8 @@ pub struct Term {
|
||||||
|
|
||||||
/// Default style for resetting the cursor
|
/// Default style for resetting the cursor
|
||||||
default_cursor_style: CursorStyle,
|
default_cursor_style: CursorStyle,
|
||||||
|
|
||||||
|
dynamic_title: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Terminal size info
|
/// Terminal size info
|
||||||
|
@ -806,6 +808,7 @@ impl Term {
|
||||||
semantic_escape_chars: config.selection().semantic_escape_chars.clone(),
|
semantic_escape_chars: config.selection().semantic_escape_chars.clone(),
|
||||||
cursor_style: None,
|
cursor_style: None,
|
||||||
default_cursor_style: config.cursor_style(),
|
default_cursor_style: config.cursor_style(),
|
||||||
|
dynamic_title: config.dynamic_title(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,6 +834,7 @@ impl Term {
|
||||||
}
|
}
|
||||||
self.visual_bell.update_config(config);
|
self.visual_bell.update_config(config);
|
||||||
self.default_cursor_style = config.cursor_style();
|
self.default_cursor_style = config.cursor_style();
|
||||||
|
self.dynamic_title = config.dynamic_title();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1159,7 +1163,9 @@ impl ansi::Handler for Term {
|
||||||
/// Set the window title
|
/// Set the window title
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_title(&mut self, title: &str) {
|
fn set_title(&mut self, title: &str) {
|
||||||
self.next_title = Some(title.to_owned());
|
if self.dynamic_title {
|
||||||
|
self.next_title = Some(title.to_owned());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A character to be displayed
|
/// A character to be displayed
|
||||||
|
|
Loading…
Reference in a new issue