Commit graph

101 commits

Author SHA1 Message Date
Drew Smirnoff
585149e50e
fix: drain terminal query replies before releasing the terminal (#1894)
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-20 19:01:53 +04:00
jane michelle arc
9c6598361d
fix: return write errors from Program.Run (#1879)
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-20 18:52:39 +04:00
Johnny Chen
bc55190481
fix: synchronize canceled input cleanup (#1876)
AI-assisted-by: Codex (GPT 6.1 sol)
Co-authored-by: Drew Smirnoff <drew@charm.land>
Signed-off-by: Drew Smirnoff <drew@charm.land>
2026-11-20 18:44:32 +04:00
Attila Fábián
56a2fe7fed
fix: close the replaced cancel reader on RestoreTerminal (#1821)
Co-authored-by: Drew Smirnoff <drew@charm.land>
2026-11-12 17:25:04 +04:00
adam magued
96d69d2f7e
fix(tty): fall back to default dimensions when terminal size is 0x0 (#1836)
Co-authored-by: AdamMagued <adammagued.business@gmail.com>
2026-10-02 15:07:33 +04:00
Ayman Bagabas
718c8e750a
feat: restore WithoutRenderer option 2025-10-14 17:35:41 -04:00
Ayman Bagabas
cf6866fe56
fix: add View to Model interface and introduce DisableRenderer field 2025-10-01 13:50:43 -04:00
Ayman Bagabas
c4303e1147
fix: dry passed width and height to newCursedRenderer and send resize 2025-10-01 13:50:42 -04:00
Ayman Bagabas
6c1e051b72
refactor: make renderer flush method not require Program parameter and
wrap errors
2025-10-01 13:50:40 -04:00
Ayman Bagabas
5cbd22bd62
refactor: expose InitialModel field in Program struct 2025-10-01 13:50:39 -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
94c70a4ff4
feat: add OpenTTY to open the terminal's TTY 2025-10-01 13:50:33 -04:00
Ayman Bagabas
0db2eabd6d
Bump Ultraviolet and update input handling (#1493)
* feat(core): use uv input scanner

* chore: bump ultraviolet

* feat(input): use uv new input api

* chore: update ultraviolet dependency

* chore: bump ultraviolet to v0.0.0-20250810001545-aa2a3c4457a6 to fix esc
timeout

* chore: bump: update ultraviolet to v0.0.0-20250811190745-12cb2616ad77

* feat: enable Win32 Input Mode on Windows to get paste support

* chore: bump ultraviolet to a28b1e47903f to fix win32-input-mode paste

* Revert "feat: enable Win32 Input Mode on Windows to get paste support"

This reverts commit 6c5845ae7a.

* chore: bump ultraviolet to fix win32-input-mode issues

* fix(termios): windows console optimizations
2025-09-09 16:30:16 -04:00
Ayman Bagabas
70e94a2e0b
fix(keyboard): use kitty keyboard state command
Kitty keyboard can be set to a specific state instead of using the
push/pop stack approach. The latter might break and sometimes won't work
with things like Zellij.
2025-08-05 15:03:05 -04:00
Ayman Bagabas
efd37e6e54
chore: update to use ultraviolet repository name 2025-06-30 11:05:36 -04:00
Ayman Bagabas
c3a99ef435
feat: input: use new uv input reader api 2025-06-26 16:43:28 -04:00
Ayman Bagabas
fe8fa9de23
chore: update terminal reader api 2025-06-24 14:57:31 -04:00
Ayman Bagabas
f9391ae5ed
fix: mouse mode uv value 2025-06-10 16:53:54 -04:00
Ayman Bagabas
31fb5031cc
feat: update to use uv package 2025-05-30 17:44:58 -04:00
Ayman Bagabas
01667a90e9
fix: windows mouse mode 2025-05-19 13:23:46 -04:00
Ayman Bagabas
33dd5b01ba
refactor: rework tracing and use a standalone logger 2025-05-19 13:23:45 -04:00
Ayman Bagabas
9eb2867725
refactor: use tv package for input events 2025-05-19 13:23:44 -04:00
Ayman Bagabas
cc204f668b
(v2) fix: windows: enable mouse mode on demand (#1341)
* fix: windows: enable mouse mode on demand

This fixes an issue where mouse mode is always enabled on Windows. With
this patch, we enable mouse events only it is requested.

Needs: https://github.com/charmbracelet/x/pull/386
Related: https://github.com/charmbracelet/bubbletea/issues/1313

* refactor: mouse: properly handle mouse mode

Since mouse mode has a special case on Windows, we now have
separate msg types for mouse events.

* chore: go mod tidy
2025-03-11 16:20:20 -04:00
Andrey Nering
431cb5cd9f ci(lint): fix all lint issues on v2-exp 2025-02-27 12:04:20 -03:00
Ayman Bagabas
1805861a99
feat: separate view in its own interface
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.
2025-02-13 12:15:56 -05:00
Ayman Bagabas
d1fa13cdba
fix: reset renderer and cursor when releasing terminal (#1321)
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.
2025-02-11 12:29:34 -05:00
Ayman Bagabas
a93e488db8
chore: fix lint issues 2025-02-03 10:54:42 -05:00
Ayman Bagabas
6f40250d70
chore: merge branch 'v2-exp' into v2-enh-keeb 2025-01-15 15:35:14 +03:00
Ayman Bagabas
446de71c40
fix: preserve kittyFlags and modifyOtherKeys when updating enhancements 2025-01-13 16:47:54 +03:00
Ayman Bagabas
6e5929bd8d
chore: don't expose internal fields in KeyboardEnhancements 2025-01-13 08:23:29 +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
3d79aff7ed
perf: only reset mouse modes that are set 2025-01-13 08:20:24 +03:00
Ayman Bagabas
04c0b438d1
refactor: use the cursed renderer for rendering and remove the standard renderer
This also removes the experimental flags and changes the renderer
interface to be more explicit about the methods that are available.
2025-01-13 08:19:40 +03:00
Ayman Bagabas
0cf58beba4
feat: use the cursed ferocious renderer
This implements the new cursed ferocious renderer. This is based on the
new `cellbuf.Screen` renderer. This renderer is more efficient and
flexible than the previous renderer.

The renderer controls the altscreen buffer and cursor visibility which
means we don't need to do so in Bubble Tea. Instead, Bubble Tea can
focus on the event loop and the application state.
2025-01-13 08:19:38 +03:00
Ayman Bagabas
2df9ed00e3 refactor: use x/input for input events
This moves the existing input event handling to the x/input package. All
input events are translated to tea messages in
`tea.translateInputEvent`.
2024-12-12 10:51:58 -05:00
Ayman Bagabas
0806e0139a refactor: use x/input 2024-12-12 10:51:58 -05:00
Ayman Bagabas
1b7743e512 chore: lint issues 2024-11-21 14:12:16 -05: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
fc554e5972
chore: merge branch 'v2-exp' into v2-renderer 2024-10-30 12:39:19 -04:00
Ayman Bagabas
83a84e4593
refactor: move input tracing to input parser and simplify tracing
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.
2024-10-29 16:26:30 -04:00
Ayman Bagabas
a008bbfb58
chore: merge branch 'v2-exp' into v2-renderer 2024-10-24 11:27:50 -04:00
Ayman Bagabas
baecd89ed6
chore: merge branch 'main' into v2-exp 2024-10-24 11:19:25 -04:00
Ayman Bagabas
233434efcd
refactor: implement cell renderer screen type and perform rendering changes
This implements the meat of the cell renderer. It performs rendering changes
using a cell-based tracking. Changed cells are marked as dirty and only the
changed cells are rendered to the terminal. This is more efficient than
line rendering.
2024-10-16 16:53:21 -04:00
Ayman Bagabas
792918fd75
feat: trace i/o to a file 2024-10-11 12:58:13 -04:00
Ayman Bagabas
d727a8ce39
fix: enabling alt screen buffer should also set the cursor visibility 2024-09-19 13:00:28 -04: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
45222dfde8
fix: only reset terminal colors if they're changed 2024-09-13 10:52:30 -04:00
Ayman Bagabas
ceaed4d6b2
fix: restore terminal colors
This makes the program keep track of terminal colors so that they get
restored on program exit or suspend.
2024-09-12 14:07:17 -04:00