1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Add Minimize binding action

Fixes #2534.
This commit is contained in:
Kirill Chibisov 2020-01-05 04:54:14 +03:00 committed by Christian Duerr
parent 1cfb0740bc
commit 0cc68da04f
5 changed files with 20 additions and 6 deletions

View file

@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- /Applications symlink into OS X DMG for easier installation - /Applications symlink into OS X DMG for easier installation
- Colored emojis on Linux/BSD - Colored emojis on Linux/BSD
- Value `randr` for `WINIT_HIDPI_FACTOR`, to ignore `Xft.dpi` and scale based on screen dimensions - Value `randr` for `WINIT_HIDPI_FACTOR`, to ignore `Xft.dpi` and scale based on screen dimensions
- `Minimize` key binding action, bound to `cmd + m` on macOS
### Changed ### Changed

View file

@ -65,14 +65,14 @@
# Window title # Window title
#title: Alacritty #title: Alacritty
# Window class (Linux only): # Window class (Linux/BSD only):
#class: #class:
# Application instance name # Application instance name
#instance: Alacritty #instance: Alacritty
# General application class # General application class
#general: Alacritty #general: Alacritty
# GTK theme variant (Linux only) # GTK theme variant (Linux/BSD only)
# #
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`. # Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
# Set this to `None` to use the default theme variant. # Set this to `None` to use the default theme variant.
@ -107,7 +107,7 @@
# #
# Default: # Default:
# - (macOS) Menlo # - (macOS) Menlo
# - (Linux) monospace # - (Linux/BSD) monospace
# - (Windows) Consolas # - (Windows) Consolas
#family: monospace #family: monospace
@ -324,7 +324,7 @@
# #
# Default: # Default:
# - (macOS) /bin/bash --login # - (macOS) /bin/bash --login
# - (Linux) user login shell # - (Linux/BSD) user login shell
# - (Windows) powershell # - (Windows) powershell
#shell: #shell:
# program: /bin/bash # program: /bin/bash
@ -396,7 +396,7 @@
# #
# Default: # Default:
# - (macOS) open # - (macOS) open
# - (Linux) xdg-open # - (Linux/BSD) xdg-open
# - (Windows) explorer # - (Windows) explorer
#launcher: #launcher:
# program: xdg-open # program: xdg-open
@ -482,6 +482,7 @@
# - ScrollToBottom # - ScrollToBottom
# - ClearHistory # - ClearHistory
# - Hide # - Hide
# - Minimize
# - Quit # - Quit
# - ToggleFullscreen # - ToggleFullscreen
# - SpawnNewInstance # - SpawnNewInstance
@ -530,7 +531,7 @@
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for # be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
# a no-op if you do not wish to receive input characters for that binding. # a no-op if you do not wish to receive input characters for that binding.
#key_bindings: #key_bindings:
# (Windows/Linux only) # (Windows, Linux, and BSD only)
#- { key: V, mods: Control|Shift, action: Paste } #- { key: V, mods: Control|Shift, action: Paste }
#- { key: C, mods: Control|Shift, action: Copy } #- { key: C, mods: Control|Shift, action: Copy }
#- { key: Insert, mods: Shift, action: PasteSelection } #- { key: Insert, mods: Shift, action: PasteSelection }
@ -539,6 +540,8 @@
#- { key: Add, mods: Control, action: IncreaseFontSize } #- { key: Add, mods: Control, action: IncreaseFontSize }
#- { key: Subtract, mods: Control, action: DecreaseFontSize } #- { key: Subtract, mods: Control, action: DecreaseFontSize }
#- { key: Minus, mods: Control, action: DecreaseFontSize } #- { key: Minus, mods: Control, action: DecreaseFontSize }
# (Windows only)
#- { key: Return, mods: Alt, action: ToggleFullscreen } #- { key: Return, mods: Alt, action: ToggleFullscreen }
# (macOS only) # (macOS only)
@ -551,6 +554,7 @@
#- { key: V, mods: Command, action: Paste } #- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy } #- { key: C, mods: Command, action: Copy }
#- { key: H, mods: Command, action: Hide } #- { key: H, mods: Command, action: Hide }
#- { key: M, mods: Command, action: Minimize }
#- { key: Q, mods: Command, action: Quit } #- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit } #- { key: W, mods: Command, action: Quit }
#- { key: F, mods: Command|Control, action: ToggleFullscreen } #- { key: F, mods: Command|Control, action: ToggleFullscreen }

View file

@ -167,6 +167,9 @@ pub enum Action {
/// Hide the Alacritty window. /// Hide the Alacritty window.
Hide, Hide,
/// Minimize the Alacritty window.
Minimize,
/// Quit Alacritty. /// Quit Alacritty.
Quit, Quit,
@ -430,6 +433,7 @@ pub fn platform_key_bindings() -> Vec<KeyBinding> {
Key::V, ModifiersState::LOGO; Action::Paste; Key::V, ModifiersState::LOGO; Action::Paste;
Key::C, ModifiersState::LOGO; Action::Copy; Key::C, ModifiersState::LOGO; Action::Copy;
Key::H, ModifiersState::LOGO; Action::Hide; Key::H, ModifiersState::LOGO; Action::Hide;
Key::M, ModifiersState::LOGO; Action::Minimize;
Key::Q, ModifiersState::LOGO; Action::Quit; Key::Q, ModifiersState::LOGO; Action::Quit;
Key::W, ModifiersState::LOGO; Action::Quit; Key::W, ModifiersState::LOGO; Action::Quit;
) )

View file

@ -137,6 +137,7 @@ impl<T: EventListener> Execute<T> for Action {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
Action::ToggleSimpleFullscreen => ctx.window_mut().toggle_simple_fullscreen(), Action::ToggleSimpleFullscreen => ctx.window_mut().toggle_simple_fullscreen(),
Action::Hide => ctx.window().set_visible(false), Action::Hide => ctx.window().set_visible(false),
Action::Minimize => ctx.window().set_minimized(true),
Action::Quit => ctx.terminal_mut().exit(), Action::Quit => ctx.terminal_mut().exit(),
Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP), Action::IncreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP),
Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.), Action::DecreaseFontSize => ctx.change_font_size(FONT_SIZE_STEP * -1.),

View file

@ -319,6 +319,10 @@ impl Window {
self.window().set_maximized(maximized); self.window().set_maximized(maximized);
} }
pub fn set_minimized(&self, minimized: bool) {
self.window().set_minimized(minimized);
}
/// Toggle the window's fullscreen state /// Toggle the window's fullscreen state
pub fn toggle_fullscreen(&mut self) { pub fn toggle_fullscreen(&mut self) {
self.set_fullscreen(self.window().fullscreen().is_none()); self.set_fullscreen(self.window().fullscreen().is_none());