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 185 commits into
base: main
Choose a base branch
from
Draft

(v2) Bubble Tea API #1118

wants to merge 185 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 <caarlos0@users.noreply.github.com>
This replaces enable/disable directives with exception to alt-screen and
cursor visibility since those affect the renderer.
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
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 <caarlos0@users.noreply.github.com>
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
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.
aymanbagabas and others added 30 commits October 15, 2024 18:49
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`
This commit changes the behavior of grapheme clustering to be opt-in
instead of opt-out. This is because some terminals like Apple Terminal
don't support DECRQM and DECRPM, which are required for querying and
setting the grapheme clustering state.

Apple Terminal, instead, replies with a `p` character when querying the
grapheme clustering state, which is not a valid response and breaks the
program output.
Before initializing the input reader, we need to ensure that
the console input buffer is empty, otherwise, we can get dangling
events from previous sessions.
…mes (#1205)

* chore: use verbs in background, foreground, and window request cmd names

This renames a few existing commands to make it clearer that the user is
firing off a task.

* WindowSize -> RequestWindowSize
* ForegroundColor -> RequestForegroundColor
* BackgroundColor -> RequestBackgroundColor

It also expands on a few comments, and provides examples.

* fix: screen tests

* fix(examples): use RequestWindowSize instead of WindowSize

---------

Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
This change updates the standard renderer to use the colorprofile.Writer
to downsample colors when writing to the terminal.
This adds support for detecting the terminal's color profile. It adds a
new `ColorProfileMsg` message that get sent when the program starts. You
can force a specific color profile using the `WithColorProfile` option.

When a program requests the `RGB` or `Tc` terminfo capabilities, Bubble
Tea will read the response, if there is one, and upgrade the cached
color profile and send the new profile to the program again.

Supersedes: #1142
Supersedes: #1143
This commit wraps the input parser in a struct and moves the tracing
logic to the program and its writer and input driver.

It also changes the behavior of the tracer to only enable tracing for
local environment variables i.e. from `os.Getenv` and not from the
program's environment. In other words, it will ignore the program's
environment variables when it comes to tracing.
Fixes: 83a84e4 (refactor: move input tracing to input parser and simplify tracing)
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