2022-04-21 17:56:35 +03:00
|
|
|
# ClearSelection
|
|
|
|
|
2022-06-25 00:58:18 +03:00
|
|
|
*Since: 20220624-141144-bd1b7c5d*
|
2022-04-21 17:56:35 +03:00
|
|
|
|
|
|
|
Clears the selection in the current pane.
|
|
|
|
|
|
|
|
This example shows how to rebind `CTRL-C` to copy to the clipboard
|
|
|
|
when there is a selection present (clearing it afterwards) or sending
|
|
|
|
CTRL-C to the terminal when there is no selection:
|
|
|
|
|
|
|
|
```lua
|
|
|
|
local wezterm = require 'wezterm'
|
2022-06-25 16:58:10 +03:00
|
|
|
local act = wezterm.action
|
2022-04-21 17:56:35 +03:00
|
|
|
|
|
|
|
return {
|
|
|
|
keys = {
|
|
|
|
{
|
2022-07-19 17:54:31 +03:00
|
|
|
key = 'c',
|
|
|
|
mods = 'CTRL',
|
2022-04-21 17:56:35 +03:00
|
|
|
action = wezterm.action_callback(function(window, pane)
|
2022-07-19 17:54:31 +03:00
|
|
|
local has_selection = window:get_selection_text_for_pane(pane) ~= ''
|
2022-04-21 17:56:35 +03:00
|
|
|
if has_selection then
|
|
|
|
window:perform_action(
|
2022-07-19 17:54:31 +03:00
|
|
|
act.CopyTo 'ClipboardAndPrimarySelection',
|
2022-07-19 16:58:38 +03:00
|
|
|
pane
|
2022-06-25 20:59:17 +03:00
|
|
|
)
|
2022-04-21 17:56:35 +03:00
|
|
|
|
2022-06-25 20:59:17 +03:00
|
|
|
window:perform_action(act.ClearSelection, pane)
|
2022-04-21 17:56:35 +03:00
|
|
|
else
|
|
|
|
window:perform_action(
|
2022-07-19 17:54:31 +03:00
|
|
|
act.SendKey { key = 'c', mods = 'CTRL' },
|
2022-07-19 16:58:38 +03:00
|
|
|
pane
|
2022-06-25 20:59:17 +03:00
|
|
|
)
|
2022-04-21 17:56:35 +03:00
|
|
|
end
|
2022-07-19 17:54:31 +03:00
|
|
|
end),
|
|
|
|
},
|
|
|
|
},
|
2022-04-21 17:56:35 +03:00
|
|
|
}
|
|
|
|
```
|