diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2023-07-13 11:46:25 +0400 |
---|---|---|
committer | Kirill Chibisov <contact@kchibisov.com> | 2023-09-04 03:01:12 +0400 |
commit | bfcebbcd38d7bbf2aa4cce2e446fdb781bc0c4f0 (patch) | |
tree | aba4a49e65c0f10fe871f1e5ca2a1ad7746a6810 /alacritty/src/input.rs | |
parent | a189861880aafcce760e3a142bc2d391f2801f64 (diff) | |
download | r-alacritty-bfcebbcd38d7bbf2aa4cce2e446fdb781bc0c4f0.tar.gz r-alacritty-bfcebbcd38d7bbf2aa4cce2e446fdb781bc0c4f0.tar.bz2 r-alacritty-bfcebbcd38d7bbf2aa4cce2e446fdb781bc0c4f0.zip |
Add bindings for macOS tabs
This doesn't represnet the movement to add tabs on any other platform,
unless winit could add a similar API for them.
Diffstat (limited to 'alacritty/src/input.rs')
-rw-r--r-- | alacritty/src/input.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 54580fa6..14413f75 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -98,6 +98,9 @@ pub trait ActionContext<T: EventListener> { fn terminal(&self) -> &Term<T>; fn terminal_mut(&mut self) -> &mut Term<T>; fn spawn_new_instance(&mut self) {} + #[cfg(target_os = "macos")] + fn create_new_window(&mut self, _tabbing_id: Option<String>) {} + #[cfg(not(target_os = "macos"))] fn create_new_window(&mut self) {} fn change_font_size(&mut self, _delta: f32) {} fn reset_font_size(&mut self) {} @@ -363,8 +366,40 @@ impl<T: EventListener> Execute<T> for Action { }, Action::ClearHistory => ctx.terminal_mut().clear_screen(ClearMode::Saved), Action::ClearLogNotice => ctx.pop_message(), - Action::SpawnNewInstance => ctx.spawn_new_instance(), + #[cfg(not(target_os = "macos"))] Action::CreateNewWindow => ctx.create_new_window(), + Action::SpawnNewInstance => ctx.spawn_new_instance(), + #[cfg(target_os = "macos")] + Action::CreateNewWindow => ctx.create_new_window(None), + #[cfg(target_os = "macos")] + Action::CreateNewTab => { + let tabbing_id = Some(ctx.window().tabbing_id()); + ctx.create_new_window(tabbing_id); + }, + #[cfg(target_os = "macos")] + Action::SelectNextTab => ctx.window().select_next_tab(), + #[cfg(target_os = "macos")] + Action::SelectPreviousTab => ctx.window().select_previous_tab(), + #[cfg(target_os = "macos")] + Action::SelectTab1 => ctx.window().select_tab_at_index(0), + #[cfg(target_os = "macos")] + Action::SelectTab2 => ctx.window().select_tab_at_index(1), + #[cfg(target_os = "macos")] + Action::SelectTab3 => ctx.window().select_tab_at_index(2), + #[cfg(target_os = "macos")] + Action::SelectTab4 => ctx.window().select_tab_at_index(3), + #[cfg(target_os = "macos")] + Action::SelectTab5 => ctx.window().select_tab_at_index(4), + #[cfg(target_os = "macos")] + Action::SelectTab6 => ctx.window().select_tab_at_index(5), + #[cfg(target_os = "macos")] + Action::SelectTab7 => ctx.window().select_tab_at_index(6), + #[cfg(target_os = "macos")] + Action::SelectTab8 => ctx.window().select_tab_at_index(7), + #[cfg(target_os = "macos")] + Action::SelectTab9 => ctx.window().select_tab_at_index(8), + #[cfg(target_os = "macos")] + Action::SelectLastTab => ctx.window().select_last_tab(), Action::ReceiveChar | Action::None => (), } } |