-
Notifications
You must be signed in to change notification settings - Fork 855
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
aymanbagabas
wants to merge
391
commits into
main
Choose a base branch
from
v2-exp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
(v2) Bubble Tea v2 #1118
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b38523b
to
d727a8c
Compare
dd32151
to
6073691
Compare
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.
6073691
to
d2bffc5
Compare
d2bffc5
to
84b68c5
Compare
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
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.
caarlos0
reviewed
Feb 12, 2025
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR will keep track of the changes upcoming in Bubble Tea v2
MakeInit()
return the model