29 Commits

Author SHA1 Message Date
Nameless
49f1866f28 add tests for fuzzed results, clean up unimplemented osc warning 2023-10-25 11:44:16 -05:00
Nameless
81f7ae63b0 fuzz: src/terminal/stream.zig
osc.zig: undefined pointer was dereferenced when warning was issued
for handler missing
Parser.zig: too many parameters was not handled in the final case
Parser.zig: parameters being too long (>255 digits) was not handled
2023-10-25 11:42:13 -05:00
Mitchell Hashimoto
cfac6c4001 terminal: OSC parser takes optional allocator
OSC 52 is the only command that uses this today. If the allocator is
present it will use it to store the clipboard contents.
2023-10-14 21:49:10 -07:00
Tim Culverhouse
5e800df277 osc: allow 0x20-0xFF in osc_put
The osc_string state of the parser limited accepted bytes to 0x7F. When
parsing a utf-8 encoded string as part of an OSC string, the parser
would encounter an error and abort the OSC parsing, allowing any
remaining bytes to be leaked (possibly) as printable characters to the
terminal window.

Allow any byte in the range 0x20 - 0xFF to be accepted by osc_put. Add
test cases which conflict with the 'anywhere' transitions (IE the utf8
sequence includes C1 control codes which might transition to another
state).
2023-09-21 03:08:41 -05:00
Mitchell Hashimoto
19ef4a22a9 terminal: stylistic changes for OSC terminators, 10/11 params 2023-09-14 13:12:41 -07:00
cryptocode
dc14ca86ca Review updates:
* Change state names to more human readable query_default_fg/bg
* Single-line state prongs
* String terminator is not an enum
* Removed `endWithStringTerminator` and added nullabe arg to `end`
* Fixed a color reporting bug, fg/bg wasn't correctly picked
2023-09-14 21:46:23 +02:00
cryptocode
a3696a9185 Implement OSC 10 and OSC 11 default color queries
These OSC commands report the default foreground and background colors.

Most terminals return the RGB components scaled up to 16-bit components, because some
legacy software are unable to read 8-bit components. The PR follows this conventions.

iTerm2 allow 8-bit reporting through a config option, and a similar option is
added here. In addition to picking between scaled and unscaled reporting, the user
can also turn off OSC 10/11 replies altogether.

Scaling is essentially c / 1 * 65535, where c is the 8-bit component, and reporting
is left-padded with zeros if necessary. This format appears to stem from the XParseColor
format.
2023-09-14 21:41:40 +02:00
Mitchell Hashimoto
cb2931cb27 rename cursor shape to mouse shape for OSC 22 2023-09-14 11:12:17 -07:00
Mitchell Hashimoto
ab8569b4bd terminal: parse OSC 22 2023-09-14 09:36:23 -07:00
Mitchell Hashimoto
de3d0b4243 terminal: parse semantic prompt "k" (kind) parameter 2023-09-03 13:47:06 -07:00
Kevin Hovsäter
59fd918443 Allow optional OSC 52 parameter
Quoting from the XTerm documentation:

The first, Pc, may contain zero or more characters from the set c, p, q,
s, 0, 1, 2, 3, 4, 5, 6, and 7. It is used to construct a list of
selection parameters for clipboard, primary, secondary, select, or
cut-buffers 0 through 7 respectively, in the order given. If the
parameter is empty, xterm uses s 0 , to specify the configurable
primary/clipboard selection and cut-buffer 0.

See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
2023-08-22 14:20:19 +02:00
Mitchell Hashimoto
314f9287b1 Update Zig (#164)
* update zig

* pkg/fontconfig: clean up @as

* pkg/freetype,harfbuzz: clean up @as

* pkg/imgui: clean up @as

* pkg/macos: clean up @as

* pkg/pixman,utf8proc: clean up @as

* clean up @as

* lots more @as cleanup

* undo flatpak changes

* clean up @as
2023-06-30 12:15:31 -07:00
Mitchell Hashimoto
e59b2f7fca terminal: track pwd reported via OSC 7 2023-05-31 18:54:24 -07:00
Mitchell Hashimoto
b538072972 terminal: osc 7 parsing 2023-05-31 17:32:06 -07:00
Mitchell Hashimoto
283c94f874 terminal: parse OSC 133 A redraw like kitty 2023-05-31 15:39:54 -07:00
Mitchell Hashimoto
4047a90555 terminal: track semantic prompt metadata per row 2023-05-27 15:45:51 -07:00
Mitchell Hashimoto
0592e4fa1a terminal: osc parser gracefully handles input data larger than buffer 2022-12-14 21:24:43 -08:00
Mitchell Hashimoto
56de5846f4 OSC 52: Clipboard Control (#52)
This adds support for OSC 52 -- applications can read/write the clipboard. Due to the security risk of this, the default configuration allows for writing but _not reading_. This is configurable using two new settings: `clipboard-read` and `clipboard-write` (both booleans).
2022-11-21 15:12:00 -08:00
Mitchell Hashimoto
02b6eb123e fix test name 2022-11-18 18:18:10 -08:00
Mitchell Hashimoto
dbf167d18a OSC parsing for get/set clipboard (OSC 52) -- not hooked up yet 2022-11-18 18:16:53 -08:00
Mitchell Hashimoto
5c2edf4d2a Fix some stage2 compilation errors 2022-08-17 14:42:23 -07:00
Mitchell Hashimoto
46db4623bc OSC 133;C 2022-06-21 15:50:44 -07:00
Mitchell Hashimoto
1e8e80ed7b osc: change window title with code 2 2022-05-10 14:12:35 -07:00
Mitchell Hashimoto
28b3ac52e9 osc: reset_cursor_color 2022-05-10 12:15:35 -07:00
Mitchell Hashimoto
b585fe463d osc parser temporary state changed to union 2022-05-10 12:10:44 -07:00
Mitchell Hashimoto
eee837f69b osc: prompt_end 2022-05-10 11:57:42 -07:00
Mitchell Hashimoto
92805f57b0 osc: end of command 2022-05-10 11:54:43 -07:00
Mitchell Hashimoto
6b5bdc4634 OSC parses prompt_start 2022-05-10 11:40:37 -07:00
Mitchell Hashimoto
bb4332ac38 terminal: OSC parser 2022-05-10 09:27:29 -07:00