mirror of
https://github.com/wez/wezterm.git
synced 2024-11-27 02:25:28 +03:00
wezterm: ActivateTab now accepts negative numbers
This allows setting up shortcuts relative to the final tab in a window, rather than always being relative to the first. The default assignment for CTRL+SHIFT+9 is now `ActivateTab=-1` as a convenient way to always reach the last tab. refs: https://github.com/wez/wezterm/issues/228
This commit is contained in:
parent
d1dd28df46
commit
843ce152ec
@ -41,6 +41,9 @@ brief notes about them may accumulate here.
|
|||||||
to a similar degree as iTerm2
|
to a similar degree as iTerm2
|
||||||
* Fixed an issue where unmodified F5+ would use the CSI-u encoded-modifiers
|
* Fixed an issue where unmodified F5+ would use the CSI-u encoded-modifiers
|
||||||
format, and confused eg: `htop`.
|
format, and confused eg: `htop`.
|
||||||
|
* `ActivateTab` now accepts negative numbers as a way to reference the last
|
||||||
|
tab in the Window. The default assignment for `CTRL+SHIFT+9` and `CMD+9`
|
||||||
|
is now `ActivateTab=-1`, which selects the last tab.
|
||||||
|
|
||||||
### 20200607-144723-74889cd4
|
### 20200607-144723-74889cd4
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ The default key bindings are:
|
|||||||
| `SUPER` | `6` | `ActivateTab=5` |
|
| `SUPER` | `6` | `ActivateTab=5` |
|
||||||
| `SUPER` | `7` | `ActivateTab=6` |
|
| `SUPER` | `7` | `ActivateTab=6` |
|
||||||
| `SUPER` | `8` | `ActivateTab=7` |
|
| `SUPER` | `8` | `ActivateTab=7` |
|
||||||
| `SUPER` | `9` | `ActivateTab=8` |
|
| `SUPER` | `9` | `ActivateTab=-1` |
|
||||||
| `CTRL+SHIFT` | `w` | `CloseCurrentTab` |
|
| `CTRL+SHIFT` | `w` | `CloseCurrentTab` |
|
||||||
| `CTRL+SHIFT` | `1` | `ActivateTab=0` |
|
| `CTRL+SHIFT` | `1` | `ActivateTab=0` |
|
||||||
| `CTRL+SHIFT` | `2` | `ActivateTab=1` |
|
| `CTRL+SHIFT` | `2` | `ActivateTab=1` |
|
||||||
@ -50,7 +50,7 @@ The default key bindings are:
|
|||||||
| `CTRL+SHIFT` | `6` | `ActivateTab=5` |
|
| `CTRL+SHIFT` | `6` | `ActivateTab=5` |
|
||||||
| `CTRL+SHIFT` | `7` | `ActivateTab=6` |
|
| `CTRL+SHIFT` | `7` | `ActivateTab=6` |
|
||||||
| `CTRL+SHIFT` | `8` | `ActivateTab=7` |
|
| `CTRL+SHIFT` | `8` | `ActivateTab=7` |
|
||||||
| `CTRL+SHIFT` | `9` | `ActivateTab=8` |
|
| `CTRL+SHIFT` | `9` | `ActivateTab=-1` |
|
||||||
| `SUPER+SHIFT` | `[` | `ActivateTabRelative=-1` |
|
| `SUPER+SHIFT` | `[` | `ActivateTabRelative=-1` |
|
||||||
| `SUPER+SHIFT` | `]` | `ActivateTabRelative=1` |
|
| `SUPER+SHIFT` | `]` | `ActivateTabRelative=1` |
|
||||||
| `CTRL+SHIFT` | `PAGEUP` | `MoveTabRelative=-1` |
|
| `CTRL+SHIFT` | `PAGEUP` | `MoveTabRelative=-1` |
|
||||||
@ -340,6 +340,13 @@ return {
|
|||||||
Activate the tab specified by the argument value. eg: `0` activates the
|
Activate the tab specified by the argument value. eg: `0` activates the
|
||||||
leftmost tab, while `1` activates the second tab from the left, and so on.
|
leftmost tab, while `1` activates the second tab from the left, and so on.
|
||||||
|
|
||||||
|
*since: nightly*
|
||||||
|
|
||||||
|
`ActivateTab` now accepts negative numbers; these wrap around from the start
|
||||||
|
of the tabs to the end, so `-1` references the right-most tab, `-2` the tab
|
||||||
|
to its left and so on.
|
||||||
|
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local wezterm = require 'wezterm';
|
local wezterm = require 'wezterm';
|
||||||
|
|
||||||
|
@ -1202,13 +1202,20 @@ impl TermWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn activate_tab(&mut self, tab_idx: usize) -> anyhow::Result<()> {
|
fn activate_tab(&mut self, tab_idx: isize) -> anyhow::Result<()> {
|
||||||
let mux = Mux::get().unwrap();
|
let mux = Mux::get().unwrap();
|
||||||
let mut window = mux
|
let mut window = mux
|
||||||
.get_window_mut(self.mux_window_id)
|
.get_window_mut(self.mux_window_id)
|
||||||
.ok_or_else(|| anyhow!("no such window"))?;
|
.ok_or_else(|| anyhow!("no such window"))?;
|
||||||
|
|
||||||
let max = window.len();
|
let max = window.len();
|
||||||
|
|
||||||
|
let tab_idx = if tab_idx < 0 {
|
||||||
|
max.saturating_sub(tab_idx.abs() as usize)
|
||||||
|
} else {
|
||||||
|
tab_idx as usize
|
||||||
|
};
|
||||||
|
|
||||||
if tab_idx < max {
|
if tab_idx < max {
|
||||||
window.set_active(tab_idx);
|
window.set_active(tab_idx);
|
||||||
|
|
||||||
@ -1232,7 +1239,7 @@ impl TermWindow {
|
|||||||
let tab = active + delta;
|
let tab = active + delta;
|
||||||
let tab = if tab < 0 { max as isize + tab } else { tab };
|
let tab = if tab < 0 { max as isize + tab } else { tab };
|
||||||
drop(window);
|
drop(window);
|
||||||
self.activate_tab(tab as usize % max)
|
self.activate_tab((tab as usize % max) as isize)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_tab(&mut self, tab_idx: usize) -> anyhow::Result<()> {
|
fn move_tab(&mut self, tab_idx: usize) -> anyhow::Result<()> {
|
||||||
@ -2950,7 +2957,7 @@ impl TermWindow {
|
|||||||
match event.kind {
|
match event.kind {
|
||||||
WMEK::Press(MousePress::Left) => match self.tab_bar.hit_test(x) {
|
WMEK::Press(MousePress::Left) => match self.tab_bar.hit_test(x) {
|
||||||
TabBarItem::Tab(tab_idx) => {
|
TabBarItem::Tab(tab_idx) => {
|
||||||
self.activate_tab(tab_idx).ok();
|
self.activate_tab(tab_idx as isize).ok();
|
||||||
}
|
}
|
||||||
TabBarItem::NewTabButton => {
|
TabBarItem::NewTabButton => {
|
||||||
self.spawn_tab(&SpawnTabDomain::CurrentTabDomain);
|
self.spawn_tab(&SpawnTabDomain::CurrentTabDomain);
|
||||||
|
@ -82,7 +82,7 @@ pub enum KeyAssignment {
|
|||||||
IncreaseFontSize,
|
IncreaseFontSize,
|
||||||
DecreaseFontSize,
|
DecreaseFontSize,
|
||||||
ResetFontSize,
|
ResetFontSize,
|
||||||
ActivateTab(usize),
|
ActivateTab(isize),
|
||||||
SendString(String),
|
SendString(String),
|
||||||
Nop,
|
Nop,
|
||||||
DisableDefaultAssignment,
|
DisableDefaultAssignment,
|
||||||
@ -207,7 +207,7 @@ impl InputMap {
|
|||||||
[KeyModifiers::SUPER, KeyCode::Char('6'), ActivateTab(5)],
|
[KeyModifiers::SUPER, KeyCode::Char('6'), ActivateTab(5)],
|
||||||
[KeyModifiers::SUPER, KeyCode::Char('7'), ActivateTab(6)],
|
[KeyModifiers::SUPER, KeyCode::Char('7'), ActivateTab(6)],
|
||||||
[KeyModifiers::SUPER, KeyCode::Char('8'), ActivateTab(7)],
|
[KeyModifiers::SUPER, KeyCode::Char('8'), ActivateTab(7)],
|
||||||
[KeyModifiers::SUPER, KeyCode::Char('9'), ActivateTab(8)],
|
[KeyModifiers::SUPER, KeyCode::Char('9'), ActivateTab(-1)],
|
||||||
[KeyModifiers::SUPER, KeyCode::Char('w'), CloseCurrentTab],
|
[KeyModifiers::SUPER, KeyCode::Char('w'), CloseCurrentTab],
|
||||||
[ctrl_shift, KeyCode::Char('1'), ActivateTab(0)],
|
[ctrl_shift, KeyCode::Char('1'), ActivateTab(0)],
|
||||||
[ctrl_shift, KeyCode::Char('2'), ActivateTab(1)],
|
[ctrl_shift, KeyCode::Char('2'), ActivateTab(1)],
|
||||||
@ -217,7 +217,7 @@ impl InputMap {
|
|||||||
[ctrl_shift, KeyCode::Char('6'), ActivateTab(5)],
|
[ctrl_shift, KeyCode::Char('6'), ActivateTab(5)],
|
||||||
[ctrl_shift, KeyCode::Char('7'), ActivateTab(6)],
|
[ctrl_shift, KeyCode::Char('7'), ActivateTab(6)],
|
||||||
[ctrl_shift, KeyCode::Char('8'), ActivateTab(7)],
|
[ctrl_shift, KeyCode::Char('8'), ActivateTab(7)],
|
||||||
[ctrl_shift, KeyCode::Char('9'), ActivateTab(8)],
|
[ctrl_shift, KeyCode::Char('9'), ActivateTab(-1)],
|
||||||
[ctrl_shift, KeyCode::Char('W'), CloseCurrentTab],
|
[ctrl_shift, KeyCode::Char('W'), CloseCurrentTab],
|
||||||
[
|
[
|
||||||
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
KeyModifiers::SUPER | KeyModifiers::SHIFT,
|
||||||
|
Loading…
Reference in New Issue
Block a user