152 Commits

Author SHA1 Message Date
Qwerasd
1c87bf51a0 fix(terminal/stream): correct invalid assertion 2024-03-17 15:06:31 -06:00
Qwerasd
777ecffe6b fix(terminal/stream): fix OOB read and integer overflow 2024-02-08 22:34:21 -05:00
Qwerasd
68c0813397 terminal/stream: Added ESC parsing fast tracks 2024-02-08 21:49:58 -05:00
Qwerasd
f8c544c119 terminal: stream/parser changes 2024-02-07 19:08:34 -05:00
Qwerasd
343cb9a334 fix(terminal): send SI to execute instead of print 2024-02-07 00:14:54 -05:00
Mitchell Hashimoto
fdc67a08f4 terminal: add tests for incomplete utf-8, fix one bug 2024-02-06 08:45:41 -08:00
Qwerasd
689a521256 terminal: remove unused properties 2024-02-06 03:04:00 -05:00
Qwerasd
5769bb16dd fix(terminal): Fix boundary utf-8 decoding crash
Get rid of completePartialUtf8 and simply use the scalar parse (`.next`) to resolve boundary conditions instead.
2024-02-06 02:51:04 -05:00
Mitchell Hashimoto
dc6c52fac1 terminal: do not have the UTF8Decoder overhead if SIMD 2024-02-05 21:26:40 -08:00
Mitchell Hashimoto
449d3b49a4 terminal: split input to fit output chunks 2024-02-05 21:22:27 -08:00
Mitchell Hashimoto
351d9eb402 terminal: use new VT simd to process slices 2024-02-05 21:22:27 -08:00
Mitchell Hashimoto
c751619b7e terminal: use highway-based indexOf to support all targets 2024-02-05 21:22:26 -08:00
Mitchell Hashimoto
62ce93dcff terminal: use SIMD w/ Neon to find ESC in VT streams 2024-02-05 21:22:25 -08:00
Mitchell Hashimoto
0c2a87e5fb terminal: small stylistic tweaks 2024-02-05 21:20:20 -08:00
Qwerasd
846b3421e6 terminal: replace utf8 decoding with custom decoder in stream.zig
(Completely removed utf8 handling from Parser.zig)
2024-02-05 23:20:47 -05:00
Mitchell Hashimoto
3c26828a3f terminal: distinguish between DSRs with "?" and not 2024-02-02 12:42:22 -08:00
Jeffrey C. Ollie
67e347070d fix typo in CSI n handling 2024-02-01 10:50:49 -06:00
Mitchell Hashimoto
c871140419 terminal: handle SCOSC/SCORC
Fixes #1401

SCOSC is ambiguous with regards to DECSLRM. This commit copies the logic
of xterm: if left/right mode is enabled, then CSI S is always DECSLRM.
But if left/right mode is disabled then CSI S empty always uses SCOSC.

SCORC always works.
2024-01-28 08:04:14 -08:00
Mitchell Hashimoto
f445ee269f terminal: ignore change window title requests with invalid UTF-8 2024-01-23 11:52:56 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -08:00
Mitchell Hashimoto
84a0e4e62d terminal: support 58;5 for setting underline color via 256 palette
Fixes #1013
2023-12-07 14:57:07 -08:00
Mitchell Hashimoto
8b09764614 terminal: implement OSC 1 (change icon) and ignore it
Fixes #948

We want to parse it so we can log at a lower level than warn but we
don't want to support this because it isn't very well defined.
2023-11-23 14:58:34 -08:00
Mitchell Hashimoto
b5cad7184d terminal: ED handles invalid values 2023-11-19 20:47:04 -08:00
Gregory Anders
3f4ea2f763 core: support OSC 9 and OSC 777 for showing desktop notifications 2023-11-15 10:25:02 -06:00
Mitchell Hashimoto
bde9b02db3 termio: wake up writer thread if the writer mailbox is full
Normally, we queue all the writes we need from a single `read()` syscall
and only wake up the writer thread at the end of processing that batch
of data.

But under very heavy load or large batches of data, it is possible for the
terminal sequences to generate enough writes to the pty to fill the
writer thread queue while we're still processing the data from `read()`.

