1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-20 11:17:15 +03:00

quickselect: allow changing label for custom actions

This commit is contained in:
Wez Furlong 2021-12-23 16:32:20 -07:00
parent b1c58b9376
commit 38087755e1
3 changed files with 11 additions and 1 deletions

View File

@ -159,6 +159,9 @@ pub struct QuickSelectArguments {
pub patterns: Vec<String>,
#[serde(default)]
pub action: Option<Box<KeyAssignment>>,
/// Label to use in place of "copy" when `action` is set
#[serde(default)]
pub label: String,
}
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq)]

View File

@ -31,6 +31,7 @@ The `QuickSelectArgs` struct allows for the following fields:
* `patterns` - if present, completely overrides the normal set of patterns and uses only the patterns specified
* `alphabet` - if present, this alphabet is used instead of [quick_select_alphabet](../config/quick_select_alphabet.md)
* `action` - if present, this key assignment action is performed as if by [window:perform_action](../window/perform_action.md) 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 using `action`.
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
@ -43,6 +44,7 @@ return {
keys = {
{key="P", mods="CTRL",
action=wezterm.action{QuickSelectArgs={
label = "open url",
patterns={
"https?://\\S+"
},

View File

@ -464,8 +464,13 @@ impl Pane for QuickSelectOverlay {
line.overlay_text_with_attribute(
0,
&format!(
"Select: {} (type highlighted prefix to copy, uppercase pastes, ESC to cancel)",
"Select: {} (type highlighted prefix to {}, uppercase pastes, ESC to cancel)",
renderer.selection,
if renderer.args.label.is_empty() {
"copy"
} else {
&renderer.args.label
},
),
rev,
SEQ_ZERO,