PaneSelect: MoveToNewTab, MoveToNewWindow and show_pane_ids
refs: #4147
This commit is contained in:
5 files changed
+111
-4
No files matched your search
@@ -333,6 +333,8 @@ impl Default for ClipboardPasteSource {
|
||||
pub enum PaneSelectMode {
|
||||
Activate,
|
||||
SwapWithActive,
|
||||
MoveToNewTab,
|
||||
MoveToNewWindow,
|
||||
}
|
||||
|
||||
impl Default for PaneSelectMode {
|
||||
@@ -349,6 +351,9 @@ pub struct PaneSelectArguments {
|
||||
|
||||
#[dynamic(default)]
|
||||
pub mode: PaneSelectMode,
|
||||
|
||||
#[dynamic(default)]
|
||||
pub show_pane_ids: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromDynamic, ToDynamic)]
|
||||
|
||||
@@ -27,6 +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
|
||||
|
||||
#### New
|
||||
* [wezterm imgcat](cli/imgcat.md) now has `--position`, `--no-move-cursor` and
|
||||
|
||||
@@ -19,6 +19,15 @@ The available actions are:
|
||||
|
||||
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
|
||||
|
||||
You may now also set `show_pane_ids=true` to show the pane id alongside the label.
|
||||
|
||||
```lua
|
||||
local wezterm = require 'wezterm'
|
||||
local act = wezterm.action
|
||||
|
||||
@@ -797,7 +797,10 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Comm
|
||||
menubar: &["Edit"],
|
||||
icon: Some("md_sticker_emoji"),
|
||||
},
|
||||
PaneSelect(_) => CommandDef {
|
||||
PaneSelect(PaneSelectArguments {
|
||||
mode: PaneSelectMode::Activate,
|
||||
..
|
||||
}) => CommandDef {
|
||||
brief: "Enter Pane selection mode".into(),
|
||||
doc: "Activates the pane selection UI".into(),
|
||||
keys: vec![], // FIXME: find a new assignment
|
||||
@@ -805,6 +808,39 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Comm
|
||||
menubar: &["Window"],
|
||||
icon: Some("cod_multiple_windows"),
|
||||
},
|
||||
PaneSelect(PaneSelectArguments {
|
||||
mode: PaneSelectMode::SwapWithActive,
|
||||
..
|
||||
}) => CommandDef {
|
||||
brief: "Swap a pane with the active pane".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,
|
||||
..
|
||||
}) => CommandDef {
|
||||
brief: "Move a pane into its own tab".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::MoveToNewWindow,
|
||||
..
|
||||
}) => CommandDef {
|
||||
brief: "Move a pane into its own window".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"),
|
||||
},
|
||||
DecreaseFontSize => CommandDef {
|
||||
brief: "Decrease font size".into(),
|
||||
doc: "Scales the font size smaller by 10%".into(),
|
||||
@@ -1971,7 +2007,26 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
|
||||
ToggleFullScreen,
|
||||
Hide,
|
||||
Search(Pattern::CurrentSelectionOrEmptyString),
|
||||
PaneSelect(PaneSelectArguments::default()),
|
||||
PaneSelect(PaneSelectArguments {
|
||||
alphabet: String::new(),
|
||||
mode: PaneSelectMode::Activate,
|
||||
show_pane_ids: false,
|
||||
}),
|
||||
PaneSelect(PaneSelectArguments {
|
||||
alphabet: String::new(),
|
||||
mode: PaneSelectMode::SwapWithActive,
|
||||
show_pane_ids: false,
|
||||
}),
|
||||
PaneSelect(PaneSelectArguments {
|
||||
alphabet: String::new(),
|
||||
mode: PaneSelectMode::MoveToNewTab,
|
||||
show_pane_ids: false,
|
||||
}),
|
||||
PaneSelect(PaneSelectArguments {
|
||||
alphabet: String::new(),
|
||||
mode: PaneSelectMode::MoveToNewWindow,
|
||||
show_pane_ids: false,
|
||||
}),
|
||||
RotatePanes(RotationDirection::Clockwise),
|
||||
RotatePanes(RotationDirection::CounterClockwise),
|
||||
ActivateTab(0),
|
||||
|
||||
@@ -20,6 +20,7 @@ pub struct PaneSelector {
|
||||
alphabet: String,
|
||||
mode: PaneSelectMode,
|
||||
was_zoomed: bool,
|
||||
show_pane_ids: bool,
|
||||
}
|
||||
|
||||
impl PaneSelector {
|
||||
@@ -45,12 +46,14 @@ impl PaneSelector {
|
||||
alphabet,
|
||||
mode: args.mode,
|
||||
was_zoomed,
|
||||
show_pane_ids: args.show_pane_ids,
|
||||
}
|
||||
}
|
||||
|
||||
fn compute(
|
||||
term_window: &mut TermWindow,
|
||||
alphabet: &str,
|
||||
show_pane_ids: bool,
|
||||
) -> anyhow::Result<(Vec<ComputedElement>, Vec<String>)> {
|
||||
let font = term_window
|
||||
.fonts
|
||||
@@ -73,7 +76,11 @@ impl PaneSelector {
|
||||
|
||||
let mut elements = vec![];
|
||||
for pos in panes {
|
||||
let caption = labels[pos.index].clone();
|
||||
let caption = if show_pane_ids {
|
||||
format!("{}: {}", labels[pos.index], pos.pane.pane_id())
|
||||
} else {
|
||||
labels[pos.index].clone()
|
||||
};
|
||||
let element = Element::new(&font, ElementContent::Text(caption))
|
||||
.colors(ElementColors {
|
||||
border: BorderColor::new(
|
||||
@@ -175,6 +182,34 @@ impl PaneSelector {
|
||||
PaneSelectMode::SwapWithActive => {
|
||||
tab.swap_active_with_index(pane_index);
|
||||
}
|
||||
PaneSelectMode::MoveToNewWindow => {
|
||||
if let Some(pos) = panes.iter().find(|p| p.index == pane_index) {
|
||||
let pane_id = pos.pane.pane_id();
|
||||
promise::spawn::spawn(async move {
|
||||
if let Err(err) = mux.move_pane_to_new_tab(pane_id, None, None).await {
|
||||
log::error!("failed to move_pane_to_new_tab: {err:#}");
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
PaneSelectMode::MoveToNewTab => {
|
||||
if let Some(pos) = panes.iter().find(|p| p.index == pane_index) {
|
||||
let pane_id = pos.pane.pane_id();
|
||||
let window_id = term_window.mux_window_id;
|
||||
promise::spawn::spawn(async move {
|
||||
if let Err(err) = mux
|
||||
.move_pane_to_new_tab(pane_id, Some(window_id), None)
|
||||
.await
|
||||
{
|
||||
log::error!("failed to move_pane_to_new_tab: {err:#}");
|
||||
}
|
||||
|
||||
mux.focus_pane_and_containing_tab(pane_id).ok();
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,7 +277,7 @@ impl Modal for PaneSelector {
|
||||
term_window: &mut TermWindow,
|
||||
) -> anyhow::Result<Ref<[ComputedElement]>> {
|
||||
if self.element.borrow().is_none() {
|
||||
let (element, labels) = Self::compute(term_window, &self.alphabet)?;
|
||||
let (element, labels) = Self::compute(term_window, &self.alphabet, self.show_pane_ids)?;
|
||||
self.element.borrow_mut().replace(element);
|
||||
*self.labels.borrow_mut() = labels;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user