Commit graph

58 commits

Author SHA1 Message Date
Jack Walker
b3b8f982fe
test: stabilize view model golden output (#1752)
Co-authored-by: Drew Smirnoff <drew@charm.land>
2026-11-12 17:22:51 +04:00
Drew Smirnoff
9c6c325f83
fix: ingnore implausible terminal resize reports (#1887)
Signed-off-by: drew <me@andrinoff.com>
2026-10-26 17:59:16 +04:00
Liam Stanley
c60f0c5304
fix: prevent data race with cursedRenderer.onMouse (#1691)
- closes #1690
- adds `-race`, `-count`, and `-cpu`
- make all viable tests parallel

Signed-off-by: Liam Stanley <liam@liam.sh>
2026-05-11 21:11:40 -04:00
Ayman Bagabas
a74936a850
chore(tests): fix tests and update testdata 2025-11-13 14:46:50 -05:00
Ayman Bagabas
be3c7e5427
refactor: restore options 2025-10-14 11:49:17 -04:00
Ayman Bagabas
bd747e7bfa
refactor: clean up redundant code and update testdata 2025-10-01 13:50:38 -04:00
Ayman Bagabas
fb3e0a4a3e
refactor: lean more into the View struct to manage terminal state 2025-10-01 13:50:37 -04:00
Ayman Bagabas
d1128242cd
refactor: remove WithWindowSize option in favor of InitialWidth and InitialHeight fields 2025-10-01 13:50:37 -04:00
Ayman Bagabas
fd39cfc36a
refactor: remove WithColorProfile option in favor of Program.ColorProfile field 2025-10-01 13:50:36 -04:00
Ayman Bagabas
7b13c33c4f
refactor: remove WithEnvironment option in favor of Env field on Program 2025-10-01 13:50:34 -04:00
Ayman Bagabas
6b6414508e
refactor: replace WithInput and WithOutput options with Input and Output fields on Program struct 2025-10-01 13:50:33 -04:00
Ayman Bagabas
688573d200
refactor: remove WithContext and pass context to Run 2025-10-01 13:50:32 -04:00
Ayman Bagabas
439500e8e5
fix: update screen_test to not depend on platform for test names 2025-09-11 16:23:26 -04:00
Ayman Bagabas
99a80e67ee
feat: keyboard: split keyboard enhancements into separate functions
This commit refactors the keyboard enhancements functionality by
splitting the `WithKeyboardEnhancements` function into three separate
functions:
- `WithKeyReleases`: Enables support for reporting key release events.
- `WithUniformKeyLayout`: Enables support for reporting key events in a
  uniform layout format.
- `RequestKeyDisambiguation`: Enables support for disambiguated key events.

This change improves clarity and usability by allowing users to enable
specific keyboard enhancements individually, rather than requiring them
to use a single function with multiple options.
2025-06-02 14:09:47 -04:00
Ayman Bagabas
7a0b68040e
chore: test: combine tests with golden file suffixes 2025-05-01 11:53:10 -04:00
Ayman Bagabas
f0d18bbad3
feat: add WithWindowSize option to set the initial window size (#1314)
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.
2025-02-07 17:42:18 -05:00
Ayman Bagabas
6f40250d70
chore: merge branch 'v2-exp' into v2-enh-keeb 2025-01-15 15:35:14 +03:00
Ayman Bagabas
e06652b4a7
fix: screen tests 2025-01-13 08:27:03 +03:00
Ayman Bagabas
65874a6122
refactor: keyboard: expose type and track requested and active enhancements
This change exposes the `KeyboardEnhancements` type and tracks requested
and active enhancements in the `Program` struct. This change also
renames the `KeyboardEnhancement` type to `KeyboardEnhancementOption`
and `keyboardEnhancements` to `KeyboardEnhancements` as well as
`EnableKeyboardEnhancements` to `RequestKeyboardEnhancements`.
2025-01-13 08:23:28 +03:00
Ayman Bagabas
26be4d4138
feat: tests: use golden files to test screen sequences 2025-01-13 08:20:20 +03:00
Ayman Bagabas
b704152507
fix: screen tests 2025-01-13 08:17:32 +03:00
Carlos Alexandro Becker
15ce054a43 feat: updating x/ansi (#1235)
* feat: updating x/ansi

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: enable/disable mode

* fix: execute in private mode, fix tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: update deps

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* fix: test

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* feat: update cellbuf

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

* all the updates

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
2024-11-21 14:12:16 -05:00
Ayman Bagabas
56f8ccb568 fix(tests): screen tests 2024-11-12 16:42:38 -05:00
Ayman Bagabas
b7a3c35132 feat: make the ferocious renderer opt-in
The ferocious renderer is now opt-in. This commit adds a new option
`WithFerociousRenderer` that enables the ferocious renderer.
2024-11-12 16:42:38 -05:00
Ayman Bagabas
29a3c0d6e0
chore: merge branch 'main' into v2-exp 2024-11-12 15:36:06 -05:00
Ayman Bagabas
e16a768eab fix: screen_test.go: fix test cases for ClearScreen and EnterAltScreen 2024-11-08 11:55:21 -05:00
Ayman Bagabas
50249d492d fix: screen_test.go: fix test cases for cursor movement
Add window size msg to the test cases to fix the cursor movement test cases.
2024-11-08 11:55:21 -05:00
Christian Rocha
c66c815d71
chore: add internal option for using the standard renderer 2024-11-06 13:30:10 -05:00
Ayman Bagabas
a2c8b388d9
chore: merge branch 'main' into v2-exp 2024-11-05 10:57:44 -05:00
Konstantin Antonov
2106895cd8 feat(render): update tests for non-flick rendering + optimisations 2024-10-30 09:43:53 -04:00
Ayman Bagabas
952b69d99b
fix: use ANSI256 color profile in screen_test.go 2024-10-28 16:00:23 -04:00
Christian Rocha
3bd4650254
chore: use verbs in background, foreground, and window request cmd names (#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>
2024-10-28 13:38:27 -04:00
Ayman Bagabas
43b11c30b3 fix: make grapheme clustering opt-in
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.
2024-10-22 21:55:07 -04:00
Ayman Bagabas
c35932f7ba fix(windows): test cases on windows 2024-10-15 18:49:46 -07:00
Ayman Bagabas
7cb34becaf
(v2) feat: combine keyboard enhancements into a nicer API (#1152)
* feat: combine keyboard enhancements into a nicer API

This change combines the keyboard enhancements into a nicer API. Kitty
keyboard protocol and XTerm modifyOtherKeys are now combined into a
single API. This makes it easier to enable keyboard enhancements.

Use `WithKeyboardEnhancements` to enable keyboard enhancements. This
function accepts a list of `KeyboardEnhancement` functions that can be
used to enable different keyboard features.

For now, we only support the `WithReleaseKeys` enhancement which enables
support for reporting release key events.

* Update options.go

Co-authored-by: Christian Rocha <christian@rocha.is>

* chore: go mod tidy

* chore: gofumpt

* fix: simplify keyboard enhancements disambiguation

* feat: make KeyboardEnhancementsMsg helpers always return true on Windows

* fix: remove unused win32input mode

* refactor: rename KeyboardEnhancementsMsg methods

---------

Co-authored-by: Christian Rocha <christian@rocha.is>
2024-09-18 14:23:47 -04:00
Ayman Bagabas
3650670bdb
fix: reset terminal colors on exit using osc 110/111/112 2024-09-16 14:20:18 -04:00
Ayman Bagabas
4fa1f0608c
fix: terminal colors tests 2024-09-12 14:58:24 -04:00
Ayman Bagabas
033071be4d
feat: export kitty/xterm/win32 input commands and messages 2024-08-30 09:37:22 -04:00
Ayman Bagabas
b2e983a1f1
feat: add mode 2027 grapheme clustering stubs (#1105)
* 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
2024-08-23 15:17:24 -04:00
Ayman Bagabas
05f8399a93
feat: dry setting and retrieving terminal modes
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.
2024-08-21 16:02:02 -04:00
Ayman Bagabas
c9f2a56893
fix: screen test 2024-08-21 11:35:56 -04:00
Ayman Bagabas
39ea34c830
refactor: unexport kitty keyboard settings and options
We can export them when we need them
2024-08-20 12:02:14 -04:00
Ayman Bagabas
e25b4b522e
Merge branch 'master' into input-clipboard 2024-08-19 11:59:40 -04:00
Ayman Bagabas
19f916be8e
Merge branch 'master' into input-background-foreground 2024-08-19 11:51:19 -04:00
Ayman Bagabas
04f843d2f9
feat: support setting and querying the terminal clipboard using OSC52
This adds support to setting the system and primary (X11 & Wayland)
clipboards using OSC52. This makes the clipboard commands work even on
remote session such as SSH.

While this doesn't work on all terminals, most modern terminals support
OSC52 including Alacritty, Kitty, Xterm.JS, etc. For terminals, that
don't support OSC52, application developers should consider using a
Golang clipboard library like https://github.com/atotto/clipboard.

OSC52 support can be detected if the terminal responds to a
`ReadClipboard` command.

Fixes: https://github.com/charmbracelet/bubbletea/issues/982
2024-08-15 15:51:57 -04:00
Ayman Bagabas
e6ad78c915
chore: add bg/fg/cur terminal color command test cases 2024-08-15 14:55:32 -04:00
Ayman Bagabas
a37d731531
chore: add kitty keyboard command test case 2024-08-15 14:43:40 -04:00
Ayman Bagabas
4497aa9eef
fix: reset cursor position on renderer exit (#1058)
We need to reset the cursor position to the beginning of the line when
the program stops or exit.

Related: https://github.com/charmbracelet/gum/issues/607
2024-07-16 12:54:58 -04:00
Ayman Bagabas
cb801d8f2c
refactor: use x/term and x/ansi for renderer sequences (#962)
* refactor: use x/exp/term for renderer sequences

This replaces termenv.Output with raw sequences and a bytes.Buffer to
handle vt screen and cursor events.

* chore: update dependencies

* refactor: use x/term
2024-05-21 14:46:11 -04:00
Ayman Bagabas
601d2289c9 fix: renderer: reset the cursor on the first line
We need to reset the cursor position on the first line before rendering.
Otherwise, it might mess up the first line being rendered.

Fixes: https://github.com/charmbracelet/bubbletea/issues/1000
Fixes: 46241068da (feat: reduce console/term dependencies (#897))
2024-05-08 16:07:42 -04:00