diff options
author | Dan Aloni <alonid@gmail.com> | 2017-10-14 20:35:56 +0300 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-10-14 10:35:56 -0700 |
commit | 8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e (patch) | |
tree | 80768003f9a2f3c99b0238dc68f4c9b119cc77d6 /src/input.rs | |
parent | fd410f9ec8bc53e35d46cc213244c978ef7c5816 (diff) | |
download | alacritty-8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e.tar.gz alacritty-8a0b1d9c3f5a9ddb98469a340bbcd06374d4a24e.zip |
Implement user actions for font resize (#625)
Adds support for font resizing at run-time. Three new actions are
introduced:
* IncreaseFontSize - Increases current font size by 1.0
* DecreaseFontSize - Decreases current font size by 1.0
* ResetFontSize - Resets font size to that specified in the
configuration.
The stock config files have example configuration for each which should
match gnome-terminal. For convenience, the config entries are:
- { key: Key0, mods: Control, action: ResetFontSize }
- { key: Equals, mods: Control, action: IncreaseFontSize }
- { key: Subtract, mods: Control, action: DecreaseFontSize }
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index 4be7dac5..7378e8dc 100644 --- a/src/input.rs +++ b/src/input.rs @@ -62,6 +62,8 @@ pub trait ActionContext { fn received_count(&mut self) -> &mut usize; fn suppress_chars(&mut self) -> &mut bool; fn last_modifiers(&mut self) -> &mut ModifiersState; + fn change_font_size(&mut self, delta: i8); + fn reset_font_size(&mut self); } /// Describes a state and action to take in that state @@ -154,6 +156,15 @@ pub enum Action { /// Paste contents of selection buffer PasteSelection, + /// Increase font size + IncreaseFontSize, + + /// Decrease font size + DecreaseFontSize, + + /// Reset font size to the config value + ResetFontSize, + /// Run given command Command(String, Vec<String>), @@ -202,6 +213,15 @@ impl Action { // FIXME should do a more graceful shutdown ::std::process::exit(0); }, + Action::IncreaseFontSize => { + ctx.change_font_size(1); + }, + Action::DecreaseFontSize => { + ctx.change_font_size(-1); + } + Action::ResetFontSize => { + ctx.reset_font_size(); + } } } @@ -593,6 +613,10 @@ mod tests { fn last_modifiers(&mut self) -> &mut ModifiersState { &mut self.last_modifiers } + fn change_font_size(&mut self, _delta: i8) { + } + fn reset_font_size(&mut self) { + } } macro_rules! test_clickstate { |