The recent work on the scrollback made it easier to constrain the search region, so expose those parameters to the Pane::search interface and to the mux protocol. Use those new parameters to constrain quickselect search to 1000 rows above and below the current viewport by default, and add a new parameter to QuickSelectArgs that allows overriding that range. A follow-up commit could make the search/copy overlay issue a series of searches in chunks so that it avoids blocking the UI when searching very large scrollback. refs: https://github.com/wez/wezterm/pull/1317
2.3 KiB
2.3 KiB
QuickSelectArgs
Since: 20220101-133340-7edc5b5a
Activates Quick Select Mode but with the option to override the global configuration.
This example shows how to pop up a quick select that is scoped solely to a very basic http regex; it will only match those regexes regardless of the default or the quick_select_patterns configuration:
local wezterm = require 'wezterm'
return {
keys = {
{
key = 'P',
mods = 'CTRL',
action = wezterm.action.QuickSelectArgs {
patterns = {
'https?://\\S+',
},
},
},
},
}
The QuickSelectArgs struct allows for the following fields:
patterns- if present, completely overrides the normal set of patterns and uses only the patterns specifiedalphabet- if present, this alphabet is used instead of quick_select_alphabetaction- if present, this key assignment action is performed as if by window:perform_action when an item is selected. The normal clipboard action is NOT performed in this case.label- if present, replaces the string"copy"that is shown at the bottom of the overlay; you can use this to indicate which action will happen if you are usingaction.scope_lines- Specify the number of lines to search above and below the current viewport. The default is 1000 lines. The scope will be increased to the current viewport height if it is smaller than the viewport. (Since: nightly builds only. In earlier releases, the entire scrollback was always searched).
Here's an example that shows how to trigger some lua code to operate on the quick-selected text, instead of copying it to the clipboard. Here, we open the selected URL using the web browser:
local wezterm = require 'wezterm'
return {
keys = {
{
key = 'P',
mods = 'CTRL',
action = wezterm.action.QuickSelectArgs {
label = 'open url',
patterns = {
'https?://\\S+',
},
action = wezterm.action_callback(function(window, pane)
local url = window:get_selection_text_for_pane(pane)
wezterm.log_info('opening: ' .. url)
wezterm.open_with(url)
end),
},
},
},
}
See also wezterm.open_with.