Commit Graph

130 Commits

Author SHA1 Message Date
Mitchell Hashimoto
2044e5030f terminal: make stream processing infallible
The terminal.Stream next/nextSlice functions can now no longer fail.
All prior failure modes were fully isolated in the handler `vt`
callbacks. As such, vt callbacks are now required to not return an error
and handle their own errors somehow.

Allowing streams to be fallible before was an incorrect design. It
caused problematic scenarios like in `nextSlice` early terminating
processing due to handler errors. This should not be possible.

There is no safe way to bubble up vt errors through the stream because
if nextSlice is called and multiple errors are returned, we can't
coalesce them. We could modify that to return a partial result but its
just more work for stream that is unnecessary. The handler can do all of
this.

This work was discovered due to cleanups to prepare for more C APIs.
Less errors make C APIs easier to implement! And, it helps clean up our
Zig, too.
2026-03-13 13:56:14 -07:00
Mitchell Hashimoto
eb335fb8dd cleanup by just scrolling in the renderer 2026-02-19 14:06:58 -08:00
benodiwal
263469755c refactor: remove unused stream handler scroll-to-bottom code
The renderer approach doesn't need termio changes.

Co-Authored-By: Sachin <sachinbeniwal0101@gmail.com>
2026-02-19 13:54:32 -08:00
benodiwal
81f537e992 feat: implement scroll-to-bottom on output option
Implements the `output` option for the `scroll-to-bottom` configuration,
which scrolls the viewport to the bottom when new lines are printed.

Co-Authored-By: Sachin <sachinbeniwal0101@gmail.com>
2026-02-19 13:52:57 -08:00
Mitchell Hashimoto
1b2376d366 terminal: remove last semantic_prompt usage from Terminal 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
84cfb9de1c restore old marking behavior so everything keeps working 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
c9e60b322b terminal: OSC133 options parse from raw string
This changes our OSC133 parser to parse options lazily. We do this for
multiple reasons:

1. Parsing all our options ahead of time balloons our required
   osc.Command tagged union type which has C ABI implications. Adding
   all supported options (including Kitty extensions) today already
   breaks our C ABI.

2. Invalid options are allowed by the specification and should be 
   explicitly ignored, so we don't need to validate options at all
   during parse time.

3. Semantic prompt markers don't need to be high throughput, so we
   can afford to do some extra work at processing time to gather
   the options. They're also rather short usually.
