From 809bb5338729e35dfc813ad6c29c4d63bdd487a3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 10 Oct 2020 08:40:14 -0700 Subject: [PATCH] docs: split out the KeyAssignment enum variants This makes the individual functions a bit easier to discover, and a lot easier to link to. --- .gitignore | 1 + ci/generate-docs.py | 47 +- docs/config/keys.markdown | 517 +----------------- .../lua/keyassignment/ActivateCopyMode.md | 8 + docs/config/lua/keyassignment/ActivateTab.md | 36 ++ .../lua/keyassignment/ActivateTabRelative.md | 17 + .../lua/keyassignment/ClearScrollback.md | 14 + .../lua/keyassignment/CloseCurrentTab.md | 15 + .../lua/keyassignment/CompleteSelection.md | 7 + ...ompleteSelectionOrOpenLinkAtMouseCursor.md | 7 + docs/config/lua/keyassignment/Copy.md | 15 + .../lua/keyassignment/DecreaseFontSize.md | 14 + .../keyassignment/DisableDefaultAssignment.md | 18 + .../ExtendSelectionToMouseCursor.md | 26 + docs/config/lua/keyassignment/Hide.md | 13 + .../lua/keyassignment/HideApplication.md | 13 + .../lua/keyassignment/IncreaseFontSize.md | 14 + docs/config/lua/keyassignment/MoveTab.md | 25 + .../lua/keyassignment/MoveTabRelative.md | 17 + docs/config/lua/keyassignment/Nop.md | 15 + .../keyassignment/OpenLinkAtMouseCursor.md | 6 + docs/config/lua/keyassignment/Paste.md | 15 + .../keyassignment/PastePrimarySelection.md | 15 + .../lua/keyassignment/QuitApplication.md | 13 + .../lua/keyassignment/ReloadConfiguration.md | 13 + .../config/lua/keyassignment/ResetFontSize.md | 14 + docs/config/lua/keyassignment/ScrollByPage.md | 17 + docs/config/lua/keyassignment/Search.md | 28 + .../keyassignment/SelectTextAtMouseCursor.md | 7 + docs/config/lua/keyassignment/SendString.md | 34 ++ docs/config/lua/keyassignment/Show.md | 4 + docs/config/lua/keyassignment/ShowLauncher.md | 14 + .../lua/keyassignment/ShowTabNavigator.md | 15 + .../lua/keyassignment/SpawnCommandInNewTab.md | 28 + .../keyassignment/SpawnCommandInNewWindow.md | 28 + docs/config/lua/keyassignment/SpawnTab.md | 19 + docs/config/lua/keyassignment/SpawnWindow.md | 14 + .../lua/keyassignment/ToggleFullScreen.md | 14 + docs/config/lua/wezterm/action.md | 12 +- 39 files changed, 623 insertions(+), 526 deletions(-) create mode 100644 docs/config/lua/keyassignment/ActivateCopyMode.md create mode 100644 docs/config/lua/keyassignment/ActivateTab.md create mode 100644 docs/config/lua/keyassignment/ActivateTabRelative.md create mode 100644 docs/config/lua/keyassignment/ClearScrollback.md create mode 100644 docs/config/lua/keyassignment/CloseCurrentTab.md create mode 100644 docs/config/lua/keyassignment/CompleteSelection.md create mode 100644 docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md create mode 100644 docs/config/lua/keyassignment/Copy.md create mode 100644 docs/config/lua/keyassignment/DecreaseFontSize.md create mode 100644 docs/config/lua/keyassignment/DisableDefaultAssignment.md create mode 100644 docs/config/lua/keyassignment/ExtendSelectionToMouseCursor.md create mode 100644 docs/config/lua/keyassignment/Hide.md create mode 100644 docs/config/lua/keyassignment/HideApplication.md create mode 100644 docs/config/lua/keyassignment/IncreaseFontSize.md create mode 100644 docs/config/lua/keyassignment/MoveTab.md create mode 100644 docs/config/lua/keyassignment/MoveTabRelative.md create mode 100644 docs/config/lua/keyassignment/Nop.md create mode 100644 docs/config/lua/keyassignment/OpenLinkAtMouseCursor.md create mode 100644 docs/config/lua/keyassignment/Paste.md create mode 100644 docs/config/lua/keyassignment/PastePrimarySelection.md create mode 100644 docs/config/lua/keyassignment/QuitApplication.md create mode 100644 docs/config/lua/keyassignment/ReloadConfiguration.md create mode 100644 docs/config/lua/keyassignment/ResetFontSize.md create mode 100644 docs/config/lua/keyassignment/ScrollByPage.md create mode 100644 docs/config/lua/keyassignment/Search.md create mode 100644 docs/config/lua/keyassignment/SelectTextAtMouseCursor.md create mode 100644 docs/config/lua/keyassignment/SendString.md create mode 100644 docs/config/lua/keyassignment/Show.md create mode 100644 docs/config/lua/keyassignment/ShowLauncher.md create mode 100644 docs/config/lua/keyassignment/ShowTabNavigator.md create mode 100644 docs/config/lua/keyassignment/SpawnCommandInNewTab.md create mode 100644 docs/config/lua/keyassignment/SpawnCommandInNewWindow.md create mode 100644 docs/config/lua/keyassignment/SpawnTab.md create mode 100644 docs/config/lua/keyassignment/SpawnWindow.md create mode 100644 docs/config/lua/keyassignment/ToggleFullScreen.md diff --git a/.gitignore b/.gitignore index 3ba8422e7..44c35fe88 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ /docs/config/lua/wezterm/index.md /docs/config/lua/pane/index.md /docs/config/lua/window/index.md +/docs/config/lua/keyassignment/index.md **/*.rs.bk .*.sw* /esctest.log diff --git a/ci/generate-docs.py b/ci/generate-docs.py index 48da34e38..e7a535a00 100644 --- a/ci/generate-docs.py +++ b/ci/generate-docs.py @@ -91,7 +91,10 @@ TOC = [ "Lua Reference", "config/lua/general.md", children=[ - Gen("module: wezterm", "config/lua/wezterm", index=""" + Gen( + "module: wezterm", + "config/lua/wezterm", + index=""" # `require wezterm` The wezterm module is the primary module that exposes wezterm configuration @@ -106,8 +109,35 @@ local wezterm = require 'wezterm'; at the top of your configuration file to enable it. ## Available functions, constants -"""), - Gen("object: Pane", "config/lua/pane", index=""" +""", + ), + Gen( + "enum: KeyAssignment", + "config/lua/keyassignment", + index=""" +# `KeyAssignment` enumeration + +A `KeyAssignment` represents a pre-defined function that can be applied +to control the Window, Tab, Pane state typically when a key or mouse event +is triggered. + +Internally, in the underlying Rust code, `KeyAssignment` is an enum +type with a variant for each possible action known to wezterm. In Lua, +enums get represented as a table with a single key corresponding to +the variant name. + +In most cases the [`wezterm.action`](../wezterm/action.md) function is +used to create an instance of `KeyAssignment` and make it a bit more +clear and convenient. + +## Available Key Assignments + +""", + ), + Gen( + "object: Pane", + "config/lua/pane", + index=""" # `Pane` object A Pane object cannot be created in lua code; it is typically passed to your @@ -121,8 +151,12 @@ introspect the state of the terminal emulation for that pane. ## Available methods -"""), - Gen("object: Window", "config/lua/window", index=""" +""", + ), + Gen( + "object: Window", + "config/lua/window", + index=""" # `Window` object A Window object cannot be created in lua code; it is typically passed to @@ -131,7 +165,8 @@ TermWindow running in the wezterm process. ## Available methods -"""), +""", + ), ], ), ], diff --git a/docs/config/keys.markdown b/docs/config/keys.markdown index d1d0c2a7c..a49ccfd77 100644 --- a/docs/config/keys.markdown +++ b/docs/config/keys.markdown @@ -289,519 +289,8 @@ Possible Modifier labels are: You can combine modifiers using the `|` symbol (eg: `"CMD|CTRL"`). -# Possible Actions +# Available Actions -Possible actions are listed below. +See the [`KeyAssignment` reference](lua/keyassignment/index.md) for information +on available actions. -## SpawnTab - -Create a new tab in the current window. The argument defines to which *domain* the tab belongs: - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - -- Create a new tab in the default domain - {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab="DefaultDomain"}}, - -- Create a new tab in the same domain as the current tab - {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab="CurrentPaneDomain"}}, - -- Create a tab in a named domain - {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab={DomainName="unix"}}}, - } -} -``` - -## SpawnWindow - -Create a new window containing a tab from the default tab domain. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="n", mods="SHIFT|CTRL", action="SpawnWindow"}, - } -} -``` - -## SpawnCommandInNewWindow / SpawnCommandInNewTab - -Spawn a new tab either into the current window or into a brand new window. -The argument controls which command is run in the tab; it is a lua table -with the following fields: - -* `args` - the argument array specifying the command and its arguments. - If omitted, the default program will be run. -* `cwd` - the current working directory to set for the command. -* `set_environment_variables` - a table specifying key/value pairs to - set in the environment -* `domain` - specifies the domain into which the tab will be spawned. - See `SpawnTab` for examples. - -```lua -local wezterm = require 'wezterm'; - -return { - keys = { - -- CMD-y starts `top` in a new window - {key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={ - args={"top"} - }}}, - } -} -``` - -## ToggleFullScreen - -Toggles full screen mode for the current window. (But see: -) - -```lua -return { - keys = { - {key="n", mods="SHIFT|CTRL", action="ToggleFullScreen"}, - } -} -``` - -## Copy - -Copy the selection to the clipboard. On X11 systems, this populates both the -Clipboard and the Primary Selection. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="c", mods="SHIFT|CTRL", action="Copy"}, - } -} -``` - -## Paste - -Paste the clipboard to the current tab. On X11 systems, this copies from the -Clipboard rather than the Primary Selection. See also `PastePrimarySelection`. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="v", mods="SHIFT|CTRL", action="Paste"}, - } -} -``` - -## PastePrimarySelection - -X11: Paste the Primary Selection to the current tab. -On other systems, this behaves identically to `Paste`. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="v", mods="SHIFT|CTRL", action="PastePrimarySelection"}, - } -} -``` - -## ActivateTabRelative - -Activate a tab relative to the current tab. The argument value specifies an -offset. eg: `-1` activates the tab to the left of the current tab, while `1` -activates the tab to the right. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="{", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=-1}}, - {key="}", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=1}}, - } -} -``` - -## ActivateTab - -Activate the tab specified by the argument value. eg: `0` activates the -leftmost tab, while `1` activates the second tab from the left, and so on. - -*since: 20200620-160318-e00b076c* - -`ActivateTab` now accepts negative numbers; these wrap around from the start -of the tabs to the end, so `-1` references the right-most tab, `-2` the tab -to its left and so on. - - -```lua -local wezterm = require 'wezterm'; - -local mykeys = {} -for i = 1, 8 do - -- CTRL+ALT + number to activate that tab - table.insert(mykeys, { - key=tostring(i), - mods="CTRL|ALT", - action=wezterm.action{ActivateTab=i-1}, - }) - -- F1 through F8 to activate that tab - table.insert(mykeys, { - key="F" .. tostring(i), - action=wezterm.action{ActivateTab=i-1}, - }) -end - -return { - keys = mykeys, -} -``` - -## IncreaseFontSize - -Increases the font size of the current window by 10% - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="=", mods="CTRL", action="IncreaseFontSize"}, - } -} -``` - -## DecreaseFontSize - -Decreases the font size of the current window by 10% - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="-", mods="CTRL", action="DecreaseFontSize"}, - } -} -``` - -## ResetFontSize - -Reset the font size for the current window to the value in your configuration - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="0", mods="CTRL", action="ResetFontSize"}, - } -} -``` - -## SendString - -Sends the string specified argument to the terminal in the current tab, as -though that text were literally typed into the terminal. - -```lua -local wezterm = require 'wezterm'; - -return { - keys = { - {key="m", mods="CMD", action=wezterm.action{SendString="Hello"}}, - } -} -``` - -You can also emit escape sequences using `SendString`. This example shows -how to bind Alt-LeftArrow/RightArrow to the Alt-b/f, an emacs style -keybinding for moving backwards/forwards through a word in a line editor. - -`\x1b` is the ESC character: - -```lua -local wezterm = require 'wezterm'; - -return { - keys = { - -- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word - {key="LeftArrow", mods="OPT", action=wezterm.action{SendString="\x1bb"}}, - -- Make Option-Right equivalent to Alt-f; forward-word - {key="RightArrow", mods="OPT", action=wezterm.action{SendString="\x1bf"}}, - } -} -``` - -## DisableDefaultAssignment - -Has no special meaning of its own; this action will undo the registration -of a default assignment if that key/mouse/modifier combination is one of the -default assignments and cause the key press to be propagated through -to the tab for processing. - -```lua -return { - keys = { - -- Turn off the default CMD-m Hide action, allowing CMD-m to - -- be potentially recognized and handled by the tab - {key="m", mods="CMD", action="DisableDefaultAssignment"}, - } -} -``` - -## Nop - -Causes the key press to have no effect; it behaves as though those -keys were not pressed. - -```lua -return { - keys = { - -- Turn off any side effects from pressing CMD-m - {key="m", mods="CMD", action="Nop"}, - } -} -``` - -## Hide - -Hides the current window - -```lua -return { - keys = { - {key="h", mods="CMD", action="Hide"}, - } -} -``` - -## HideApplication - -On macOS, hide the WezTerm application. - -```lua -return { - keys = { - {key="h", mods="CMD", action="HideApplication"}, - } -} -``` - -## QuitApplication - -Terminate the WezTerm application, killing all tabs. - -```lua -return { - keys = { - {key="q", mods="CMD", action="QuitApplication"}, - } -} -``` - -## Show - -Shows the current window. - -## CloseCurrentTab - -Equivalent to clicking the `x` on the window title bar to close it: Closes the -current tab. If that was the last tab, closes that window. If that was the -last window, wezterm terminates. - -```lua -return { - keys = { - {key="w", mods="CMD", action="CloseCurrentTab"}, - } -} -``` - -## MoveTabRelative - -Move the current tab relative to its peers. The argument specifies an -offset. eg: `-1` moves the tab to the left of the current tab, while `1` moves -the tab to the right. - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - {key="{", mods="SHIFT|ALT", action=wezterm.action{MoveTabRelative=-1}}, - {key="}", mods="SHIFT|ALT", action=wezterm.action{MoveTabRelative=1}}, - } -} -``` - -## MoveTab - -Move the tab so that it has the index specified by the argument. eg: `0` -moves the tab to be leftmost, while `1` moves the tab so that it is second tab -from the left, and so on. - -```lua -local wezterm = require 'wezterm'; - -local mykeys = {} -for i = 1, 8 do - -- CTRL+ALT + number to move to that position - table.insert(mykeys, { - key=tostring(i), - mods="CTRL|ALT", - action=wezterm.action{Move=i-1}, - }) -end - -return { - keys = mykeys, -} -``` - -## ScrollByPage - -Adjusts the scroll position by the number of pages specified by the argument. -Negative values scroll upwards, while positive values scroll downwards. - -```lua -local wezterm = require 'wezterm'; - -return { - keys = { - {key="PageUp", mods="SHIFT", action=wezterm.action{ScrollByPage=-1}}, - {key="PageDown", mods="SHIFT", action=wezterm.action{ScrollByPage=1}}, - } -} -``` - -## ClearScrollback - -Clears the lines that have scrolled off the top of the viewport, resetting -the scrollbar thumb to the full height of the window. - -```lua -return { - keys = { - {key="K", mods="CTRL|SHIFT", action="ClearScrollback"} - } -} -``` - -## ReloadConfiguration - -Explicitly reload the configuration. - -```lua -return { - keys = { - {key="r", mods="CMD|SHIFT", action="ReloadConfiguration"}, - } -} -``` - -## ShowLauncher - -Activate the [Launcher Menu](launch.html#the-launcher-menu) -in the current tab. - -```lua -return { - keys = { - {key="l", mods="ALT", action="ShowLauncher"}, - } -} -``` - -## ShowTabNavigator - -Activate the tab navigator UI in the current tab. The tab -navigator displays a list of tabs and allows you to select -and activate a tab from that list. - -```lua -return { - keys = { - {key="F9", mods="ALT", action="ShowTabNavigator"}, - } -} -``` - -## SelectTextAtMouseCursor - -Initiates selection of text at the current mouse cursor position. -The mode argument can be one of `Cell`, `Word` or `Line` to control -the scope of the selection. - -## ExtendSelectionToMouseCursor - -Extends the current text selection to the current mouse cursor position. -The mode argument can be one of `Cell`, `Word` or `Line` to control -the scope of the selection. - -It is also possible to leave the mode unspecified like this: - -```lua -return { - mouse_bindings = { - { - event={Up={streak=1, button="Left"}}, - mods="SHIFT", - -- Note that there is no `wezterm.action` here - action={ExtendSelectionToMouseCursor={}}, - }, - } -} -``` - -when unspecified, wezterm will use a default mode which at the time -of writing is `Cell`, but in a future release may be context sensitive -based on recent actions. - -## OpenLinkAtMouseCursor - -If the current mouse cursor position is over a cell that contains -a hyperlink, this action causes that link to be opened. - -## CompleteSelection - -Completes an active text selection process; the selection range is -marked closed and then the selected text is copied as though the -`Copy` action was executed. - -## CompleteSelectionOrOpenLinkAtMouseCursor - -If a selection is in progress, acts as though `CompleteSelection` was -triggered. Otherwise acts as though `OpenLinkAtMouseCursor` was -triggered. - -## Search - -*since: 20200607-144723-74889cd4* - -This action will trigger the search overlay for the current tab. -It accepts a typed pattern string as its parameter, allowing for -`Regex`, `CaseSensitiveString` and `CaseInSensitiveString` as -pattern matching types. - -The supported [regular expression syntax is described -here](https://docs.rs/regex/1.3.9/regex/#syntax). - - -```lua -local wezterm = require 'wezterm'; -return { - keys = { - -- search for things that look like git hashes - {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={Regex="[a-f0-9]{6,}"}}}, - -- search for the lowercase string "hash" matching the case exactly - {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={CaseSensitiveString="hash"}}}, - -- search for the string "hash" matching regardless of case - {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={CaseInSensitiveString="hash"}}}, - }, -} -``` - -## ActivateCopyMode - -*since: 20200607-144723-74889cd4* - -Activates copy mode! - -[Learn more about copy mode](../copymode.html) diff --git a/docs/config/lua/keyassignment/ActivateCopyMode.md b/docs/config/lua/keyassignment/ActivateCopyMode.md new file mode 100644 index 000000000..c9a1bd624 --- /dev/null +++ b/docs/config/lua/keyassignment/ActivateCopyMode.md @@ -0,0 +1,8 @@ +# ActivateCopyMode + +*since: 20200607-144723-74889cd4* + +Activates copy mode! + +[Learn more about copy mode](../copymode.html) + diff --git a/docs/config/lua/keyassignment/ActivateTab.md b/docs/config/lua/keyassignment/ActivateTab.md new file mode 100644 index 000000000..61c9297d0 --- /dev/null +++ b/docs/config/lua/keyassignment/ActivateTab.md @@ -0,0 +1,36 @@ +# ActivateTab + +Activate the tab specified by the argument value. eg: `0` activates the +leftmost tab, while `1` activates the second tab from the left, and so on. + +*since: 20200620-160318-e00b076c* + +`ActivateTab` now accepts negative numbers; these wrap around from the start +of the tabs to the end, so `-1` references the right-most tab, `-2` the tab +to its left and so on. + + +```lua +local wezterm = require 'wezterm'; + +local mykeys = {} +for i = 1, 8 do + -- CTRL+ALT + number to activate that tab + table.insert(mykeys, { + key=tostring(i), + mods="CTRL|ALT", + action=wezterm.action{ActivateTab=i-1}, + }) + -- F1 through F8 to activate that tab + table.insert(mykeys, { + key="F" .. tostring(i), + action=wezterm.action{ActivateTab=i-1}, + }) +end + +return { + keys = mykeys, +} +``` + + diff --git a/docs/config/lua/keyassignment/ActivateTabRelative.md b/docs/config/lua/keyassignment/ActivateTabRelative.md new file mode 100644 index 000000000..6f600bc45 --- /dev/null +++ b/docs/config/lua/keyassignment/ActivateTabRelative.md @@ -0,0 +1,17 @@ +# ActivateTabRelative + +Activate a tab relative to the current tab. The argument value specifies an +offset. eg: `-1` activates the tab to the left of the current tab, while `1` +activates the tab to the right. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="{", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=-1}}, + {key="}", mods="SHIFT|ALT", action=wezterm.action{ActivateTabRelative=1}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ClearScrollback.md b/docs/config/lua/keyassignment/ClearScrollback.md new file mode 100644 index 000000000..19853533c --- /dev/null +++ b/docs/config/lua/keyassignment/ClearScrollback.md @@ -0,0 +1,14 @@ +# ClearScrollback + +Clears the lines that have scrolled off the top of the viewport, resetting +the scrollbar thumb to the full height of the window. + +```lua +return { + keys = { + {key="K", mods="CTRL|SHIFT", action="ClearScrollback"} + } +} +``` + + diff --git a/docs/config/lua/keyassignment/CloseCurrentTab.md b/docs/config/lua/keyassignment/CloseCurrentTab.md new file mode 100644 index 000000000..86e63e627 --- /dev/null +++ b/docs/config/lua/keyassignment/CloseCurrentTab.md @@ -0,0 +1,15 @@ +# CloseCurrentTab + +Equivalent to clicking the `x` on the window title bar to close it: Closes the +current tab. If that was the last tab, closes that window. If that was the +last window, wezterm terminates. + +```lua +return { + keys = { + {key="w", mods="CMD", action="CloseCurrentTab"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/CompleteSelection.md b/docs/config/lua/keyassignment/CompleteSelection.md new file mode 100644 index 000000000..5c000402a --- /dev/null +++ b/docs/config/lua/keyassignment/CompleteSelection.md @@ -0,0 +1,7 @@ +# CompleteSelection + +Completes an active text selection process; the selection range is +marked closed and then the selected text is copied as though the +`Copy` action was executed. + + diff --git a/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md b/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md new file mode 100644 index 000000000..aaccc8109 --- /dev/null +++ b/docs/config/lua/keyassignment/CompleteSelectionOrOpenLinkAtMouseCursor.md @@ -0,0 +1,7 @@ +# CompleteSelectionOrOpenLinkAtMouseCursor + +If a selection is in progress, acts as though `CompleteSelection` was +triggered. Otherwise acts as though `OpenLinkAtMouseCursor` was +triggered. + + diff --git a/docs/config/lua/keyassignment/Copy.md b/docs/config/lua/keyassignment/Copy.md new file mode 100644 index 000000000..d62a2466a --- /dev/null +++ b/docs/config/lua/keyassignment/Copy.md @@ -0,0 +1,15 @@ +# Copy + +Copy the selection to the clipboard. On X11 systems, this populates both the +Clipboard and the Primary Selection. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="c", mods="SHIFT|CTRL", action="Copy"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/DecreaseFontSize.md b/docs/config/lua/keyassignment/DecreaseFontSize.md new file mode 100644 index 000000000..20daa5417 --- /dev/null +++ b/docs/config/lua/keyassignment/DecreaseFontSize.md @@ -0,0 +1,14 @@ +# DecreaseFontSize + +Decreases the font size of the current window by 10% + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="-", mods="CTRL", action="DecreaseFontSize"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/DisableDefaultAssignment.md b/docs/config/lua/keyassignment/DisableDefaultAssignment.md new file mode 100644 index 000000000..4940552cc --- /dev/null +++ b/docs/config/lua/keyassignment/DisableDefaultAssignment.md @@ -0,0 +1,18 @@ +# DisableDefaultAssignment + +Has no special meaning of its own; this action will undo the registration +of a default assignment if that key/mouse/modifier combination is one of the +default assignments and cause the key press to be propagated through +to the tab for processing. + +```lua +return { + keys = { + -- Turn off the default CMD-m Hide action, allowing CMD-m to + -- be potentially recognized and handled by the tab + {key="m", mods="CMD", action="DisableDefaultAssignment"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ExtendSelectionToMouseCursor.md b/docs/config/lua/keyassignment/ExtendSelectionToMouseCursor.md new file mode 100644 index 000000000..a77903b30 --- /dev/null +++ b/docs/config/lua/keyassignment/ExtendSelectionToMouseCursor.md @@ -0,0 +1,26 @@ +# ExtendSelectionToMouseCursor + +Extends the current text selection to the current mouse cursor position. +The mode argument can be one of `Cell`, `Word` or `Line` to control +the scope of the selection. + +It is also possible to leave the mode unspecified like this: + +```lua +return { + mouse_bindings = { + { + event={Up={streak=1, button="Left"}}, + mods="SHIFT", + -- Note that there is no `wezterm.action` here + action={ExtendSelectionToMouseCursor={}}, + }, + } +} +``` + +when unspecified, wezterm will use a default mode which at the time +of writing is `Cell`, but in a future release may be context sensitive +based on recent actions. + + diff --git a/docs/config/lua/keyassignment/Hide.md b/docs/config/lua/keyassignment/Hide.md new file mode 100644 index 000000000..f33b83ec0 --- /dev/null +++ b/docs/config/lua/keyassignment/Hide.md @@ -0,0 +1,13 @@ +# Hide + +Hides the current window + +```lua +return { + keys = { + {key="h", mods="CMD", action="Hide"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/HideApplication.md b/docs/config/lua/keyassignment/HideApplication.md new file mode 100644 index 000000000..5a6765ead --- /dev/null +++ b/docs/config/lua/keyassignment/HideApplication.md @@ -0,0 +1,13 @@ +# HideApplication + +On macOS, hide the WezTerm application. + +```lua +return { + keys = { + {key="h", mods="CMD", action="HideApplication"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/IncreaseFontSize.md b/docs/config/lua/keyassignment/IncreaseFontSize.md new file mode 100644 index 000000000..5bb529b4b --- /dev/null +++ b/docs/config/lua/keyassignment/IncreaseFontSize.md @@ -0,0 +1,14 @@ +# IncreaseFontSize + +Increases the font size of the current window by 10% + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="=", mods="CTRL", action="IncreaseFontSize"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/MoveTab.md b/docs/config/lua/keyassignment/MoveTab.md new file mode 100644 index 000000000..e8c26f7a4 --- /dev/null +++ b/docs/config/lua/keyassignment/MoveTab.md @@ -0,0 +1,25 @@ +# MoveTab + +Move the tab so that it has the index specified by the argument. eg: `0` +moves the tab to be leftmost, while `1` moves the tab so that it is second tab +from the left, and so on. + +```lua +local wezterm = require 'wezterm'; + +local mykeys = {} +for i = 1, 8 do + -- CTRL+ALT + number to move to that position + table.insert(mykeys, { + key=tostring(i), + mods="CTRL|ALT", + action=wezterm.action{Move=i-1}, + }) +end + +return { + keys = mykeys, +} +``` + + diff --git a/docs/config/lua/keyassignment/MoveTabRelative.md b/docs/config/lua/keyassignment/MoveTabRelative.md new file mode 100644 index 000000000..2d3d1b834 --- /dev/null +++ b/docs/config/lua/keyassignment/MoveTabRelative.md @@ -0,0 +1,17 @@ +# MoveTabRelative + +Move the current tab relative to its peers. The argument specifies an +offset. eg: `-1` moves the tab to the left of the current tab, while `1` moves +the tab to the right. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="{", mods="SHIFT|ALT", action=wezterm.action{MoveTabRelative=-1}}, + {key="}", mods="SHIFT|ALT", action=wezterm.action{MoveTabRelative=1}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/Nop.md b/docs/config/lua/keyassignment/Nop.md new file mode 100644 index 000000000..b9b318a7a --- /dev/null +++ b/docs/config/lua/keyassignment/Nop.md @@ -0,0 +1,15 @@ +# Nop + +Causes the key press to have no effect; it behaves as though those +keys were not pressed. + +```lua +return { + keys = { + -- Turn off any side effects from pressing CMD-m + {key="m", mods="CMD", action="Nop"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/OpenLinkAtMouseCursor.md b/docs/config/lua/keyassignment/OpenLinkAtMouseCursor.md new file mode 100644 index 000000000..cc1055cd9 --- /dev/null +++ b/docs/config/lua/keyassignment/OpenLinkAtMouseCursor.md @@ -0,0 +1,6 @@ +# OpenLinkAtMouseCursor + +If the current mouse cursor position is over a cell that contains +a hyperlink, this action causes that link to be opened. + + diff --git a/docs/config/lua/keyassignment/Paste.md b/docs/config/lua/keyassignment/Paste.md new file mode 100644 index 000000000..6c7478e8b --- /dev/null +++ b/docs/config/lua/keyassignment/Paste.md @@ -0,0 +1,15 @@ +# Paste + +Paste the clipboard to the current tab. On X11 systems, this copies from the +Clipboard rather than the Primary Selection. See also `PastePrimarySelection`. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="v", mods="SHIFT|CTRL", action="Paste"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/PastePrimarySelection.md b/docs/config/lua/keyassignment/PastePrimarySelection.md new file mode 100644 index 000000000..cf303cdc0 --- /dev/null +++ b/docs/config/lua/keyassignment/PastePrimarySelection.md @@ -0,0 +1,15 @@ +# PastePrimarySelection + +X11: Paste the Primary Selection to the current tab. +On other systems, this behaves identically to `Paste`. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="v", mods="SHIFT|CTRL", action="PastePrimarySelection"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/QuitApplication.md b/docs/config/lua/keyassignment/QuitApplication.md new file mode 100644 index 000000000..8befa076a --- /dev/null +++ b/docs/config/lua/keyassignment/QuitApplication.md @@ -0,0 +1,13 @@ +# QuitApplication + +Terminate the WezTerm application, killing all tabs. + +```lua +return { + keys = { + {key="q", mods="CMD", action="QuitApplication"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ReloadConfiguration.md b/docs/config/lua/keyassignment/ReloadConfiguration.md new file mode 100644 index 000000000..c98827cb8 --- /dev/null +++ b/docs/config/lua/keyassignment/ReloadConfiguration.md @@ -0,0 +1,13 @@ +# ReloadConfiguration + +Explicitly reload the configuration. + +```lua +return { + keys = { + {key="r", mods="CMD|SHIFT", action="ReloadConfiguration"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ResetFontSize.md b/docs/config/lua/keyassignment/ResetFontSize.md new file mode 100644 index 000000000..c31b1a3c2 --- /dev/null +++ b/docs/config/lua/keyassignment/ResetFontSize.md @@ -0,0 +1,14 @@ +# ResetFontSize + +Reset the font size for the current window to the value in your configuration + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="0", mods="CTRL", action="ResetFontSize"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ScrollByPage.md b/docs/config/lua/keyassignment/ScrollByPage.md new file mode 100644 index 000000000..7dbe24c81 --- /dev/null +++ b/docs/config/lua/keyassignment/ScrollByPage.md @@ -0,0 +1,17 @@ +# ScrollByPage + +Adjusts the scroll position by the number of pages specified by the argument. +Negative values scroll upwards, while positive values scroll downwards. + +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + {key="PageUp", mods="SHIFT", action=wezterm.action{ScrollByPage=-1}}, + {key="PageDown", mods="SHIFT", action=wezterm.action{ScrollByPage=1}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/Search.md b/docs/config/lua/keyassignment/Search.md new file mode 100644 index 000000000..e9cb4721b --- /dev/null +++ b/docs/config/lua/keyassignment/Search.md @@ -0,0 +1,28 @@ +# Search + +*since: 20200607-144723-74889cd4* + +This action will trigger the search overlay for the current tab. +It accepts a typed pattern string as its parameter, allowing for +`Regex`, `CaseSensitiveString` and `CaseInSensitiveString` as +pattern matching types. + +The supported [regular expression syntax is described +here](https://docs.rs/regex/1.3.9/regex/#syntax). + + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + -- search for things that look like git hashes + {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={Regex="[a-f0-9]{6,}"}}}, + -- search for the lowercase string "hash" matching the case exactly + {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={CaseSensitiveString="hash"}}}, + -- search for the string "hash" matching regardless of case + {key="H", mods="SHIFT|CTRL", action=wezterm.action{Search={CaseInSensitiveString="hash"}}}, + }, +} +``` + + diff --git a/docs/config/lua/keyassignment/SelectTextAtMouseCursor.md b/docs/config/lua/keyassignment/SelectTextAtMouseCursor.md new file mode 100644 index 000000000..2c0f4f454 --- /dev/null +++ b/docs/config/lua/keyassignment/SelectTextAtMouseCursor.md @@ -0,0 +1,7 @@ +# SelectTextAtMouseCursor + +Initiates selection of text at the current mouse cursor position. +The mode argument can be one of `Cell`, `Word` or `Line` to control +the scope of the selection. + + diff --git a/docs/config/lua/keyassignment/SendString.md b/docs/config/lua/keyassignment/SendString.md new file mode 100644 index 000000000..6107c0c0a --- /dev/null +++ b/docs/config/lua/keyassignment/SendString.md @@ -0,0 +1,34 @@ +# SendString + +Sends the string specified argument to the terminal in the current tab, as +though that text were literally typed into the terminal. + +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + {key="m", mods="CMD", action=wezterm.action{SendString="Hello"}}, + } +} +``` + +You can also emit escape sequences using `SendString`. This example shows +how to bind Alt-LeftArrow/RightArrow to the Alt-b/f, an emacs style +keybinding for moving backwards/forwards through a word in a line editor. + +`\x1b` is the ESC character: + +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + -- Make Option-Left equivalent to Alt-b which many line editors interpret as backward-word + {key="LeftArrow", mods="OPT", action=wezterm.action{SendString="\x1bb"}}, + -- Make Option-Right equivalent to Alt-f; forward-word + {key="RightArrow", mods="OPT", action=wezterm.action{SendString="\x1bf"}}, + } +} +``` + diff --git a/docs/config/lua/keyassignment/Show.md b/docs/config/lua/keyassignment/Show.md new file mode 100644 index 000000000..ffd847d9d --- /dev/null +++ b/docs/config/lua/keyassignment/Show.md @@ -0,0 +1,4 @@ +# Show + +Shows the current window. + diff --git a/docs/config/lua/keyassignment/ShowLauncher.md b/docs/config/lua/keyassignment/ShowLauncher.md new file mode 100644 index 000000000..449c6964d --- /dev/null +++ b/docs/config/lua/keyassignment/ShowLauncher.md @@ -0,0 +1,14 @@ +# ShowLauncher + +Activate the [Launcher Menu](launch.html#the-launcher-menu) +in the current tab. + +```lua +return { + keys = { + {key="l", mods="ALT", action="ShowLauncher"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ShowTabNavigator.md b/docs/config/lua/keyassignment/ShowTabNavigator.md new file mode 100644 index 000000000..ee9130381 --- /dev/null +++ b/docs/config/lua/keyassignment/ShowTabNavigator.md @@ -0,0 +1,15 @@ +# ShowTabNavigator + +Activate the tab navigator UI in the current tab. The tab +navigator displays a list of tabs and allows you to select +and activate a tab from that list. + +```lua +return { + keys = { + {key="F9", mods="ALT", action="ShowTabNavigator"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/SpawnCommandInNewTab.md b/docs/config/lua/keyassignment/SpawnCommandInNewTab.md new file mode 100644 index 000000000..cf081c94c --- /dev/null +++ b/docs/config/lua/keyassignment/SpawnCommandInNewTab.md @@ -0,0 +1,28 @@ +## SpawnCommandInNewTab + +Spawn a new tab into the current window. +The argument controls which command is run in the tab; it is a lua table +with the following fields: + +* `args` - the argument array specifying the command and its arguments. + If omitted, the default program will be run. +* `cwd` - the current working directory to set for the command. +* `set_environment_variables` - a table specifying key/value pairs to + set in the environment +* `domain` - specifies the domain into which the tab will be spawned. + See `SpawnTab` for examples. + +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + -- CMD-y starts `top` in a new window + {key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={ + args={"top"} + }}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/SpawnCommandInNewWindow.md b/docs/config/lua/keyassignment/SpawnCommandInNewWindow.md new file mode 100644 index 000000000..6a9830ca0 --- /dev/null +++ b/docs/config/lua/keyassignment/SpawnCommandInNewWindow.md @@ -0,0 +1,28 @@ +# SpawnCommandInNewWindow + +Spawn a new tab into a brand new window. +The argument controls which command is run in the tab; it is a lua table +with the following fields: + +* `args` - the argument array specifying the command and its arguments. + If omitted, the default program will be run. +* `cwd` - the current working directory to set for the command. +* `set_environment_variables` - a table specifying key/value pairs to + set in the environment +* `domain` - specifies the domain into which the tab will be spawned. + See `SpawnTab` for examples. + +```lua +local wezterm = require 'wezterm'; + +return { + keys = { + -- CMD-y starts `top` in a new window + {key="y", mods="CMD", action=wezterm.action{SpawnCommandInNewWindow={ + args={"top"} + }}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/SpawnTab.md b/docs/config/lua/keyassignment/SpawnTab.md new file mode 100644 index 000000000..848f005df --- /dev/null +++ b/docs/config/lua/keyassignment/SpawnTab.md @@ -0,0 +1,19 @@ +# SpawnTab + +Create a new tab in the current window. The argument defines to which *domain* the tab belongs: + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + -- Create a new tab in the default domain + {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab="DefaultDomain"}}, + -- Create a new tab in the same domain as the current tab + {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab="CurrentPaneDomain"}}, + -- Create a tab in a named domain + {key="t", mods="SHIFT|ALT", action=wezterm.action{SpawnTab={DomainName="unix"}}}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/SpawnWindow.md b/docs/config/lua/keyassignment/SpawnWindow.md new file mode 100644 index 000000000..afce3c788 --- /dev/null +++ b/docs/config/lua/keyassignment/SpawnWindow.md @@ -0,0 +1,14 @@ +# SpawnWindow + +Create a new window containing a tab from the default tab domain. + +```lua +local wezterm = require 'wezterm'; +return { + keys = { + {key="n", mods="SHIFT|CTRL", action="SpawnWindow"}, + } +} +``` + + diff --git a/docs/config/lua/keyassignment/ToggleFullScreen.md b/docs/config/lua/keyassignment/ToggleFullScreen.md new file mode 100644 index 000000000..9f08bb2bd --- /dev/null +++ b/docs/config/lua/keyassignment/ToggleFullScreen.md @@ -0,0 +1,14 @@ +# ToggleFullScreen + +Toggles full screen mode for the current window. (But see: +) + +```lua +return { + keys = { + {key="n", mods="SHIFT|CTRL", action="ToggleFullScreen"}, + } +} +``` + + diff --git a/docs/config/lua/wezterm/action.md b/docs/config/lua/wezterm/action.md index 71e8e02c4..c72415797 100644 --- a/docs/config/lua/wezterm/action.md +++ b/docs/config/lua/wezterm/action.md @@ -17,10 +17,10 @@ return { } ``` -The parameter is a lua representation of the underlying -[KeyAssignment](https://github.com/wez/wezterm/blob/master/config/src/keyassignment.rs#L114) -enum from the configuration code. These docs aim to spell out sufficient -examples that you shouldn't need to learn to read Rust code, but there -are occasions where newly developed features are not yet documented and -an enterprising user may wish to go spelunking to figure them out! +The parameter is a lua representation of the underlying KeyAssignment enum from +the configuration code. These docs aim to spell out sufficient examples that +you shouldn't need to learn to read Rust code, but there are occasions where +newly developed features are not yet documented and an enterprising user may +wish to go spelunking to figure them out! +[You can find the reference for available KeyAssignment values here](../keyassignment/index.md).