add window:active_workspace()

refs: #1531
refs: https://github.com/wez/wezterm/discussions/1322#discussioncomment-1984256
This commit is contained in:
Wez Furlong committed 2022-01-17 09:11:06 -07:00
1 parent 91c684b702
commit e8900d47cd
3 files changed
+30

No files matched your search

+1
View File
@@ -22,6 +22,7 @@ As features stabilize some brief notes about them will accumulate here.
* `Symbols Nerd Font Mono` is now bundled with WezTerm and is included as a default fallback font. This means that you may use any of the glyphs available in the [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts) collection with any font without patching fonts and without explicitly adding that font to your fallback list. Pomicons have an unclear license for distribution and are excluded from this bundled font, however, you may manually install the font with those icons from the Nerd Font site itself and it will take precedence over the bundled font. This font replaces the older `PowerlineExtraSymbols` font. [#1521](https://github.com/wez/wezterm/issues/1521).
* [wezterm.nerdfonts](config/lua/wezterm/nerdfonts.md) as a convenient way to resolve Nerd Fonts glyphs by name in your config file
* [ShowLauncherArgs](config/lua/keyassignment/ShowLauncherArgs.md) key assignment to show the launcher scoped to certain items, or to launch it directly in fuzzy matching mode
* Workspaces. Follow work in progress on [#1531](https://github.com/wez/wezterm/issues/1531) and [#1322](https://github.com/wez/wezterm/discussions/1322)! [window:active_workspace()](config/lua/window/active_workspace.md)
#### Changed
@@ -0,0 +1,22 @@
# window:active_workspace()
*Since: nightly builds only*
Returns the name of the active workspace.
This example demonstrates using the launcher menu to select and create workspaces,
and how the workspace can be shown in the right status area.
```lua
local wezterm = require 'wezterm'
wezterm.on("update-right-status", function(window, pane)
window:set_right_status(window:active_workspace())
end)
return {
keys = {
{key="9", mods="ALT", action=wezterm.action{ShowLauncherArgs={flags="FUZZY|WORKSPACES"}}},
},
}
```
+7
View File
@@ -7,6 +7,7 @@ use config::keyassignment::KeyAssignment;
use luahelper::*;
use mlua::{UserData, UserDataMethods};
use mux::window::WindowId as MuxWindowId;
use mux::Mux;
use serde::*;
use wezterm_toast_notification::ToastNotification;
use window::{Connection, ConnectionOps, DeadKeyStatus, WindowOps, WindowState};
@@ -164,5 +165,11 @@ impl UserData for GuiWin {
Ok(result)
});
methods.add_method("active_workspace", |_, _, _: ()| {
let mux = Mux::get()
.ok_or_else(|| anyhow::anyhow!("must be called on main thread"))
.map_err(luaerr)?;
Ok(mux.active_workspace().to_string())
});
}
}