Files
LLeMbas-TTY/docs/config/lua/keyassignment/ClearSelection.md
T
Wez Furlong 0f8146b212 docs: shift from return {} style to config.something style
Nudge new users towards using this style:

```lua
local config = {}
config.color_scheme = 'Batman'
return config
```

and surface how to write lua modules closer to the main section
on config files. In that lua modules section, nudge towards using
a convention similar to that of the plugin spec described in
this commit: e4ae8a844d
2023-03-19 18:26:21 -07:00

32 lines
827 B
Markdown

# ClearSelection
*Since: 20220624-141144-bd1b7c5d*
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'
local act = wezterm.action
config.keys = {
{
key = 'c',
mods = 'CTRL',
action = wezterm.action_callback(function(window, pane)
local has_selection = window:get_selection_text_for_pane(pane) ~= ''
if has_selection then
window:perform_action(act.CopyTo 'ClipboardAndPrimarySelection', pane)
window:perform_action(act.ClearSelection, pane)
else
window:perform_action(act.SendKey { key = 'c', mods = 'CTRL' }, pane)
end
end),
},
}
```