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 v2 #1118

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

(v2) Bubble Tea v2 #1118

wants to merge 391 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 aymanbagabas changed the title V2 exp (v2) Bubble Tea API Aug 28, 2024
@aymanbagabas aymanbagabas added this to the v2.0.0 milestone Aug 29, 2024
@aymanbagabas aymanbagabas force-pushed the v2-exp branch 3 times, most recently from b38523b to d727a8c Compare September 19, 2024 17:00
@aymanbagabas aymanbagabas force-pushed the v2-exp branch 2 times, most recently from dd32151 to 6073691 Compare September 20, 2024 20:00
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 13 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: wezterm/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
aymanbagabas and others added 15 commits February 7, 2025 17:39
This updates the renderer to use backspace to optimize cursor movements
when the terminal supports it. This is similar to the hard tabs
optimization, but for backspace to move the cursor left.
This adds a new option to set the initial window size of the terminal
window. This is useful in testing and required for teatest/v2 after the
changes in the renderer. The cell-based cursed renderer heavily relies
on the terminal size, and it's important to have a way to set the size
manually for tests to run in a non-interactive environment.
Using cud1 (`\x1b[B`) won't scroll the terminal if the cursor is already
at the bottom of the screen. Instead, use a newline character to move
the cursor down and scroll the terminal if necessary.

Fixes: #1322
The new renderer now always moves the cursor to the beginning of
the next line on exit.
The cursed renderer moves the cursor between renders, which can cause
issues when the terminal is released and restored. For instance, when
we exec a command using tea.Exec, we want the cursor position to remain
the same after the command finishes and goes back to the same position
as before the command was executed.

With tea.Suspend on the other hand, we want to make sure we reset the
cursor position because the program stops executing and is put to
suspend. Resuming the program again initializes the renderer and its
cursor position again from scratch as if it was a new program.

This wasn't an issue for the standard renderer because we always put the
cursor at the lower left corner of the screen. Releasing and restoring
the program wasn't an issue because the cursor was always at the same
position.
aymanbagabas and others added 14 commits February 12, 2025 12:32
This change separates the viw from the main model by introducing new
interfaces `ViewModel` and `CursorModel`. The `ViewModel` interface
provides a view method that returns the string to render, while the
`CursorModel` interface provides a view method that returns the string
to render and the cursor position.

If a program does not implement a view interface, the program won't
render anything. This removes the need for the `WithoutRenderer` option.
This change separates the viw from the main model by introducing new
interfaces `ViewModel` and `CursorModel`. The `ViewModel` interface
provides a view method that returns the string to render, while the
`CursorModel` interface provides a view method that returns the string
to render and the cursor position.

If a program does not implement a view interface, the program won't
render anything. This removes the need for the `WithoutRenderer` option.
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