diff options
author | Christian Duerr <contact@christianduerr.com> | 2018-03-09 16:06:39 +0100 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-06-02 09:44:58 -0700 |
commit | dab0eca4a7bbb94e728465ca0248fbbbf32e6674 (patch) | |
tree | b1d4ae8da619248e8446e2f3b2c14e9a2aa4ac61 /src/config.rs | |
parent | 231ef51365e3cb0de760d04a47a7d2b74809c41d (diff) | |
download | alacritty-dab0eca4a7bbb94e728465ca0248fbbbf32e6674.tar.gz alacritty-dab0eca4a7bbb94e728465ca0248fbbbf32e6674.zip |
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.
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 32 |
1 files changed, 27 insertions, 5 deletions
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<usize, D::Error> +fn default_normal_scrolling_lines() -> u8 { + 3 +} + +fn deserialize_faux_scrollback_lines<'a, D>(deserializer: D) -> ::std::result::Result<u8, D::Error> 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<u8, D::Error> + 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(), } } } |