This modifies our queuer to attempt to queue, but if the queue is full
we wake up the writer thread immediately then queue again (which should
succeed in every case -- eventually).
2023-11-10 22:01:07 -08:00
Gregory Anders
33753f59c8 core: implement OSC 104, 110, and 111 to reset colors 2023-11-09 16:17:21 -06:00
Gregory Anders
1c0b79c40f core: separate default colors from modifiable colors
Default colors are those set by the user in the config file, or an
actual default value if unset. The actual colors are modifiable and can
be changed using the OSC 4, 10, and 11 sequences.
2023-11-09 14:08:14 -06:00
Gregory Anders
006e93bd08 core: implement setting colors with OSC 4, 10, and 11 2023-11-09 11:59:20 -06:00
Mitchell Hashimoto
4c45bfec9e terminal: improve some debug logging 2023-10-27 09:14:29 -07:00
Mitchell Hashimoto
9c165ecbd2 terminal: clamp cursor left above scroll region with XTREVWRAP2
Fixes a crash found through fuzzing. This crash is also exhibited in
xterm (as of v384). The issue arises when you set the cursor above the top
scroll margin, then issue a large cursor left (CSI D) with extended reverse
wrap (?1045) set. Extended reverse wrap loops back until it reaches the top
scroll then wraps around. But since the cursor is before the top scroll,
xterm just arbitrarily moves back into negative row numbers, which reads into
bad memory.

We decided to fix this by clamping to (0,0) and exiting because this
will mimic the xterm behavior for valid values of cursor left count
(prior to crashing).
2023-10-26 22:38:33 -07:00
Mitchell Hashimoto
28aace4393 Merge pull request #728 from mitchellh/cimgui
Terminal Inspector v1
2023-10-26 10:12:39 -07:00
Mitchell Hashimoto
0baf3522b4 terminal: bring back unimplemented logs 2023-10-26 09:53:57 -07:00
Nameless
49f1866f28 add tests for fuzzed results, clean up unimplemented osc warning 2023-10-25 11:44:16 -05:00
Mitchell Hashimoto
7b2af3a039 inspector: start termio log 2023-10-24 15:27:17 -07:00
Mitchell Hashimoto
62475fd709 terminal: ICH should only run with no intermediates 2023-10-24 09:43:06 -07:00
Mitchell Hashimoto
de1ed071ad termio: configure OSC parser with an allocator 2023-10-15 08:41:38 -07:00
Mitchell Hashimoto
392da475e1 terminal: XTSHIFTESCAPE 2023-10-11 21:49:04 -07:00
Mitchell Hashimoto
7a8f2bfed6 terminal: decscusr 2023-10-10 12:24:11 -07:00
Mitchell Hashimoto
f216609662 terminal: RIS should reset tabstops, ESC ? W should reset every 8
Fixes #648

Two issues here:

  - RIS should've been resetting the tabstops to every 8, but was
    clearing all tabstops.

  - `ESC ? W` should've reset tabstops to every 8, but was clearing
    all tabstops.
2023-10-10 09:02:22 -07:00
Mitchell Hashimoto
2354454907 terminal: set left and right margins, left and right margin mode 69 2023-10-09 21:20:15 -07:00
Mitchell Hashimoto
9c45c6a3d1 terminal: handle ansi vs dec mode
Previously, we just ignored ansi vs dec modes (`?`-prefix) and just
responded to both requests most of the time using the number as the
unique value. This _kind of works_ because almost all DEC modes do not
overlap with ANSI modes, but some overlap (i.e. `insert`, ANSI mode 4).

This commit properly separates ANSI vs DEC modes and updates all of our
terminal sequences to handle both (where applicable -- some sequences
are explicitly DEC-only).
2023-10-09 16:01:08 -07:00
Mitchell Hashimoto
ed23f2f1d0 terminal: implement DECID (ESC Z) 2023-10-09 09:43:28 -07:00
Mitchell Hashimoto
b927760149 terminal: HPR, VPR 2023-10-07 09:32:58 -07:00
Mitchell Hashimoto
c2af7b60d0 terminal: FF (0x0D) also invokes LF 2023-10-06 12:00:18 -07:00
Mitchell Hashimoto
823f47f695 termio: hook up dcs callbacks 2023-09-27 13:32:00 -07:00
Mitchell Hashimoto
032fcee9ff terminal: DCS handler, XTGETTCAP parsing 2023-09-27 12:07:31 -07:00
Mitchell Hashimoto
5528580a29 terminal: DECSED, DECSEL parsing, tests 2023-09-25 10:56:59 -07:00
Mitchell Hashimoto
8137a66ef6 terminal: CSI Ps " q for setting DEC protected mode 2023-09-25 10:56:59 -07:00
Mitchell Hashimoto
92e98d34b5 terminal: CSI E and F 2023-09-21 08:21:32 -07:00
Tim Culverhouse
fbe030d85a terminal: respond to XTVERSION query
XTVERSION (CSI > 0 q) is used by some libraries to identify the terminal
+ version. Respond to this query with `ghostty {version_string}`. There
is no formal format for this response. A roundup of a few tested
terminals show two primary formats. This patch opts to save one byte and
use the `name SP version` semantics.

foot: foot(version)
xterm: XTerm(version)
contour: contour version
wezterm: wezterm version

Reference: https://github.com/dankamongmen/notcurses/blob/master/TERMINALS.md#notes-for-terminal-authors
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
2023-09-20 19:06:28 -05:00