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

docs: update in the wild #1128

Closed
wants to merge 93 commits into from
Closed

docs: update in the wild #1128

wants to merge 93 commits into from

Conversation

bashbunni
Copy link
Member

@bashbunni bashbunni commented Sep 3, 2024

No description provided.

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 28 commits August 20, 2024 12:08
This adds the ability to use a custom renderer using a modified version
of the existing `renderer` interface.
This moves the GetSize call after initializing the renderer.
Use Render instead of Write/WriteString
Only disable enabled capabilities. Keep track of mouse mode state.
Use Mode/SetMode instead of EnableAltScreenBuffer/DisableAltScreenBuffer
etc. This uses less code and makes it more usable in the future to
accommodate for more terminal capabilities and modes.
This adds the ability to use a custom renderer using a modified version
of the existing `renderer` interface. This also keeps track of enabled
capabilities and ensure they are turned off on program exit. It only
turns off enabled capabilities rather.

The new API looks like:

```go
// Renderer is the interface for Bubble Tea renderers.
type Renderer interface {
	// Close closes the renderer and flushes any remaining data.
	Close() error

	// Render renders a frame to the output.
	Render(string) error

	// SetOutput sets the output for the renderer.
	SetOutput(io.Writer)

	// Flush flushes the renderer's buffer to the output.
	Flush() error

	// InsertAbove inserts lines above the current frame. This only works in
	// inline mode.
	InsertAbove(string) error

	// Resize sets the size of the terminal.
	Resize(w int, h int)

	// Request a full re-render. Note that this will not trigger a render
	// immediately. Rather, this method causes the next render to be a full
	// Repaint. Because of this, it's safe to call this method multiple times
	// in succession.
	Repaint()

	// ClearScreen clear the terminal screen. This should always have the same
	// behavior as the "clear" command which is equivalent to `CSI 2 J` and
	// `CSI H`.
	ClearScreen()

	// SetMode sets a terminal mode on/off. The mode argument is an int
	// consisting of the mode identifier.
	// For example, to set alt-screen mode, you would call SetMode(1049, true).
	SetMode(mode int, on bool)

	// Mode returns whether the render has a mode enabled.
	// For example, to check if alt-screen mode is enabled, you would call
	// Mode(1049).
	Mode(mode int) bool
}
```

--- 

This also introduces some performance gains by not writing unnecessary
sequences on enable/disable terminal modes. For example, we always hide
the cursor when the program runs, it doesn't make sense to write the
sequence again when the model sends a `HideCursor` command, we already
know it's hidden. Don't _always_ disable mouse if it wasn't enabled in
the first place.
…#1099)

Bumps [github.com/charmbracelet/x/ansi](https://github.com/charmbracelet/x) from 0.2.1 to 0.2.2.
- [Release notes](https://github.com/charmbracelet/x/releases)
- [Commits](charmbracelet/x@ansi/v0.2.1...ansi/v0.2.2)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/x/ansi
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Hack!

This forces a bg/fg query on the default os.Stdout and os.Stdin before
starting any bubbletea program. Otherwise, programs might hang before
the query finishes. This is because at that point, the bubbletea already
acquired the terminal os.Stdin and termenv cannot read from it. The
termenv query timeout can be adjusted using `termenv.OSCTimeout`.

Note that this will only work for the default IO i.e. os.Stdout and
os.Stdin.

docs: copyedits in Lip Gloss/Termenv workaround for clarity

Co-authored-by: Christian Rocha <christian@rocha.is>
* feat: add mode 2027 grapheme clustering stubs

This adds the necessary stubs to make mode 2027 (grapheme clustering)
work on Bubble Tea with renderers that support it.

* fix: screen grapheme clustering tests
@bashbunni bashbunni closed this Sep 3, 2024
@bashbunni bashbunni deleted the in-the-wild branch September 3, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants