PaneSelect: add SwapWithActiveKeepFocus

refs: #3014
This commit is contained in:
Wez Furlong committed 2023-08-24 22:32:19 -07:00
1 parent a9c7d28b09
commit 53988c7fe6
6 files changed
+47 -13

No files matched your search

+1
View File
@@ -333,6 +333,7 @@ impl Default for ClipboardPasteSource {
pub enum PaneSelectMode {
Activate,
SwapWithActive,
SwapWithActiveKeepFocus,
MoveToNewTab,
MoveToNewWindow,
}
+3 -3
View File
@@ -27,9 +27,9 @@ As features stabilize some brief notes about them will accumulate here.
their own new Short Codes section.
* CharSelect now shows emoji variations such as skin tones
* Improved fuzzy matching performance in CharSelect
* [PaneSelect](config/lua/keyassignment/PaneSelect.md) new modes `MoveToNewTab`
and `MoveToNewWindow`, as well as `show_pane_ids=true` to show the pane ids.
#4147
* [PaneSelect](config/lua/keyassignment/PaneSelect.md) new modes `MoveToNewTab`,
`MoveToNewWindow`, and `SwapWithActiveKeepFocus`, as well as
`show_pane_ids=true` to show the pane ids. #4147 #3014
#### New
* [wezterm imgcat](cli/imgcat.md) now has `--position`, `--no-move-cursor` and
+12 -4
View File
@@ -15,16 +15,24 @@ action.
The available actions are:
* `mode="Activate"` - activate the selected pane. This is the default mode.
* `mode="SwapWithActive"` - swap the position of the active pane with the selected pane
* `mode="SwapWithActive"` - swap the position of the active pane with the
selected pane, switching focus to the selected pane
The selection alphabet defaults to the same value as [quick_select_alphabet](../config/quick_select_alphabet.md), but can be explicitly via the `alphabet` field:
The selection alphabet defaults to the same value as
[quick_select_alphabet](../config/quick_select_alphabet.md), but can be
explicitly via the `alphabet` field:
{{since('nightly')}}
Additional modes are now supported:
* `mode="MoveToNewTab"` - moves the selected pane into a new tab in the same window, and activates it
* `mode="MoveToNewWindow"` - moves the selected pane into a new window, and activates it
* `mode="MoveToNewTab"` - moves the selected pane into a new tab in the same
window, and activates it
* `mode="MoveToNewWindow"` - moves the selected pane into a new window, and
activates it
* `mode="SwapWithActiveKeepFocus"` - swap the position of the active pane with
the selected pane, retaining focus on the currently active pane but in its
new position
You may now also set `show_pane_ids=true` to show the pane id alongside the label.
+10 -4
View File
@@ -714,8 +714,10 @@ impl Tab {
}
/// Swap the active pane with the specified pane_index
pub fn swap_active_with_index(&self, pane_index: usize) -> Option<()> {
self.inner.lock().swap_active_with_index(pane_index)
pub fn swap_active_with_index(&self, pane_index: usize, keep_focus: bool) -> Option<()> {
self.inner
.lock()
.swap_active_with_index(pane_index, keep_focus)
}
/// Computes the size of the pane that would result if the specified
@@ -1776,7 +1778,7 @@ impl TabInner {
cell_dimensions(&self.size)
}
fn swap_active_with_index(&mut self, pane_index: usize) -> Option<()> {
fn swap_active_with_index(&mut self, pane_index: usize, keep_focus: bool) -> Option<()> {
let active_idx = self.get_active_idx();
let mut pane = self.get_active_pane()?;
log::trace!(
@@ -1822,7 +1824,11 @@ impl TabInner {
}
// And update focus
self.advise_focus_change(Some(pane));
if keep_focus {
self.set_active_idx(pane_index);
} else {
self.advise_focus_change(Some(pane));
}
None
}
+16
View File
@@ -819,6 +819,17 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Comm
menubar: &["Window"],
icon: Some("cod_multiple_windows"),
},
PaneSelect(PaneSelectArguments {
mode: PaneSelectMode::SwapWithActiveKeepFocus,
..
}) => CommandDef {
brief: "Swap a pane with the active pane, keeping focus".into(),
doc: "Activates the pane selection UI".into(),
keys: vec![], // FIXME: find a new assignment
args: &[ArgType::ActivePane],
menubar: &["Window"],
icon: Some("cod_multiple_windows"),
},
PaneSelect(PaneSelectArguments {
mode: PaneSelectMode::MoveToNewTab,
..
@@ -2017,6 +2028,11 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
mode: PaneSelectMode::SwapWithActive,
show_pane_ids: false,
}),
PaneSelect(PaneSelectArguments {
alphabet: String::new(),
mode: PaneSelectMode::SwapWithActiveKeepFocus,
show_pane_ids: false,
}),
PaneSelect(PaneSelectArguments {
alphabet: String::new(),
mode: PaneSelectMode::MoveToNewTab,
+5 -2
View File
@@ -179,8 +179,11 @@ impl PaneSelector {
tab.set_active_idx(pane_index);
}
}
PaneSelectMode::SwapWithActive => {
tab.swap_active_with_index(pane_index);
PaneSelectMode::SwapWithActiveKeepFocus | PaneSelectMode::SwapWithActive => {
tab.swap_active_with_index(
pane_index,
self.mode == PaneSelectMode::SwapWithActiveKeepFocus,
);
}
PaneSelectMode::MoveToNewWindow => {
if let Some(pos) = panes.iter().find(|p| p.index == pane_index) {