2026-01-24 13:48:31 -08:00
Mitchell Hashimoto
d23722dbd7 terminal: remove old semantic prompt handling 2026-01-23 14:35:10 -08:00
Mitchell Hashimoto
389439b167 terminal: handle semantic prompt same as old 2026-01-23 14:30:27 -08:00
Mitchell Hashimoto
9f2808ce40 terminal: stream handles new SemanticPrompt type 2026-01-23 14:14:28 -08:00
Mitchell Hashimoto
82b10ae7af terminal: explicit error sets in Screen and ScreenSet 2026-01-21 11:34:59 -08:00
Mitchell Hashimoto
c8ffc0faa5 termio: report color scheme synchronously (#9705)
The reporting of color scheme was handled asynchronously by queuing a
handler in the surface. This could lead to race conditions where the DSR
is reported after subsequent VT sequences.

Fixes #5922
2026-01-20 09:48:43 -08:00
Mitchell Hashimoto
a8b31ceb84 terminal: restoreCursor is now longer fallible
We need to have sane behavior in error handling because the running
program that sends the restore cursor command has no way to realize it
failed. So if our style fails to add (our only fail case) then we revert
to no style.

https://ampcode.com/threads/T-019bd7dc-cf0b-7439-ad2f-218b3406277a
2026-01-19 12:12:19 -08:00
Tobias Kohlbau
836d794b9e termio: report color scheme synchronously
The reporting of color scheme was handled asynchronously by queuing a
handler in the surface. This could lead to race conditions where the
DSR is reported after subsequent VT sequences.

Fixes #5922
2026-01-19 07:49:57 +01:00
Qwerasd
69066200ef fix: handle double tmux control mode exit command 2026-01-16 16:58:58 -05:00
Peter Cardenas
f36abed35a fix: reset progress bar on reset terminal 2026-01-05 05:26:33 -08:00
Mitchell Hashimoto
1fdc0c0b9f terminal: CSI S compatiblity improvements
Fixes #9905

This fixes a major compatibility issues with the CSI S sequence:

When our top margin is at the top (row 0) without left/right
margins, we should be creating scrollback. Previously, we were
only deleting.
2025-12-14 14:36:42 -08:00
Mitchell Hashimoto
86cd489701 terminal/tmux: introduce command queue for viewer 2025-12-08 09:00:38 -08:00
Mitchell Hashimoto
ec5a60a119 terminal/tmux: make sure we always have space for one action 2025-12-08 07:27:37 -08:00
Mitchell Hashimoto
b26c42f4a6 terminal/tmux: better formatting for notifications and actions 2025-12-08 07:00:44 -08:00
Mitchell Hashimoto
52dbca3d26 termio: hook up tmux viewer 2025-12-08 07:00:43 -08:00
Mitchell Hashimoto
0d75a78747 terminal/tmux: start viewer state machine 2025-12-08 07:00:43 -08:00
Qwerasd
212598ed66 perf: add branch hints based on real world data
+ move stream ESC state entry outside of `nextNonUtf8`
2025-11-18 20:43:31 -07:00
Qwerasd
6d5b4a3426 perf: replace std.debug.assert with inlined version
See doc comment in `quirks.zig` for reasoning
2025-11-17 12:13:56 -07:00
Mitchell Hashimoto
580f9f057b convert t.screen to t.screens.active 2025-11-14 15:40:31 -08:00
Mitchell Hashimoto
3aff5f0aff ScreenSet 2025-11-14 15:08:10 -08:00
Mitchell Hashimoto
2daecd94a5 renderer: use terminal color state, remove color messages 2025-10-30 09:52:39 -07:00
Mitchell Hashimoto
77343bb06e terminal: move color state fully into the terminal for fg/bg/cursor 2025-10-30 09:33:21 -07:00
Mitchell Hashimoto
cabca0aca8 terminal: unify palette functionality into shared type DynamicPalette 2025-10-30 09:15:43 -07:00
Mitchell Hashimoto
1d03451d4f terminal: OSC color operations 2025-10-25 07:03:21 -07:00
Mitchell Hashimoto
e13f9b9e8c terminal: kitty color 2025-10-25 06:42:20 -07:00
Mitchell Hashimoto
e49694439c terminal: setAttribute 2025-10-24 11:53:25 -07:00
Mitchell Hashimoto
5ba451d073 terminal: configureCharset 2025-10-24 11:27:48 -07:00
Mitchell Hashimoto
4d028dac1f terminal: some osc types 2025-10-24 11:17:31 -07:00
Mitchell Hashimoto
bce1164ae6 terminal: cursor style 2025-10-24 07:26:04 -07:00
Mitchell Hashimoto
fd0f9bb843 terminal: device attributes 2025-10-24 07:17:44 -07:00
Mitchell Hashimoto
e347ab6915 terminal: device attributes 2025-10-24 07:08:34 -07:00
Mitchell Hashimoto
109376115b terminal: convert dcs 2025-10-23 21:29:18 -07:00
Mitchell Hashimoto
6902d89d91 terminal: convert APC 2025-10-23 21:24:31 -07:00
Mitchell Hashimoto
b91149f0fe terminal: simple esc dispatch 2025-10-23 21:18:51 -07:00
Mitchell Hashimoto
9cd4594356 terminal: active status display 2025-10-23 21:14:21 -07:00
Mitchell Hashimoto
f68ea7c907 terminal: many more conversions 2025-10-23 21:10:25 -07:00
Mitchell Hashimoto
2520e27aef terminal: kitty keyboard actions 2025-10-23 20:55:08 -07:00
Mitchell Hashimoto
b7ea979f38 terminal: zero-arg actions 2025-10-23 20:47:02 -07:00
Mitchell Hashimoto
0df4d5c5a4 terminal: margins 2025-10-23 20:37:34 -07:00
Mitchell Hashimoto
c1e57dd330 terminal: setprotectedmode 2025-10-23 20:31:17 -07:00
Mitchell Hashimoto
25eee9379d terminal: request mode 2025-10-23 20:26:14 -07:00
Mitchell Hashimoto
b6ac4c764f terminal: modify_other_keys 2025-10-23 20:26:11 -07:00
Mitchell Hashimoto
94a8fa05cb terminal: convert modes 2025-10-23 20:07:45 -07:00
Mitchell Hashimoto
dc5406781f terminal: many more conversions 2025-10-23 19:56:13 -07:00