This commit refactors the keyboard enhancements functionality by
splitting the `WithKeyboardEnhancements` function into three separate
functions:
- `WithKeyReleases`: Enables support for reporting key release events.
- `WithUniformKeyLayout`: Enables support for reporting key events in a
uniform layout format.
- `RequestKeyDisambiguation`: Enables support for disambiguated key events.
This change improves clarity and usability by allowing users to enable
specific keyboard enhancements individually, rather than requiring them
to use a single function with multiple options.
Right now, there is inconsistencies between Windows and other
*nix platforms when it comes to keyboard enhancement handling.
Since we use the Windows Console API on Windows, we always get
disambiguated keys and release events.
To make the experience consistent across platforms, we always enable
disambiguated keys for *nix platforms, and we ignore release events on
Windows unless they are explicitly requested, the same way we do for
*nix platforms.
This change exposes the `KeyboardEnhancements` type and tracks requested
and active enhancements in the `Program` struct. This change also
renames the `KeyboardEnhancement` type to `KeyboardEnhancementOption`
and `keyboardEnhancements` to `KeyboardEnhancements` as well as
`EnableKeyboardEnhancements` to `RequestKeyboardEnhancements`.
This uses kitty keyboard protocol "Report alternate keys" and "Report
all keys as escape codes" to report key events as though they were on a
PC-101 layout. This is useful for uniform key event reporting across
different keyboard layouts.
* feat: combine keyboard enhancements into a nicer API
This change combines the keyboard enhancements into a nicer API. Kitty
keyboard protocol and XTerm modifyOtherKeys are now combined into a
single API. This makes it easier to enable keyboard enhancements.
Use `WithKeyboardEnhancements` to enable keyboard enhancements. This
function accepts a list of `KeyboardEnhancement` functions that can be
used to enable different keyboard features.
For now, we only support the `WithReleaseKeys` enhancement which enables
support for reporting release key events.
* Update options.go
Co-authored-by: Christian Rocha <christian@rocha.is>
* chore: go mod tidy
* chore: gofumpt
* fix: simplify keyboard enhancements disambiguation
* feat: make KeyboardEnhancementsMsg helpers always return true on Windows
* fix: remove unused win32input mode
* refactor: rename KeyboardEnhancementsMsg methods
---------
Co-authored-by: Christian Rocha <christian@rocha.is>