From 55e63d867b2a72b3f554fb00dfd99dae7aab2821 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 21 Jun 2022 09:35:01 -0700 Subject: [PATCH] docs: keyboard encoding refs: https://github.com/wez/wezterm/issues/2152 --- ci/generate-docs.py | 1 + docs/changelog.md | 4 +- docs/config/key-encoding.md | 61 +++++++++++++++++++ .../lua/config/allow_win32_input_mode.md | 16 +++++ .../lua/config/enable_csi_u_key_encoding.md | 22 +++---- .../lua/config/enable_kitty_keyboard.md | 8 +++ 6 files changed, 96 insertions(+), 16 deletions(-) create mode 100644 docs/config/key-encoding.md create mode 100644 docs/config/lua/config/allow_win32_input_mode.md create mode 100644 docs/config/lua/config/enable_kitty_keyboard.md diff --git a/ci/generate-docs.py b/ci/generate-docs.py index 6f826a2d0..84e5166a9 100644 --- a/ci/generate-docs.py +++ b/ci/generate-docs.py @@ -133,6 +133,7 @@ TOC = [ Page("Key Binding", "config/keys.md"), Page("Key Tables", "config/key-tables.md"), Page("Default Key Assignments", "config/default-keys.md"), + Page("Keyboard Encoding", "config/key-encoding.md"), Page("Mouse Binding", "config/mouse.md"), Page("Colors & Appearance", "config/appearance.md"), GenColorScheme("Color Schemes", "colorschemes"), diff --git a/docs/changelog.md b/docs/changelog.md index a37664f2b..cdc5000f7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -14,7 +14,7 @@ As features stabilize some brief notes about them will accumulate here. #### New * [background](config/lua/config/background.md) option for rich background compositing and parallax scrolling effects. * Added [docs for the cli](cli/general.md) -* Support for the [Kitty Keyboard Protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol). Use `enable_kitty_keyboard=true` to enable it. +* Support for the [Kitty Keyboard Protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol). Use [enable_kitty_keyboard](config/lua/config/enable_kitty_keyboard.md)`=true` to enable it. * New [wezterm.mux](config/lua/wezterm.mux/index.md) module, [gui-startup](config/lua/gui-events/gui-startup.md) and [mux-startup](config/lua/mux-events/mux-startup.md) events for spawning programs into your preferred arrangement when wezterm starts. [#674](https://github.com/wez/wezterm/issues/674) * ssh client now supports `BindAddress`. Thanks to [@gpanders](https://github.com/gpanders)! [#1875](https://github.com/wez/wezterm/pull/1875) * [PaneInformation.domain_name](config/lua/PaneInformation.md) and [pane:get_domain_name()](config/lua/pane/get_domain_name.md) which return the name of the domain with which a pane is associated. [#1881](https://github.com/wez/wezterm/issues/1881) @@ -60,7 +60,7 @@ As features stabilize some brief notes about them will accumulate here. * Quickselect no longer jumps to the bottom of the viewport when activated, allowing you to quickselect within the current viewport region * Quickselect now supports multi-line anchors such as `^` and `$`. [#2008](https://github.com/wez/wezterm/issues/2008) * Overriding config using the cli `--config` option will now error out and prevent starting up if unknown config options are specified, or if the value evaluates to `nil`. Unknown options continue to generate warnings (rather than errors) when observed in the config file so that you're not "locked out" of wezterm if you make a typo in the config file. -* Windows: `allow_win32_input_mode` now defaults to `true` and enables using [win32-input-mode](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md) to send high-fidelity keyboard input to ConPTY. This means that win32 console applications, such as [FAR Manager](https://github.com/FarGroup/FarManager) that use the low level `INPUT_RECORD` API will now receive key-up events as well as events for modifier-only key presses. [#1509](https://github.com/wez/wezterm/issues/1509) [#2009](https://github.com/wez/wezterm/issues/2009) [#2098](https://github.com/wez/wezterm/issues/2098) [#1904](https://github.com/wez/wezterm/issues/1904) +* Windows: [allow_win32_input_mode](config/lua/config/allow_win32_input_mode.md) now defaults to `true` and enables using [win32-input-mode](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md) to send high-fidelity keyboard input to ConPTY. This means that win32 console applications, such as [FAR Manager](https://github.com/FarGroup/FarManager) that use the low level `INPUT_RECORD` API will now receive key-up events as well as events for modifier-only key presses. [#1509](https://github.com/wez/wezterm/issues/1509) [#2009](https://github.com/wez/wezterm/issues/2009) [#2098](https://github.com/wez/wezterm/issues/2098) [#1904](https://github.com/wez/wezterm/issues/1904) * Wayland: [enable_wayland](config/lua/config/enable_wayland.md) now defaults to `true`. [#2104](https://github.com/wez/wezterm/issues/2104) * [exit_behavior](config/lua/config/exit_behavior.md) now defaults to `"Close"`. [#2105](https://github.com/wez/wezterm/issues/2105) diff --git a/docs/config/key-encoding.md b/docs/config/key-encoding.md new file mode 100644 index 000000000..d8e2c7217 --- /dev/null +++ b/docs/config/key-encoding.md @@ -0,0 +1,61 @@ +# Keyboard Encoding + +When input that doesn't match a key assignment is processed, it is encoded into +a byte stream and sent to the PTY associated with the program that is running +in the active pane. + +The default encoding scheme used by wezterm is xterm compatible, but there are +some configuration options that can modify the encoding. + +The standard xterm compatible encoding generates events for key presses (but +not releases) and can represent the set of keys that existed on terminal +hardware of the 1980's. + +That scheme has worked well for quite some time, but has some ambiguity due +to the way that the Control modifier "shifts" the ASCII representation of +keypresses like `Control-I` to be ASCII Tab, as an example. + +## CSI-u/fixterms/libtickit + +[Fix Keyboard Input on Terminals](http://www.leonerd.org.uk/hacks/fixterms/) is +an attempt at resolving the ambiguous encoding and doing a better job at +representing more modifiers. It's not a perfect attempt as there are [a number +of issues with +it](https://sw.kovidgoyal.net/kitty/keyboard-protocol/#bugs-in-fixterms). + +You can enable support for this encoding by setting `enable_csi_u_key_encoding += true`, however, it is not recommended as it does change the behavior of some +keys in backwards incompatible ways and there isn't a way for applications to +detect or request this behavior. + +See also: [enable_csi_u_key_encoding](lua/config/enable_csi_u_key_encoding.md). + +Note that [allow_win32_input_mode](lua/config/allow_win32_input_mode.md) takes +precedence over this option. + +## Kitty Keyboard Protocol + +The Kitty terminal extended and enhanced the CSI-u based encoding scheme with +its [Comprehensive keyboard handling +protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/). + +The kitty protocol allows applications to request varying degrees of +enhancement over the standard encoding scheme and also allows for more modifier +keys (notably: `CMD`/`Super`/`Windows`) to be reported to the application. + +[enable_kitty_keyboard](lua/config/enable_kitty_keyboard.md) controls whether +wezterm will honor the application requests to modify the keyboard encoding. + +## Windows + +On Windows, [allow_win32_input_mode](lua/config/allow_win32_input_mode.md) +defaults to `true` which causes wezterm to listen for an escape sequence +generated by the ConPTY layer of Windows to enable [Win32 Input Mode](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md). + +In this mode, key release events as well as events that can distinguish between +positional (left/right) modifier keys are generated and this mode provides the +best compatibility with win32 console applications such as Far Manager. + +`allow_win32_input_mode` takes precedence over +[enable_csi_u_key_encoding](lua/config/enable_csi_u_key_encoding.md). + diff --git a/docs/config/lua/config/allow_win32_input_mode.md b/docs/config/lua/config/allow_win32_input_mode.md new file mode 100644 index 000000000..2e2924d8f --- /dev/null +++ b/docs/config/lua/config/allow_win32_input_mode.md @@ -0,0 +1,16 @@ +# `allow_win32_input_mode` + +*Since: 20220319-142410-0fcdea07* + +When set to `true`, wezterm will honor an escape sequence generated by the +Windows ConPTY layer to switch the [keyboard encoding](../../key-encoding.md) +to a proprietary scheme that has maximum compatibility with win32 console +applications. + +See also [Improved Keyboard Handling in ConPTY](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md). + +*Since: nightly builds only* + +The default for `allow_win32_input_mode` is now true. + + diff --git a/docs/config/lua/config/enable_csi_u_key_encoding.md b/docs/config/lua/config/enable_csi_u_key_encoding.md index a02f8f54f..843fbf64c 100644 --- a/docs/config/lua/config/enable_csi_u_key_encoding.md +++ b/docs/config/lua/config/enable_csi_u_key_encoding.md @@ -1,20 +1,14 @@ # `enable_csi_u_key_encoding = false` -This option affects how key presses are fed to the terminal; after processing -any key binding assignments, if the key didn't match an assignment it is passed -down to the terminal which then encodes the key press as a byte sequence to -send to the application running in the terminal. +When set to `true`, the [keyboard encoding](../../key-encoding.md) will be +changed to use the scheme that is [described +here](http://www.leonerd.org.uk/hacks/fixterms/). -By default, wezterm aims to be compatible with the encoding used by `xterm`. - -In that encoding scheme there are some key combinations that have an ambiguous -representation. - -Setting `enable_csi_u_key_encoding = true` will switch to an alternative -encoding scheme that is [described here](http://www.leonerd.org.uk/hacks/fixterms/) -that removes the ambiguity in a mostly-backwards-compatible way, but that -requires that applications also know about this encoding scheme to have -the best results. +It is not recommended to enable this option as it does change the behavior of +some keys in backwards incompatible ways and there isn't a way for applications +to detect or request this behavior. The default for this option is `false`. +Note that [allow_win32_input_mode](allow_win32_input_mode.md) takes +precedence over this option. diff --git a/docs/config/lua/config/enable_kitty_keyboard.md b/docs/config/lua/config/enable_kitty_keyboard.md new file mode 100644 index 000000000..f3c0250a0 --- /dev/null +++ b/docs/config/lua/config/enable_kitty_keyboard.md @@ -0,0 +1,8 @@ +# `enable_kitty_keyboard = false` + +*Since: nightly builds only* + +When set to `true`, wezterm will honor kitty keyboard protocol escape +sequences that modify the [keyboard encoding](../../key-encoding.md). + +