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

(v2) Bubble Tea API #1118

Draft
wants to merge 164 commits into
base: main
Choose a base branch
from
Draft

(v2) Bubble Tea API #1118

wants to merge 164 commits into from

Conversation

aymanbagabas
Copy link
Member

@aymanbagabas aymanbagabas commented Aug 28, 2024

This PR will keep track of the changes upcoming in Bubble Tea v2

  • Input sequence parser
  • Kitty keyboard
  • Xterm modifyOtherKeys
  • Mode 2027 (grapheme clustering)
  • Setting/getting terminal background/foreground/cursor colors
  • Setting/getting the clipboard using OSC52
  • Make Init() return the model
  • New Key/Mouse API (v2) Use KeyMsg/MouseMsg interfaces #1111

aymanbagabas and others added 30 commits August 12, 2024 17:33
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.

Supersedes: #1079
Supersedes: #1014
Related: #869
Related: #163
Related: #918
Related: #850
Related: #207
Signed-off-by: Carlos Alexandro Becker <[email protected]>
This replaces enable/disable directives with exception to alt-screen and
cursor visibility since those affect the renderer.
We need to initialize the tty and the input handler before writing to
it.
A modified F3 key press has the same sequence as cursor position report.
We need to handle that by reporting both messages and letting the
program determine which one to listen for. On most cases, programs don't
care about modified F3 key press since terminals tend to have different
sequences for it.
Move tracking bp to the program instead of the renderer. The renderer
doesn't need to know about the state of bp and gains nothing from that
information.
Signed-off-by: Carlos Alexandro Becker <[email protected]>
This adds the necessary options to enable/disable the kitty keyboard
protocol.

Needs: #1080
Fixes: #869
This adds the ability to read and set terminal background, foreground,
and cursor color.
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.
aymanbagabas and others added 20 commits October 7, 2024 05:12
Some terminals such as WezTerm report incorrect press and release
sequences when "report event types" enhancement is enabled. This
patch adds support for these faulty mappings.

Related: wez/wezterm#6160
This should fix the textinputs example, as the code is using KeyMsg. KeyMsg seems to have an issue with the v2
alpha where it appears that both KeyPressMsg and KeyReleaseMsg may be unintentionally being called sequentionally.
Just using one or the other should solve the issue for this. This issue also likely exists within other examples and may
Need to be looked at separately.

No PR/Issue Tag atm
When a printable character is pressed with no modifiers, the `key.Mod`
field is set to 0. In this case, the `key.Code` field should be used to
determine the text to send to the program.

Fixes: c53a7c9 (fix: kitty: use the correct case for key text)
This fixes a bunch of issues on Windows bringing improvements and
reliability to the implementation. It replacing the existing key events
hack with a key state that keeps track of previous key events to parse
the incoming ANSI escape sequences. It also decodes unicode utf16 pairs
at the parser level instead of the driver level.

Related: #1126
…1163)

This fixes a bunch of issues on Windows bringing improvements and
reliability to the implementation. It replaces the existing key events
hack with a key state that keeps track of previous key events to parse
the incoming ANSI escape sequences. It also decodes unicode utf16 pairs
at the parser level instead of the driver level.

Related: #1126

TODO:
- [x] Windows API tests
  - [x] Key events
  - [x] Mouse events
  - [x] Resize events
  - [x] Focus events
This commit adds support for changing the cursor style. The new
`SetCursorStyle` command can be used to change the cursor style to one of
the following:

- `CursorBlock`
- `CursorUnderline`
- `CursorBar`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants