mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
wezterm: add disable_default_(key|mouse)_bindings config
If set to true, then none of the default key or mouse bindings, respectively, will be registered in the GUI, leaving it up to the user to provide all key assignments.
This commit is contained in:
parent
acd016cdd4
commit
9e89a557d4
@ -416,9 +416,13 @@ pub struct Config {
|
||||
|
||||
#[serde(default)]
|
||||
pub keys: Vec<Key>,
|
||||
#[serde(default)]
|
||||
pub disable_default_key_bindings: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub mouse_bindings: Vec<Mouse>,
|
||||
#[serde(default)]
|
||||
pub disable_default_mouse_bindings: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub daemon_options: DaemonOptions,
|
||||
|
@ -143,192 +143,196 @@ impl InputMap {
|
||||
|
||||
let ctrl_shift = KeyModifiers::CTRL | KeyModifiers::SHIFT;
|
||||
|
||||
// Apply the default bindings; if the user has already mapped
|
||||
// a given entry then that will take precedence.
|
||||
k!(
|
||||
// Clipboard
|
||||
[KeyModifiers::SHIFT, KeyCode::Insert, Paste],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('c'), Copy],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('v'), Paste],
|
||||
[ctrl_shift, KeyCode::Char('C'), Copy],
|
||||
[ctrl_shift, KeyCode::Char('V'), Paste],
|
||||
// Window management
|
||||
[KeyModifiers::ALT, KeyCode::Char('\n'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Char('\r'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Enter, ToggleFullScreen],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('m'), Hide],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('n'), SpawnWindow],
|
||||
[ctrl_shift, KeyCode::Char('M'), Hide],
|
||||
[ctrl_shift, KeyCode::Char('N'), SpawnWindow],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('k'), ClearScrollback],
|
||||
[ctrl_shift, KeyCode::Char('K'), ClearScrollback],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('f'), Search],
|
||||
[ctrl_shift, KeyCode::Char('F'), Search],
|
||||
// Font size manipulation
|
||||
[KeyModifiers::CTRL, KeyCode::Char('-'), DecreaseFontSize],
|
||||
[KeyModifiers::CTRL, KeyCode::Char('0'), ResetFontSize],
|
||||
[KeyModifiers::CTRL, KeyCode::Char('='), IncreaseFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('-'), DecreaseFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('0'), ResetFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('='), IncreaseFontSize],
|
||||
// Tab navigation and management
|
||||
[
|
||||
KeyModifiers::SUPER,
|
||||
KeyCode::Char('t'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[
|
||||
ctrl_shift,
|
||||
KeyCode::Char('T'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('T'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('1'), ActivateTab(0)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('2'), ActivateTab(1)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('3'), ActivateTab(2)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('4'), ActivateTab(3)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('5'), ActivateTab(4)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('6'), ActivateTab(5)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('7'), ActivateTab(6)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('8'), ActivateTab(7)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('9'), ActivateTab(8)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('w'), CloseCurrentTab],
|
||||
[ctrl_shift, KeyCode::Char('1'), ActivateTab(0)],
|
||||
[ctrl_shift, KeyCode::Char('2'), ActivateTab(1)],
|
||||
[ctrl_shift, KeyCode::Char('3'), ActivateTab(2)],
|
||||
[ctrl_shift, KeyCode::Char('4'), ActivateTab(3)],
|
||||
[ctrl_shift, KeyCode::Char('5'), ActivateTab(4)],
|
||||
[ctrl_shift, KeyCode::Char('6'), ActivateTab(5)],
|
||||
[ctrl_shift, KeyCode::Char('7'), ActivateTab(6)],
|
||||
[ctrl_shift, KeyCode::Char('8'), ActivateTab(7)],
|
||||
[ctrl_shift, KeyCode::Char('9'), ActivateTab(8)],
|
||||
[ctrl_shift, KeyCode::Char('W'), CloseCurrentTab],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('['),
|
||||
ActivateTabRelative(-1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('{'),
|
||||
ActivateTabRelative(-1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char(']'),
|
||||
ActivateTabRelative(1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('}'),
|
||||
ActivateTabRelative(1)
|
||||
],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('r'), ReloadConfiguration],
|
||||
[ctrl_shift, KeyCode::Char('R'), ReloadConfiguration],
|
||||
[ctrl_shift, KeyCode::PageUp, MoveTabRelative(-1)],
|
||||
[ctrl_shift, KeyCode::PageDown, MoveTabRelative(1)],
|
||||
[KeyModifiers::SHIFT, KeyCode::PageUp, ScrollByPage(-1)],
|
||||
[KeyModifiers::SHIFT, KeyCode::PageDown, ScrollByPage(1)],
|
||||
[KeyModifiers::ALT, KeyCode::Char('9'), ShowTabNavigator],
|
||||
);
|
||||
if !config.disable_default_key_bindings {
|
||||
// Apply the default bindings; if the user has already mapped
|
||||
// a given entry then that will take precedence.
|
||||
k!(
|
||||
// Clipboard
|
||||
[KeyModifiers::SHIFT, KeyCode::Insert, Paste],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('c'), Copy],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('v'), Paste],
|
||||
[ctrl_shift, KeyCode::Char('C'), Copy],
|
||||
[ctrl_shift, KeyCode::Char('V'), Paste],
|
||||
// Window management
|
||||
[KeyModifiers::ALT, KeyCode::Char('\n'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Char('\r'), ToggleFullScreen],
|
||||
[KeyModifiers::ALT, KeyCode::Enter, ToggleFullScreen],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('m'), Hide],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('n'), SpawnWindow],
|
||||
[ctrl_shift, KeyCode::Char('M'), Hide],
|
||||
[ctrl_shift, KeyCode::Char('N'), SpawnWindow],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('k'), ClearScrollback],
|
||||
[ctrl_shift, KeyCode::Char('K'), ClearScrollback],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('f'), Search],
|
||||
[ctrl_shift, KeyCode::Char('F'), Search],
|
||||
// Font size manipulation
|
||||
[KeyModifiers::CTRL, KeyCode::Char('-'), DecreaseFontSize],
|
||||
[KeyModifiers::CTRL, KeyCode::Char('0'), ResetFontSize],
|
||||
[KeyModifiers::CTRL, KeyCode::Char('='), IncreaseFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('-'), DecreaseFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('0'), ResetFontSize],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('='), IncreaseFontSize],
|
||||
// Tab navigation and management
|
||||
[
|
||||
KeyModifiers::SUPER,
|
||||
KeyCode::Char('t'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[
|
||||
ctrl_shift,
|
||||
KeyCode::Char('T'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('T'),
|
||||
SpawnTab(SpawnTabDomain::CurrentTabDomain)
|
||||
],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('1'), ActivateTab(0)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('2'), ActivateTab(1)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('3'), ActivateTab(2)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('4'), ActivateTab(3)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('5'), ActivateTab(4)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('6'), ActivateTab(5)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('7'), ActivateTab(6)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('8'), ActivateTab(7)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('9'), ActivateTab(8)],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('w'), CloseCurrentTab],
|
||||
[ctrl_shift, KeyCode::Char('1'), ActivateTab(0)],
|
||||
[ctrl_shift, KeyCode::Char('2'), ActivateTab(1)],
|
||||
[ctrl_shift, KeyCode::Char('3'), ActivateTab(2)],
|
||||
[ctrl_shift, KeyCode::Char('4'), ActivateTab(3)],
|
||||
[ctrl_shift, KeyCode::Char('5'), ActivateTab(4)],
|
||||
[ctrl_shift, KeyCode::Char('6'), ActivateTab(5)],
|
||||
[ctrl_shift, KeyCode::Char('7'), ActivateTab(6)],
|
||||
[ctrl_shift, KeyCode::Char('8'), ActivateTab(7)],
|
||||
[ctrl_shift, KeyCode::Char('9'), ActivateTab(8)],
|
||||
[ctrl_shift, KeyCode::Char('W'), CloseCurrentTab],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('['),
|
||||
ActivateTabRelative(-1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('{'),
|
||||
ActivateTabRelative(-1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char(']'),
|
||||
ActivateTabRelative(1)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||
KeyCode::Char('}'),
|
||||
ActivateTabRelative(1)
|
||||
],
|
||||
[KeyModifiers::SUPER, KeyCode::Char('r'), ReloadConfiguration],
|
||||
[ctrl_shift, KeyCode::Char('R'), ReloadConfiguration],
|
||||
[ctrl_shift, KeyCode::PageUp, MoveTabRelative(-1)],
|
||||
[ctrl_shift, KeyCode::PageDown, MoveTabRelative(1)],
|
||||
[KeyModifiers::SHIFT, KeyCode::PageUp, ScrollByPage(-1)],
|
||||
[KeyModifiers::SHIFT, KeyCode::PageDown, ScrollByPage(1)],
|
||||
[KeyModifiers::ALT, KeyCode::Char('9'), ShowTabNavigator],
|
||||
);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
k!([KeyModifiers::SUPER, KeyCode::Char('h'), HideApplication],);
|
||||
#[cfg(target_os = "macos")]
|
||||
k!([KeyModifiers::SUPER, KeyCode::Char('h'), HideApplication],);
|
||||
}
|
||||
|
||||
m!(
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Line)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Word)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Cell)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SHIFT,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(None)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelectionOrOpenLinkAtMouseCursor
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelection
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelection
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Cell))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Word))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Line))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Middle
|
||||
},
|
||||
Paste
|
||||
],
|
||||
);
|
||||
if !config.disable_default_mouse_bindings {
|
||||
m!(
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Line)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Word)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
SelectTextAtMouseCursor(SelectionMode::Cell)
|
||||
],
|
||||
[
|
||||
KeyModifiers::SHIFT,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(None)
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelectionOrOpenLinkAtMouseCursor
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelection
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Up {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
CompleteSelection
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 1,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Cell))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 2,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Word))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Drag {
|
||||
streak: 3,
|
||||
button: MouseButton::Left
|
||||
},
|
||||
ExtendSelectionToMouseCursor(Some(SelectionMode::Line))
|
||||
],
|
||||
[
|
||||
KeyModifiers::NONE,
|
||||
MouseEventTrigger::Down {
|
||||
streak: 1,
|
||||
button: MouseButton::Middle
|
||||
},
|
||||
Paste
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Self { keys, mouse }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user