mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
parent
46fc05a746
commit
dd16e586c3
@ -22,7 +22,7 @@ usually the best available version.
|
||||
As features stabilize some brief notes about them will accumulate here.
|
||||
|
||||
#### New
|
||||
* Not yet
|
||||
* [pane:activate()](config/lua/pane/activate.md) and [tab:activate()](config/lua/MuxTab/activate.md). #3217
|
||||
|
||||
### 20230326-111934-3666303c
|
||||
|
||||
|
6
docs/config/lua/MuxTab/activate.md
Normal file
6
docs/config/lua/MuxTab/activate.md
Normal file
@ -0,0 +1,6 @@
|
||||
# `tab:activate()`
|
||||
|
||||
{{since('nightly')}}
|
||||
|
||||
Activates (focuses) the tab.
|
||||
|
5
docs/config/lua/pane/activate.md
Normal file
5
docs/config/lua/pane/activate.md
Normal file
@ -0,0 +1,5 @@
|
||||
# `pane:activate()`
|
||||
|
||||
{{since('nightly')}}
|
||||
|
||||
Activates (focuses) the pane and its containing tab.
|
@ -379,6 +379,30 @@ impl UserData for MuxPane {
|
||||
Ok((MuxTab(tab.tab_id()), MuxWindow(window)))
|
||||
},
|
||||
);
|
||||
|
||||
methods.add_method("activate", move |_lua, this, ()| {
|
||||
let mux = Mux::get();
|
||||
let pane = this.resolve(&mux)?;
|
||||
let (_domain_id, window_id, tab_id) = mux
|
||||
.resolve_pane_id(this.0)
|
||||
.ok_or_else(|| mlua::Error::external(format!("pane {} not found", this.0)))?;
|
||||
{
|
||||
let mut window = mux.get_window_mut(window_id).ok_or_else(|| {
|
||||
mlua::Error::external(format!("window {window_id} not found"))
|
||||
})?;
|
||||
let tab_idx = window.idx_by_id(tab_id).ok_or_else(|| {
|
||||
mlua::Error::external(format!(
|
||||
"tab {tab_id} isn't really in window {window_id}!?"
|
||||
))
|
||||
})?;
|
||||
window.save_and_then_set_active(tab_idx);
|
||||
}
|
||||
let tab = mux
|
||||
.get_tab(tab_id)
|
||||
.ok_or_else(|| mlua::Error::external(format!("tab {tab_id} not found")))?;
|
||||
tab.set_active_pane(&pane);
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,5 +124,31 @@ impl UserData for MuxTab {
|
||||
let tab = this.resolve(&mux)?;
|
||||
to_lua(lua, tab.get_size())
|
||||
});
|
||||
|
||||
methods.add_method("activate", move |_lua, this, ()| {
|
||||
let mux = Mux::get();
|
||||
let tab = this.resolve(&mux)?;
|
||||
|
||||
let pane = tab.get_active_pane().ok_or_else(|| {
|
||||
mlua::Error::external(format!("tab {} has no active pane!?", this.0))
|
||||
})?;
|
||||
|
||||
let (_domain_id, window_id, tab_id) =
|
||||
mux.resolve_pane_id(pane.pane_id()).ok_or_else(|| {
|
||||
mlua::Error::external(format!("pane {} not found", pane.pane_id()))
|
||||
})?;
|
||||
{
|
||||
let mut window = mux.get_window_mut(window_id).ok_or_else(|| {
|
||||
mlua::Error::external(format!("window {window_id} not found"))
|
||||
})?;
|
||||
let tab_idx = window.idx_by_id(tab_id).ok_or_else(|| {
|
||||
mlua::Error::external(format!(
|
||||
"tab {tab_id} isn't really in window {window_id}!?"
|
||||
))
|
||||
})?;
|
||||
window.save_and_then_set_active(tab_idx);
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user