From c49a7e88f64d1421474d492cc6f51bfd30e1e4d1 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Fri, 16 Feb 2018 17:54:32 -0800 Subject: Make number of scrollback lines configurable --- src/config.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 40c550b0..b0523c13 100644 --- a/src/config.rs +++ b/src/config.rs @@ -396,6 +396,14 @@ pub struct Config { /// Number of spaces in one tab #[serde(default="default_tabspaces", deserialize_with = "deserialize_tabspaces")] tabspaces: usize, + + /// How much scrolling history to keep + #[serde(default="default_scroll_history")] + scroll_history: u32, +} + +fn default_scroll_history() -> u32 { + 10_000 } fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result, D::Error> @@ -1244,6 +1252,10 @@ impl Config { .map(|path| path.into()) } + pub fn scroll_history(&self) -> usize { + self.scroll_history as _ + } + pub fn write_defaults() -> io::Result> { let path = ::xdg::BaseDirectories::with_prefix("alacritty") .map_err(|err| io::Error::new(io::ErrorKind::NotFound, ::std::error::Error::description(&err))) -- cgit From dd60ea563d1b3022e387d96e2b6cf8bbb682b947 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 11:01:42 +0100 Subject: Add `failure_default` deserializer to `scroll_history` --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index b0523c13..2c2cfe46 100644 --- a/src/config.rs +++ b/src/config.rs @@ -398,7 +398,7 @@ pub struct Config { tabspaces: usize, /// How much scrolling history to keep - #[serde(default="default_scroll_history")] + #[serde(default="default_scroll_history", deserialize_with="failure_default")] scroll_history: u32, } -- cgit From 04086186a00d50f22a7e1914d89a8dd1beb695cc Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 17:57:24 +0100 Subject: Provide correct default for scroll_history When implementing fallback to the default value with an u32 you will get 0 as the default value. However the default scrollback value is 10_000. A custom deserializer has been implemented which automatically falls back to the correct default value. --- src/config.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 2c2cfe46..d49dd3b4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -398,7 +398,7 @@ pub struct Config { tabspaces: usize, /// How much scrolling history to keep - #[serde(default="default_scroll_history", deserialize_with="failure_default")] + #[serde(default="default_scroll_history", deserialize_with="deserialize_scroll_history")] scroll_history: u32, } @@ -406,6 +406,18 @@ fn default_scroll_history() -> u32 { 10_000 } +fn deserialize_scroll_history<'a, D>(deserializer: D) -> ::std::result::Result + where D: de::Deserializer<'a> +{ + match u32::deserialize(deserializer) { + Ok(lines) => Ok(lines), + Err(err) => { + eprintln!("problem with config: {}; Using default value", err); + Ok(default_scroll_history()) + }, + } +} + fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result, D::Error> where D: de::Deserializer<'a>, T: Deserialize<'a> -- cgit From dab0eca4a7bbb94e728465ca0248fbbbf32e6674 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 16:06:39 +0100 Subject: Make normal scrolling line amount configurable It is now possible to configure the amount of lines the viewport should scroll when using the normal scrolling mode. This fixes #1160. --- src/config.rs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index d49dd3b4..6502cf74 100644 --- a/src/config.rs +++ b/src/config.rs @@ -85,17 +85,26 @@ pub struct Mouse { /// up/down arrows sent when scrolling in alt screen buffer #[serde(deserialize_with = "deserialize_faux_scrollback_lines")] #[serde(default="default_faux_scrollback_lines")] - pub faux_scrollback_lines: usize, + pub faux_scrollback_lines: u8, + + /// Number of lines scrolled in normal buffer with scrollback + #[serde(deserialize_with = "deserialize_normal_scrolling_lines")] + #[serde(default="default_normal_scrolling_lines")] + pub normal_scrolling_lines: u8, } -fn default_faux_scrollback_lines() -> usize { +fn default_faux_scrollback_lines() -> u8 { 1 } -fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::Result +fn default_normal_scrolling_lines() -> u8 { + 3 +} + +fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::Result where D: de::Deserializer<'a> { - match usize::deserialize(deserializer) { + match u8::deserialize(deserializer) { Ok(lines) => Ok(lines), Err(err) => { eprintln!("problem with config: {}; Using default value", err); @@ -104,6 +113,18 @@ fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::R } } +fn deserialize_normal_scrolling_lines<'a, D>(deserializer: D) -> ::std::result::Result + where D: de::Deserializer<'a> +{ + match u8::deserialize(deserializer) { + Ok(lines) => Ok(lines), + Err(err) => { + eprintln!("problem with config: {}; Using default value", err); + Ok(default_normal_scrolling_lines()) + }, + } +} + impl Default for Mouse { fn default() -> Mouse { Mouse { @@ -113,7 +134,8 @@ impl Default for Mouse { triple_click: ClickHandler { threshold: Duration::from_millis(300), }, - faux_scrollback_lines: 1, + faux_scrollback_lines: default_faux_scrollback_lines(), + normal_scrolling_lines: default_normal_scrolling_lines(), } } } -- cgit From d3f64072f3fe4d31f7a60eb0cb17a98096617b4b Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 19:45:40 +0100 Subject: Merge branch #1095 Because there was some overlap with branch #1095, these two PRs have been added together and the config has been restructured to make use of a `scrolling` section. The default faux scrolling amount has also been changed to `3` because this simplifies the code and falls in line with what most other terminal emulators do. There should be no additional test failures due to this. --- src/config.rs | 127 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 74 insertions(+), 53 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 6502cf74..8e531a9c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -82,47 +82,9 @@ pub struct Mouse { #[serde(default, deserialize_with = "failure_default")] pub triple_click: ClickHandler, - /// up/down arrows sent when scrolling in alt screen buffer - #[serde(deserialize_with = "deserialize_faux_scrollback_lines")] - #[serde(default="default_faux_scrollback_lines")] - pub faux_scrollback_lines: u8, - - /// Number of lines scrolled in normal buffer with scrollback - #[serde(deserialize_with = "deserialize_normal_scrolling_lines")] - #[serde(default="default_normal_scrolling_lines")] - pub normal_scrolling_lines: u8, -} - -fn default_faux_scrollback_lines() -> u8 { - 1 -} - -fn default_normal_scrolling_lines() -> u8 { - 3 -} - -fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::Result - where D: de::Deserializer<'a> -{ - match u8::deserialize(deserializer) { - Ok(lines) => Ok(lines), - Err(err) => { - eprintln!("problem with config: {}; Using default value", err); - Ok(default_faux_scrollback_lines()) - }, - } -} - -fn deserialize_normal_scrolling_lines<'a, D>(deserializer: D) -> ::std::result::Result - where D: de::Deserializer<'a> -{ - match u8::deserialize(deserializer) { - Ok(lines) => Ok(lines), - Err(err) => { - eprintln!("problem with config: {}; Using default value", err); - Ok(default_normal_scrolling_lines()) - }, - } + // TODO: DEPRECATED + #[serde(default)] + pub faux_scrollback_lines: Option, } impl Default for Mouse { @@ -134,8 +96,7 @@ impl Default for Mouse { triple_click: ClickHandler { threshold: Duration::from_millis(300), }, - faux_scrollback_lines: default_faux_scrollback_lines(), - normal_scrolling_lines: default_normal_scrolling_lines(), + faux_scrollback_lines: None, } } } @@ -420,12 +381,8 @@ pub struct Config { tabspaces: usize, /// How much scrolling history to keep - #[serde(default="default_scroll_history", deserialize_with="deserialize_scroll_history")] - scroll_history: u32, -} - -fn default_scroll_history() -> u32 { - 10_000 + #[serde(default, deserialize_with="failure_default")] + scrolling: Scrolling, } fn deserialize_scroll_history<'a, D>(deserializer: D) -> ::std::result::Result @@ -521,6 +478,63 @@ impl Default for Config { } } +/// Struct for scrolling related settings +#[derive(Copy, Clone, Debug, Deserialize)] +pub struct Scrolling { + #[serde(deserialize_with="deserialize_scrolling_history")] + #[serde(default="default_scrolling_history")] + pub history: u32, + #[serde(deserialize_with="deserialize_scrolling_multiplier")] + #[serde(default="default_scrolling_multiplier")] + pub multiplier: u8, + #[serde(deserialize_with="deserialize_scrolling_multiplier")] + #[serde(default="default_scrolling_multiplier")] + pub faux_multiplier: u8, +} + +fn default_scrolling_history() -> u32 { + 10_000 +} + +// Default for normal and faux scrolling +fn default_scrolling_multiplier() -> u8 { + 3 +} + +impl Default for Scrolling { + fn default() -> Self { + Self { + history: default_scrolling_history(), + multiplier: default_scrolling_multiplier(), + faux_multiplier: default_scrolling_multiplier(), + } + } +} + +fn deserialize_scrolling_history<'a, D>(deserializer: D) -> ::std::result::Result + where D: de::Deserializer<'a> +{ + match u32::deserialize(deserializer) { + Ok(lines) => Ok(lines), + Err(err) => { + eprintln!("problem with config: {}; Using default value", err); + Ok(default_scrolling_history()) + }, + } +} + +fn deserialize_scrolling_multiplier<'a, D>(deserializer: D) -> ::std::result::Result + where D: de::Deserializer<'a> +{ + match u8::deserialize(deserializer) { + Ok(lines) => Ok(lines), + Err(err) => { + eprintln!("problem with config: {}; Using default value", err); + Ok(default_scrolling_multiplier()) + }, + } +} + /// Newtype for implementing deserialize on glutin Mods /// /// Our deserialize impl wouldn't be covered by a derive(Deserialize); see the @@ -1286,10 +1300,6 @@ impl Config { .map(|path| path.into()) } - pub fn scroll_history(&self) -> usize { - self.scroll_history as _ - } - pub fn write_defaults() -> io::Result> { let path = ::xdg::BaseDirectories::with_prefix("alacritty") .map_err(|err| io::Error::new(io::ErrorKind::NotFound, ::std::error::Error::description(&err))) @@ -1419,6 +1429,12 @@ impl Config { self.dynamic_title } + /// Scrolling settings + #[inline] + pub fn scrolling(&self) -> Scrolling { + self.scrolling + } + pub fn load_from>(path: P) -> Result { let path = path.into(); let raw = Config::read_file(path.as_path())?; @@ -1451,6 +1467,11 @@ impl Config { eprintln!("{}", fmt::Yellow("Config `padding` is deprecated. \ Please use `window.padding` instead.")); } + + if self.mouse.faux_scrollback_lines.is_some() { + println!("{}", fmt::Yellow("Config `mouse.faux_scrollback_lines` is deprecated. \ + Please use `mouse.faux_scrolling_lines` instead.")); + } } } -- cgit From a238e9ac5832cb9a40f886a3b873728cd7890d01 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 9 Mar 2018 23:02:45 +0100 Subject: Fix linux config default value --- src/config.rs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 8e531a9c..e7f1b587 100644 --- a/src/config.rs +++ b/src/config.rs @@ -385,18 +385,6 @@ pub struct Config { scrolling: Scrolling, } -fn deserialize_scroll_history<'a, D>(deserializer: D) -> ::std::result::Result - where D: de::Deserializer<'a> -{ - match u32::deserialize(deserializer) { - Ok(lines) => Ok(lines), - Err(err) => { - eprintln!("problem with config: {}; Using default value", err); - Ok(default_scroll_history()) - }, - } -} - fn failure_default_vec<'a, D, T>(deserializer: D) -> ::std::result::Result, D::Error> where D: de::Deserializer<'a>, T: Deserialize<'a> -- cgit From 2c7bb9a4d3ce3ead6de4ca6485ca67c44c0bd1c1 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 10 Mar 2018 20:24:10 +0100 Subject: Add scrollback hotkeys This offers a few additional hotkeys that can be used in combination with scrollback. None of these are used by default yet. This implements the following bindings: - ScrollPageUp: Scroll exactly one screen height up - ScrollPageDown: Scroll exactly one screen height down - ScrollToTop: Scroll as far up as possible - ScrollToBottom: Scroll as far down as possible This fixes #1151. --- src/config.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index e7f1b587..f8dad1f2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -588,7 +588,8 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { type Value = ActionWrapper; fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, ResetFontSize, or Quit") + f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \ + ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, ScrollToBottom or Quit") } fn visit_str(self, value: &str) -> ::std::result::Result @@ -601,6 +602,10 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { "IncreaseFontSize" => Action::IncreaseFontSize, "DecreaseFontSize" => Action::DecreaseFontSize, "ResetFontSize" => Action::ResetFontSize, + "ScrollPageUp" => Action::ScrollPageUp, + "ScrollPageDown" => Action::ScrollPageDown, + "ScrollToTop" => Action::ScrollToTop, + "ScrollToBottom" => Action::ScrollToBottom, "Quit" => Action::Quit, _ => return Err(E::invalid_value(Unexpected::Str(value), &self)), })) -- cgit From 688cabefc0bfc3224189c10235668eae5e5b0101 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Fri, 23 Mar 2018 01:01:55 +0100 Subject: Rework auto-scrolling options This changes two things, the first thing it does is that now whenever a keybinding sends an escape sequence, the viewport is automatically scrolled to the bottom. This is enabled by default and fixes #1187. The second thing is automatic scrolling when a command writes to the terminal. So when running a command like `sleep 3; ls -lah`, alacritty will scroll to the bottom once the output is sent, even if the viewport is currently not at the bottom of the scrollback. Because this can have an impact on performance, and is not enabled by default in terminals like iTerm or Termite (VTE), it is an opt-in setting in the config. --- src/config.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index f8dad1f2..0eab1bfb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -478,6 +478,8 @@ pub struct Scrolling { #[serde(deserialize_with="deserialize_scrolling_multiplier")] #[serde(default="default_scrolling_multiplier")] pub faux_multiplier: u8, + #[serde(default, deserialize_with="failure_default")] + pub auto_scroll: bool, } fn default_scrolling_history() -> u32 { @@ -495,6 +497,7 @@ impl Default for Scrolling { history: default_scrolling_history(), multiplier: default_scrolling_multiplier(), faux_multiplier: default_scrolling_multiplier(), + auto_scroll: false, } } } -- cgit From 2234234ca9a2ab0d7eccd46893cbe6799b051aba Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 14 Apr 2018 17:21:48 +0200 Subject: Enable history comparison in ref-tests Previously ref-tests just ignored the scrollback history to keep the old tests working, this would lead to new tests which rely on scrollback history to succeeed even though they should not. This has been fixed and it is now possible to create ref-tests with and without scrollback history. When available the scrollback history is compared, but the old tests still work without having to adjust them. This fixes #1244. --- src/config.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 0eab1bfb..b9c943ee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1431,6 +1431,11 @@ impl Config { self.scrolling } + // Update the history size, used in ref tests + pub fn set_history(&mut self, history: u32) { + self.scrolling.history = history; + } + pub fn load_from>(path: P) -> Result { let path = path.into(); let raw = Config::read_file(path.as_path())?; -- cgit From f50ca1a54c94fe324d22d985c1acae1ff7c16a80 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 21 Jul 2018 17:17:41 +0000 Subject: Scrollback cleanup There were some unneeded codeblocks and TODO/XXX comments in the code that have been removed. All issues marked with TODO/XXX have either been already resolved or tracking issues exist. --- src/config.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index b9c943ee..7d8600f4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -23,6 +23,7 @@ use notify::{Watcher, watcher, DebouncedEvent, RecursiveMode}; use glutin::ModifiersState; +use cli::Options; use input::{Action, Binding, MouseBinding, KeyBinding}; use index::{Line, Column}; use ansi::CursorStyle; @@ -224,7 +225,7 @@ impl Alpha { } #[inline] - pub fn get(&self) -> f32 { + pub fn get(self) -> f32 { self.0 } @@ -1446,6 +1447,14 @@ impl Config { Ok(config) } + /// Overrides the `dynamic_title` configuration based on `--title`. + pub fn update_dynamic_title(mut self, options: &Options) -> Self { + if options.title.is_some() { + self.dynamic_title = false; + } + self + } + fn read_file>(path: P) -> Result { let mut f = fs::File::open(path)?; let mut contents = String::new(); @@ -1609,7 +1618,10 @@ pub struct Font { glyph_offset: Delta, #[serde(default="true_bool", deserialize_with = "default_true_bool")] - use_thin_strokes: bool + use_thin_strokes: bool, + + #[serde(default="true_bool", deserialize_with = "default_true_bool")] + scale_with_dpi: bool, } fn default_bold_desc() -> FontDescription { @@ -1662,6 +1674,11 @@ impl Font { .. self } } + + /// Check whether dpi should be applied + pub fn scale_with_dpi(&self) -> bool { + self.scale_with_dpi + } } #[cfg(target_os = "macos")] @@ -1673,8 +1690,9 @@ impl Default for Font { italic: FontDescription::new_with_family("Menlo"), size: Size::new(11.0), use_thin_strokes: true, + scale_with_dpi: true, + glyph_offset: Default::default(), offset: Default::default(), - glyph_offset: Default::default() } } } @@ -1688,8 +1706,9 @@ impl Default for Font { italic: FontDescription::new_with_family("monospace"), size: Size::new(11.0), use_thin_strokes: false, + scale_with_dpi: true, + glyph_offset: Default::default(), offset: Default::default(), - glyph_offset: Default::default() } } } @@ -1771,6 +1790,7 @@ impl Monitor { #[cfg(test)] mod tests { + use cli::Options; use super::Config; #[cfg(target_os="macos")] @@ -1791,9 +1811,29 @@ mod tests { // Sanity check that key bindings are being parsed assert!(!config.key_bindings.is_empty()); } + + #[test] + fn dynamic_title_ignoring_options_by_default() { + let config: Config = ::serde_yaml::from_str(ALACRITTY_YML) + .expect("deserialize config"); + let old_dynamic_title = config.dynamic_title; + let options = Options::default(); + let config = config.update_dynamic_title(&options); + assert_eq!(old_dynamic_title, config.dynamic_title); + } + + #[test] + fn dynamic_title_overridden_by_options() { + let config: Config = ::serde_yaml::from_str(ALACRITTY_YML) + .expect("deserialize config"); + let mut options = Options::default(); + options.title = Some("foo".to_owned()); + let config = config.update_dynamic_title(&options); + assert!(!config.dynamic_title); + } } -#[cfg_attr(feature = "clippy", allow(enum_variant_names))] +#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))] #[derive(Deserialize, Copy, Clone)] enum Key { Key1, @@ -1947,13 +1987,16 @@ enum Key { WebStop, Yen, Caret, + Copy, + Paste, + Cut, } impl Key { - fn to_glutin_key(&self) -> ::glutin::VirtualKeyCode { + fn to_glutin_key(self) -> ::glutin::VirtualKeyCode { use ::glutin::VirtualKeyCode::*; // Thank you, vim macros! - match *self { + match self { Key::Key1 => Key1, Key::Key2 => Key2, Key::Key3 => Key3, @@ -2105,6 +2148,9 @@ impl Key { Key::WebStop => WebStop, Key::Yen => Yen, Key::Caret => Caret, + Key::Copy => Copy, + Key::Paste => Paste, + Key::Cut => Cut, } } } -- cgit From c4a0f9c4cb7e8d73914800c4ba64413970f98540 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 28 Jul 2018 23:10:13 +0000 Subject: Merge master into scrollback * Allow disabling DPI scaling This makes it possible to disable DPI scaling completely, instead the the display pixel ration will always be fixed to 1.0. By default nothing has changed and DPI is still enabled, this just seems like a better way than running `WINIT_HIDPI_FACTOR=1.0 alacritty` every time the user wants to start alacritty. It would be possible to allow specifying any DPR, however I've decided against this since I'd assume it's a very rare usecase. It's also still possible to make use of `WINIT_HIDPI_FACTOR` to do this on X11. Currently this is not updated at runtime using the live config update, there is not really much of a technical limitation why this woudn't be possible, however a solution for that issue should be first added in jwilm/alacritty#1346, once a system is established for changing DPI at runtime, porting that functionality to this PR should be simple. * Add working --class and --title CLI parameters * Reduce Increase-/DecreaseFontSize step to 0.5 Until now the Increase-/DecreaseFontSize keybinds hand a step size of 1.0. Since the font size however is multiplied by two to allow more granular font size control, this lead to the bindings skipping one font size (incrementing/decrementing by +-2). To fix this the step size of the Increase-/DecreaseFontSize bindings has been reduced to the minimum step size that exists with the current font configuration (0.5). This should allow users to increment and decrement the font size by a single point instead of two. This also adds a few tests to make sure the methods for increasing/decreasing/resetting font size work properly. * Add Copy/Cut/Paste keys This just adds support for the Copy/Cut/Paste keys and sets up Copy/Paste as alternative defaults for Ctrl+Shift+C/V. * Move to cargo clippy Using clippy as a library has been deprecated, instead the `cargo clippy` command should be used instead. To comply with this change clippy has been removed from the `Cargo.toml` and is now installed with cargo when building in CI. This has also lead to a few new clippy issues to show up, this includes everything in the `font` subdirectory. This has been fixed and `font` should now be covered by clippy CI too. This also upgrades all dependencies, as a result this fixes #1341 and this fixes #1344. * Override dynamic_title when --title is specified * Change green implementation to use the macro * Ignore mouse input if window is unfocused * Make compilation of binary a phony target * Add opensuse zypper install method to readme * Fix clippy issues * Update manpage to document all CLI options The introduction of `--class` has added a flag to the CLI without adding it to the manpage. This has been fixed by updating the manpage. This also adds the default values of `--class` and `--title` to the CLI options. * Remove unnecessary clippy lint annotations We moved to "cargo clippy" in 5ba34d4f9766a55a06ed5e3e44cc384af1b09f65 and removing the clippy lint annotations in `src/lib.rs` does not cause any additional warnings. This also changes `cargo clippy` to use the flags required for checking integration tests. * Enable clippy in font/copypasta crates Enabled clippy in the sub-crates font and copypasta. All issues that were discovered by this change have also been fixed. * Remove outdated comment about NixOS * Replace debug asserts with static_assertions To check that transmutes will work correctly without having to rely on error-prone runtime checking, the `static_assertions` crate has been introduced. This allows comparing the size of types at compile time, preventing potentially silent breakage. This fixes #1417. * Add `cargo deb` build instructions Updated the `Cargo.toml` file and added a `package.metadata.deb` subsection to define how to build a debian "deb" install file using `cargo deb`. This will allow debian/ubuntu users to install `alacritty` using their system's package manager. It also will make it easier to provide pre-built binaries for those systems. Also fixed a stray debug line in the bash autocomplete script that was writting to a tempfile. * Add config for unfocused window cursor change * Add support for cursor shape escape sequence * Add bright foreground color option It was requested in jwilm/alacritty#825 that it should be possible to add an optional bright foreground color. This is now added to the primary colors structure and allows the user to set a foreground color for bold normal text. This has no effect unless the draw_bold_text_with_bright_colors option is also enabled. If the color is not specified, the bright foreground color will fall back to the normal foreground color. This fixes #825. * Fix clone URL in deb install instructions * Fix 'cargo-deb' desktop file name * Remove redundant dependency from deb build * Switch from deprecated `std::env::home_dir` to `dirs::home_dir` * Allow specifying modifiers for mouse bindings * Send newline with NumpadEnter * Add support for LCD-V pixel mode * Add binding action for hiding the window * Switch to rustup clippy component * Add optional dim foreground color Add optional color for the dim foreground (`\e[2m;`) Defaults to 2/3 of the foreground color. (same as other colors). If a bright color is dimmed, it's displayed as the normal color. The exception for this is when the bright foreground is dimmed when no bright foreground color is set. In that case it's treated as a normal foreground color and dimmed to DimForeground. To minimize the surprise for the user, the bright and dim colors have been completely removed from the default configuration file. Some documentation has also been added to make it clear to users what these options can be used for. This fixes #1448. * Fix clippy lints and run font tests on travis This fixes some existing clippy issues and runs the `font` tests through travis. Testing of copypasta crate was omitted due to problens when running on headless travis-ci environment (x11 clipboard would fail). * Ignore errors when logger can't write to output The (e)print macro will panic when there is no output available to write to, however in our scenario where we only log user errors to stderr, the better choice would be to ignore when writing to stdout or stderr is not possible. This changes the (e)print macro to make use of `write` and ignore any potential errors. Since (e)println rely on (e)print, this also solves potential failuers when calling (e)println. With this change implemented, all of logging, (e)println and (e)print should never fail even if the stdout/stderr is not available. --- src/config.rs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 7d8600f4..00c3a933 100644 --- a/src/config.rs +++ b/src/config.rs @@ -373,6 +373,10 @@ pub struct Config { #[serde(default, deserialize_with = "failure_default")] cursor_style: CursorStyle, + /// Use hollow block cursor when unfocused + #[serde(default="true_bool", deserialize_with = "default_true_bool")] + unfocused_hollow_cursor: bool, + /// Live config reload #[serde(default="true_bool", deserialize_with = "default_true_bool")] live_config_reload: bool, @@ -593,7 +597,8 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \ - ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, ScrollToBottom or Quit") + ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \ + ScrollToBottom, Hide, or Quit") } fn visit_str(self, value: &str) -> ::std::result::Result @@ -610,6 +615,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { "ScrollPageDown" => Action::ScrollPageDown, "ScrollToTop" => Action::ScrollToTop, "ScrollToBottom" => Action::ScrollToBottom, + "Hide" => Action::Hide, "Quit" => Action::Quit, _ => return Err(E::invalid_value(Unexpected::Str(value), &self)), })) @@ -1070,6 +1076,26 @@ pub struct PrimaryColors { pub background: Rgb, #[serde(deserialize_with = "rgb_from_hex")] pub foreground: Rgb, + #[serde(default, deserialize_with = "deserialize_optional_color")] + pub bright_foreground: Option, + #[serde(default, deserialize_with = "deserialize_optional_color")] + pub dim_foreground: Option, +} + +fn deserialize_optional_color<'a, D>(deserializer: D) -> ::std::result::Result, D::Error> + where D: de::Deserializer<'a> +{ + match Option::deserialize(deserializer) { + Ok(Some(color)) => { + let color: serde_yaml::Value = color; + Ok(Some(rgb_from_hex(color).unwrap())) + }, + Ok(None) => Ok(None), + Err(err) => { + eprintln!("problem with config: {}; Using standard foreground color", err); + Ok(None) + }, + } } impl Default for PrimaryColors { @@ -1077,6 +1103,8 @@ impl Default for PrimaryColors { PrimaryColors { background: Rgb { r: 0, g: 0, b: 0 }, foreground: Rgb { r: 0xea, g: 0xea, b: 0xea }, + bright_foreground: None, + dim_foreground: None, } } } @@ -1415,6 +1443,12 @@ impl Config { self.cursor_style } + /// Use hollow block cursor when unfocused + #[inline] + pub fn unfocused_hollow_cursor(&self) -> bool { + self.unfocused_hollow_cursor + } + /// Live config reload #[inline] pub fn live_config_reload(&self) -> bool { -- cgit From 72495172c25e00799f29eb2e79fe40ddfa189866 Mon Sep 17 00:00:00 2001 From: Nathan Lilienthal Date: Sat, 1 Sep 2018 20:30:03 -0400 Subject: Implement `ansi::ClearMode::Saved` The clearing the screen for the `ansi::ClearMode::Saved` enum value has been implemented. This is used to clear all lines which are currently outside of the visible region but still inside the scrollback buffer. The specifications of XTerm indicate that the clearing of saved lines should only clear the saved lines and not the saved lines plus the currently visible part of the grid. Applications like `clear` send both the escape for clearing history plus the escape for clearing history when requested, so all sources seem to agree here. To allow both clearing the screen and the saved lines when a key is pressed the `process_key_bindings` method has been altered so multiple bindings can be specified. So it is now possible to execute both `^L` and `ClearHistory` with just a single binding. The `process_mouse_bindings` method has also been changed for consistency. To make sure everything works properly a test has been added which clears the history and then attempts to scroll. Since scrolling is the only way for a user to check if scrollback is available, this seems like a nice abstraction to check if there is a scrollback. --- src/config.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 00c3a933..f4da671c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -598,7 +598,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \ ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \ - ScrollToBottom, Hide, or Quit") + ScrollToBottom, ClearHistory, Hide, or Quit") } fn visit_str(self, value: &str) -> ::std::result::Result @@ -615,6 +615,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper { "ScrollPageDown" => Action::ScrollPageDown, "ScrollToTop" => Action::ScrollToTop, "ScrollToBottom" => Action::ScrollToBottom, + "ClearHistory" => Action::ClearHistory, "Hide" => Action::Hide, "Quit" => Action::Quit, _ => return Err(E::invalid_value(Unexpected::Str(value), &self)), -- cgit