1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

rejigger tab spawning hotkeys

cmd-t now spawns in the same domain as the active tab,
cmd-shift-t spawns in the default domain.

It is possible to define bindings to spawn in an arbitrary domain.
This commit is contained in:
Wez Furlong 2019-06-22 07:46:49 -07:00
parent 2e84714c97
commit fcc2b1ab7d
4 changed files with 39 additions and 15 deletions

View File

@ -143,7 +143,8 @@ The default key bindings are:
| `CTRL` | `=` | `IncreaseFontSize` |
| `SUPER` | `0` | `ResetFontSize` |
| `CTRL` | `0` | `ResetFontSize` |
| `SUPER` | `t` | `SpawnTab` |
| `SUPER` | `t` | `SpawnTabInCurrentTabDomain` |
| `SUPER|SHIFT` | `T` | `SpawnTab` |
| `SUPER` | `w` | `CloseCurrentTab` |
| `SUPER` | `1` | `ActivateTab(0)` |
| `SUPER` | `2` | `ActivateTab(1)` |
@ -205,7 +206,9 @@ specified via the `arg` key; see examples below.
| Name | Effect |
| ------------------ | ------------------ |
| `SpawnTab` | Create a new tab in the current window |
| `SpawnTab` | Create a new local tab in the current window |
| `SpawnTabInCurrentTabDomain` | Create a new tab in the current window. The tab will be spawned in the same domain as the currently active tab |
| `SpawnTabInDomain` | Create a new tab in the current window. The tab will be spawned in the domain specified by the `arg` value |
| `SpawnWindow` | Create a new window |
| `ToggleFullScreen` | Toggles full screen mode for current window |
| `Paste` | Paste the clipboard to the current tab |
@ -244,6 +247,14 @@ mods = "CTRL|ALT"
action = "ActivateTab"
# the tab number
arg = "0"
# CMD+y spawns a new tab in Domain 1
[[keys]]
key = "y"
mods = "CMD"
action = "SpawnTabInDomain"
# the domain ID
arg = "1"
```
### Colors

View File

@ -2,6 +2,7 @@
use crate::font::FontSystemSelection;
use crate::frontend::guicommon::host::KeyAssignment;
use crate::frontend::guicommon::window::SpawnTabDomain;
use crate::frontend::FrontEndSelection;
use crate::get_shell;
use failure::{bail, err_msg, format_err, Error, Fallible};
@ -174,8 +175,16 @@ impl std::convert::TryInto<KeyAssignment> for &Key {
type Error = Error;
fn try_into(self) -> Result<KeyAssignment, Error> {
Ok(match self.action {
KeyAction::SpawnTab => KeyAssignment::SpawnTab,
KeyAction::SpawnTabInCurrentTabDomain => KeyAssignment::SpawnTabInCurrentTabDomain,
KeyAction::SpawnTab => KeyAssignment::SpawnTab(SpawnTabDomain::DefaultDomain),
KeyAction::SpawnTabInCurrentTabDomain => {
KeyAssignment::SpawnTab(SpawnTabDomain::CurrentTabDomain)
}
KeyAction::SpawnTabInDomain => KeyAssignment::SpawnTab(SpawnTabDomain::Domain(
self.arg
.as_ref()
.ok_or_else(|| format_err!("missing arg for {:?}", self))?
.parse()?,
)),
KeyAction::SpawnWindow => KeyAssignment::SpawnWindow,
KeyAction::ToggleFullScreen => KeyAssignment::ToggleFullScreen,
KeyAction::Copy => KeyAssignment::Copy,
@ -213,6 +222,7 @@ impl std::convert::TryInto<KeyAssignment> for &Key {
pub enum KeyAction {
SpawnTab,
SpawnTabInCurrentTabDomain,
SpawnTabInDomain,
SpawnWindow,
ToggleFullScreen,
Copy,

View File

@ -20,10 +20,7 @@ use termwiz::hyperlink::Hyperlink;
#[derive(Debug, Clone)]
pub enum KeyAssignment {
/// Spawn a tab in the default domain
SpawnTab,
/// Spawn a tab in whichever domain the current tab belongs
SpawnTabInCurrentTabDomain,
SpawnTab(SpawnTabDomain),
SpawnWindow,
ToggleFullScreen,
Copy,
@ -133,7 +130,16 @@ fn key_bindings() -> KeyMap {
[KeyModifiers::SUPER, KeyCode::Char('0'), ResetFontSize],
[KeyModifiers::CTRL, KeyCode::Char('0'), ResetFontSize],
// Tab navigation and management
[KeyModifiers::SUPER, KeyCode::Char('t'), SpawnTab],
[
KeyModifiers::SUPER,
KeyCode::Char('t'),
SpawnTab(SpawnTabDomain::DefaultDomain)
],
[
KeyModifiers::SUPER | KeyModifiers::SHIFT,
KeyCode::Char('T'),
SpawnTab(SpawnTabDomain::CurrentTabDomain)
],
[KeyModifiers::SUPER, KeyCode::Char('w'), CloseCurrentTab],
[KeyModifiers::SUPER, KeyCode::Char('1'), ActivateTab(0)],
[KeyModifiers::SUPER, KeyCode::Char('2'), ActivateTab(1)],
@ -206,11 +212,9 @@ impl<H: HostHelper> HostImpl<H> {
) -> Fallible<()> {
use KeyAssignment::*;
match assignment {
SpawnTab => {
self.with_window(|win| win.spawn_tab(SpawnTabDomain::DefaultDomain).map(|_| ()))
}
SpawnTabInCurrentTabDomain => {
self.with_window(|win| win.spawn_tab(SpawnTabDomain::CurrentTabDomain).map(|_| ()))
SpawnTab(spawn_where) => {
let spawn_where = *spawn_where;
self.with_window(move |win| win.spawn_tab(spawn_where).map(|_| ()))
}
SpawnWindow => self.spawn_new_window(),
ToggleFullScreen => self.toggle_full_screen(),

View File

@ -22,7 +22,6 @@ pub enum SpawnTabDomain {
/// Use the domain from the current tab in the associated window
CurrentTabDomain,
/// Use a specific domain
#[allow(dead_code)]
Domain(DomainId),
}