Commit graph

18 commits

Author SHA1 Message Date
Ayman Bagabas
05df5aecf8
feat: support extended keyboard enhancements (#1626)
This adds support for the Kitty keyboard protocol's extended
enhancements, allowing applications to request that the terminal report
additional information about key events, such as whether they're part of
a repeat sequence, alternate key values, and associated text.

Supersedes: https://github.com/charmbracelet/bubbletea/pull/1622
Fixes: https://github.com/charmbracelet/bubbletea/issues/1621
Fixes: https://github.com/charmbracelet/bubbletea/issues/1623
2026-04-07 11:03:32 -04:00
Ayman Bagabas
94247ed8f1
feat: add SupportsKeyDisambiguation to KeyboardEnhancementsMsg 2025-11-12 10:59:13 -05:00
Ayman Bagabas
3780c0e8b1
docs: update keyboard enhancement flags comment 2025-11-12 10:57:19 -05:00
Ayman Bagabas
f03c467c1b
refactor: keyboard enhancements api improvements (#1534) 2025-11-06 12:22:22 -05:00
Ayman Bagabas
b947ade70d
refactor: change several message types to structs for extensibility 2025-11-04 14:01:26 -05:00
Ayman Bagabas
d97f20b234
fix: use uint8 for KeyboardEnhancementsMsg 2025-10-15 11:44:02 -04:00
Ayman Bagabas
f0c5a2ddc4
fix: remove unnecessary key disambiguation support check 2025-10-14 16:16:54 -04:00
Ayman Bagabas
bd747e7bfa
refactor: clean up redundant code and update testdata 2025-10-01 13:50:38 -04:00
Ayman Bagabas
59b04aaa42
fix: remove enhanced keyboard windows special casing 2025-09-09 16:36:28 -04:00
Ayman Bagabas
99a80e67ee
feat: keyboard: split keyboard enhancements into separate functions
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.
2025-06-02 14:09:47 -04:00
Ayman Bagabas
d420464a88
chore: fix const lint issues 2025-05-01 11:54:27 -04:00
Ayman Bagabas
cb090c0aed
fix: lint: use isWindows() helper function 2025-05-01 11:53:10 -04:00
Ayman Bagabas
825e109a2a
fix: always enable basic keyboard enhancements to disambiguate keys
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.
2025-05-01 11:53:09 -04:00
Andrey Nering
431cb5cd9f ci(lint): fix all lint issues on v2-exp 2025-02-27 12:04:20 -03:00
Ayman Bagabas
6e5929bd8d
chore: don't expose internal fields in KeyboardEnhancements 2025-01-13 08:23:29 +03:00
Ayman Bagabas
65874a6122
refactor: keyboard: expose type and track requested and active enhancements
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`.
2025-01-13 08:23:28 +03:00
Ayman Bagabas
8085d33f76
feat: add kitty keyboard uniform key layout support
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.
2024-09-20 16:05:38 -04:00
Ayman Bagabas
7cb34becaf
(v2) feat: combine keyboard enhancements into a nicer API (#1152)
* 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>
2024-09-18 14:23:47 -04:00