Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable focus reporting #1081

Merged
merged 6 commits into from
Aug 19, 2024
Merged

feat: enable focus reporting #1081

merged 6 commits into from
Aug 19, 2024

Conversation

caarlos0
Copy link
Member

supersedes #1079

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 added the enhancement New feature or request label Aug 13, 2024
@caarlos0 caarlos0 marked this pull request as ready for review August 13, 2024 14:29
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
nil_renderer.go Outdated Show resolved Hide resolved
options.go Outdated Show resolved Hide resolved
Copy link
Member

@aymanbagabas aymanbagabas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add tea commands to enable this feature tea.EnableReportFocue & tea.DisableReportFocus

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Member Author

We could also add tea commands to enable this feature tea.EnableReportFocue & tea.DisableReportFocus

good idea, done!

aymanbagabas added a commit that referenced this pull request Aug 19, 2024
Currently, Bubble Tea uses a simple lookup table to detect input events.
Here, we're introducing an actual input sequence parser instead of
simply using a lookup table. This will allow Bubble Tea programs to read
all sorts of input events such Kitty keyboard, background color, mode
report, and all sorts of ANSI sequence input events.

This PR includes the following changes:
- Support clipboard OSC52 read messages (`OSC 52 ?`)
- Support terminal foreground/background/cursor color report messages
(OSC10, OSC11, OSC12)
- Support terminal focus events (mode 1004)
- Deprecate the old `KeyMsg` API in favor of `KeyPressMsg` and
`KeyReleaseMsg`
- `KeyType` const values are different now. Programs that use int value
comparison **will** break. E.g. `key.Type == 13` where `13` is the
control code for `CR` that corresponds to the <kbd>enter</kbd> key.
(BREAKING CHANGE!)
- Bubble Tea will send two messages for key presses, the first of type
`KeyMsg` and the second of type `KeyPressMsg`. This is to keep backwards
compatibility and _not_ break the API
  - `tea.Key` contains breaking changes (BREAKING CHANGE!)
- Deprecate `MouseMsg` in favor of `MouseClickMsg`, `MouseReleaseMsg`,
`MouseWheelMsg`, and `MouseMotionMsg`
- Bubble Tea will send two messages for mouse clicks, releases, wheel,
and motion. The first message will be a `MouseMsg` type. And the second
will have the new corresponding type. This is to keep backwards
compatibility and _not_ break the API
  - `tea.Mouse` contains breaking changes (BREAKING CHANGE!)
- Support reading Kitty keyboard reports (reading the results of sending
`CSI ? u` to the terminal)
- Support reading Kitty keyboard and fixterms keys `CSI u`
- Support reading terminal mode reports (DECRPM)
- Bracketed-paste messages now have their own message type `PasteMsg`.
Use `PasteStartMsg` and `PasteEndMsg` to listen to the start/end of the
paste message.
- Bubble Tea will send two messages for bracketed-paste, the first is of
type `KeyMsg` and the second is of type `PasteMsg`. This is to keep
backwards compatibility and _not_ break the API
- Support more obscure key input sequences found in URxvt and others
- Support reading termcap/terminfo capabilities through `XTGETTCAP`.
These capabilities will get reported as `TermcapMsg`
- Support reading terminfo databases for key input sequences (disabled
for now)
- Support reading [Win32 Input Mode
keys](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md#win32-input-mode-sequences)
- Support reading Xterm `modifyOtherKeys` keys

TODO:
- [x] Parse multi-rune graphemes as one `KeyPressMsg` storing it in
`key.Runes`
- [x] Kitty keyboard startup settings and options
#1083
- [x] Xterm modify other keys startup settings and options
#1084
- [x] Focus events startup settings and options
#1081
- [x] Fg/bg/cursor terminal color startup settings and options
#1085

Supersedes: #1079
Supersedes: #1014
Related: #869
Related: #163
Related: #918
Related: #850
Related: #207
Base automatically changed from input to master August 19, 2024 15:47
@aymanbagabas aymanbagabas merged commit 05e8ecb into master Aug 19, 2024
16 of 18 checks passed
@aymanbagabas aymanbagabas deleted the input-focus-blur branch August 19, 2024 16:09
aymanbagabas added a commit that referenced this pull request Aug 29, 2024
This backports @caarlos0 focus-blur changes from v2-exp to v1 #1081
aymanbagabas added a commit that referenced this pull request Aug 29, 2024
This backports @caarlos0 focus-blur changes from v2-exp to v1 #1081

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
aymanbagabas added a commit that referenced this pull request Aug 29, 2024
This backports @caarlos0 focus-blur changes from v2-exp to v1 #1081

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
aymanbagabas added a commit that referenced this pull request Aug 30, 2024
* feat: support focus-blur events

This backports @caarlos0 focus-blur changes from v2-exp to v1 #1081

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* Update key_sequences.go

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: go mod tidy

---------

Co-authored-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Christian Rocha <christian@rocha.is>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants