diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs index 54a99b289..9bb4b110b 100644 --- a/config/src/keyassignment.rs +++ b/config/src/keyassignment.rs @@ -205,6 +205,8 @@ pub enum KeyAssignment { CloseCurrentPane { confirm: bool }, EmitEvent(String), QuickSelect, + + Multiple(Vec), } impl_lua_conversion!(KeyAssignment); diff --git a/docs/changelog.md b/docs/changelog.md index 23bc97528..4f89b8a91 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -29,6 +29,7 @@ As features stabilize some brief notes about them will accumulate here. * New: Added [SendKey](config/lua/keyassignment/SendKey.md) key assignment action that makes it more convenient to rebind the key input that is sent to a pane. * Fixed: Crash due to Out of Memory condition when the iTerm2 protocol was used to send excessively large PNG files [#1031](https://github.com/wez/wezterm/issues/1031) * Fixed: `DCH` sequence would remove cells and replace them with default-blank cells instead of blank-cells-with-current-bg-color. [#789](https://github.com/wez/wezterm/issues/789) +* New: Added [Multiple](config/lua/keyassignment/Multiple.md) key assignment action for combining multuple actions in a single press. ### 20210814-124438-54e29167 diff --git a/docs/config/lua/keyassignment/Multiple.md b/docs/config/lua/keyassignment/Multiple.md new file mode 100644 index 000000000..ee4ebd808 --- /dev/null +++ b/docs/config/lua/keyassignment/Multiple.md @@ -0,0 +1,21 @@ +# Multiple + +*Since: nightly builds only* + +Performs a sequence of multiple assignments. This is useful when you +want a single key press to trigger multiple actions. + +The example below causes `LeftArrow` to effectively type `left`: + +```lua +return { + keys = { + {key="LeftArrow", action={Multiple={ + {SendKey={key="l"}}, + {SendKey={key="e"}}, + {SendKey={key="f"}}, + {SendKey={key="t"}}, + }}} + } +} +``` diff --git a/docs/config/lua/keyassignment/SendKey.md b/docs/config/lua/keyassignment/SendKey.md index f3e941b60..117b9d551 100644 --- a/docs/config/lua/keyassignment/SendKey.md +++ b/docs/config/lua/keyassignment/SendKey.md @@ -18,7 +18,6 @@ shells and applications. The following configuration achieves that same effect: ```lua -local wezterm = require 'wezterm'; return { keys = { -- Rebind OPT-Left, OPT-Right as ALT-b, ALT-f respectively to match Terminal.app behavior @@ -27,3 +26,5 @@ return { } } ``` + +See also [Multiple](Multiple.md) for combining multiple actions in a single press. diff --git a/docs/config/lua/keyassignment/SendString.md b/docs/config/lua/keyassignment/SendString.md index 2d63ecb04..3fd346e58 100644 --- a/docs/config/lua/keyassignment/SendString.md +++ b/docs/config/lua/keyassignment/SendString.md @@ -32,4 +32,5 @@ return { } ``` -See also [SendKey](SendKey.md) which makes the example above much more convenient. +See also [SendKey](SendKey.md) which makes the example above much more convenient, +and [Multiple](Multiple.md) for combining multiple actions in a single press. diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index cdc2ca3e7..a04fe3c57 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1669,6 +1669,11 @@ impl TermWindow { let window = self.window.as_ref().map(|w| w.clone()); match assignment { + Multiple(actions) => { + for a in actions { + self.perform_key_assignment(pane, a)?; + } + } SpawnTab(spawn_where) => { self.spawn_tab(spawn_where); }