Commit Graph

2115 Commits

Author SHA1 Message Date
Jacob Sandlund
f53e4b43c4 Merge remote-tracking branch 'upstream/main' into grapheme-width-changes 2026-02-23 08:39:10 -05:00
Mitchell Hashimoto
0eaf77da5f WIP: Make palette inversion opt-in (#10877)
From #10554

> I can see there being space for some kind of new sequence that tells
the terminal that "hey, I want a semantic palette" or something, that is
better adjusted to themes automatically. But, I don't think we should
this by default.

> So my concrete proposal is to eliminate the inversion and bg => fg
ramp and do a more typical dark => light ramp (still taking into account
bg/fg, but keeping 16 black and 231 white). I think this is the only way
we can really make this a default on feature. I think this would address
all the negative reactions we've gotten to it.

This adds a new `palette-harmonious`, disabled by default, which allows
generated light themes to be inverted.
2026-02-19 20:24:42 -08:00
Jake Stewart
f66a84b18a improve light theme detection 2026-02-19 20:17:47 -08:00
Jake Stewart
c4c87f8c85 make palette inversion opt-in 2026-02-20 07:46:16 +08:00
Mitchell Hashimoto
2a62f21bf0 fix tests 2026-02-19 14:10:33 -08:00
Mitchell Hashimoto
eb335fb8dd cleanup by just scrolling in the renderer 2026-02-19 14:06:58 -08:00
Jacob Sandlund
bb9d37c09c Merge remote-tracking branch 'upstream/main' into grapheme-width-changes 2026-02-19 08:52:53 -05:00
Mitchell Hashimoto
62968e423d terminal: clean up HTML OSC8 formatting 2026-02-17 12:48:35 -08:00
Matthew Hrehirchuk
9868bf3789 fix: replaced redundant writeHtmlEscaped method with writeCodepoint 2026-02-17 11:22:39 -08:00
Matthew Hrehirchuk
5e265c9c0d feat: add osc8 to <a> tag handling for html formatter 2026-02-17 11:20:40 -08:00
Mitchell Hashimoto
f0a1b05f63 rename config 2026-02-17 09:54:34 -08:00
Mitchell Hashimoto
89dfb76778 terminal: clean up 256 color gen 2026-02-17 09:45:34 -08:00
Mitchell Hashimoto
fded0e97cb terminal: clean up LAB methods, add tests, comments 2026-02-17 09:36:28 -08:00
Mitchell Hashimoto
50698c5c72 fmt 2026-02-17 09:18:03 -08:00
Jake Stewart
e268ff9a8b rename param 2026-02-17 09:17:54 -08:00
Jake Stewart
7729714935 refactor 256 color gen 2026-02-17 09:17:54 -08:00
Jacob Sandlund
bc7bbb27af Merge remote-tracking branch 'upstream/main' into grapheme-width-changes 2026-02-12 09:31:16 -05:00
Jeffrey C. Ollie
4eee1ac6a9 osc: parse OSC 5522 - Kitty clipboard protocol
This PR only adds support for parsing the OSCs. No support has been
added to DECRQM/DECRPM/DECSET/DECRST for mode 5522.
2026-02-03 13:30:05 -06:00
Mitchell Hashimoto
00567ff427 remove obsolete impossible test scenario 2026-02-02 15:20:36 -08:00
Mitchell Hashimoto
e478f3bf76 remove legacy promptPath 2026-02-02 15:18:09 -08:00
Mitchell Hashimoto
e60806942e terminal: when clicking right beyond the prompt line, move one more
This moves the cursor to the end properly.
2026-02-02 15:11:24 -08:00
Mitchell Hashimoto
4a1f02043a terminal: Screen.promptClickMove for cl handling 2026-02-02 13:36:24 -08:00
Mitchell Hashimoto
b827e587d9 terminal: set semantic_prompt.click based on OSC133A options 2026-02-02 09:28:55 -08:00
Mitchell Hashimoto
e9b6fea11c terminal: move semantic prompt state into its own field in screen 2026-02-02 09:19:18 -08:00
Mitchell Hashimoto
9ff9298707 terminal: parse OSC 133 cl values correctly 2026-02-02 09:01:01 -08:00
Jacob Sandlund
96c623ee33 Merge remote-tracking branch 'upstream/main' into grapheme-width-changes 2026-02-02 08:30:41 -05:00
Jacob Sandlund
1c3fc062e1 clarify comments 2026-02-02 08:30:30 -05:00
Mitchell Hashimoto
a909a1f120 terminal: mark newlines for input lines as prompt continuation rows 2026-02-01 13:01:03 -08:00
Mitchell Hashimoto
8811d9b055 terminal: for prompt redraw, assume at a prompt if at input line
Nu properly marks input areas with OSC 133 B, but if it spans multiple
lines it doesn't mark the continuation lines with the k=s sequence.

Our prompt redraw logic before only cleared explicitly designated prompt
lines. But if the input line is multi-line and the continuation lines
are not marked, those lines would not be cleared, leading to visual
issues on resize.

To workaround this, we assume that if the current cursor semantic
content is anything other than "command output" (default), then we're
probably at a prompt line and should clear from there all the way up.
2026-01-31 20:59:31 -08:00
Mitchell Hashimoto
853fee9496 terminal: when semantic cursor is prompt, assume newline is prompt
This works around Fish (at least v4.2) having a non-compliant OSC133 
implementation paired with not having the hooks to fix this via shell
integration. We have to instead resort to heuristics in the terminal
emulator. Womp, womp.

The issue is that Fish does not emit OSC133 secondary prompt (`k=s`)
markers at the beginning of continuation lines. And, since Fish doesn't
provide a PS2-equivalent, we can't do this via shell integration.

We fix this by assuming on newline (`\n`) that a cursor that is already
painting prompt cells is continuing a prior prompt line, and
pre-emptively mark it as a prompt line. But this has two further issues
we have to work around:

  1. Newline/index (`\n`) is one of the _hottest path_ functions in
     terminal emulation. It sucks to add any new conditional logic here.
     We do our best to gate this on unlikely conditions that the branch
     predictor can easily optimize away.

  2. Fish also emits these for auto-complete hints that may be deleted 
     later. So, we also have to handle the scenario where a prompt is 
     continued, then replaced by command output, and fix up the prompt 
     continuation flag to go back to output mode.

Point 2 is ALMOST automatically handled, because Fish does emit a `CSI J`
(erase display below) to erase the auto-complete hint. This resets all
our rows back to output rows. **Unfortunately**, Fish emits `\n` before
triggering the preexec hooks which set OSC133C. So we get the newline
logic FIRST (sets the prompt line), THEN sets the output cursor. If they
switched ordering here everything would just work (with the one
heuristic). But now, we need two!

To address this, I put some extra heuristic logic in the OSC133C
(output starting) handler: if our row is marked as a prompt AND our 
cursor is at x=0, we assume that the prompt continuation was deleted
and we unmark it. 

I put the heuristic logic dependent on OSC133C because that's way colder
of a path than putting something in `printCell` (which is the actual
hottest path in Ghostty).

We could get more rigorous here by also checking if every cell is empty
but that doesn't seem to be necessary at this time for any Fish version
I've tested. I hope thats correct.

I'd really love for Fish to improve their OSC133 implementation to
conform more closely to the terminal-wg spec, but we're going to need
these workarounds indefinitely to handle older Fish versions anyway.
2026-01-31 20:45:01 -08:00
Mitchell Hashimoto
918c2934a3 terminal: add redraw=last for bash for OSC133 2026-01-31 15:26:14 -08:00
Mitchell Hashimoto
a4b7a766fe PR review 2026-01-31 11:03:21 -08:00
Mitchell Hashimoto
c3e15a5cb6 terminal: rename semantic prompt 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
5f77b0ed98 terminal: remove old semantic_prompt 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
1b2376d366 terminal: remove last semantic_prompt usage from Terminal 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
10bc88766b terminal: soft wrap preserves new semantic prompt state 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
917a42876e terminal: cursorIsAtPrompt uses new APIs 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
112db8211d terminal: remove clearPrompt and integrate it into resize 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
0f05c2b71a terminal: fix resize test to use new semantic prompt logic 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
3aaafa2dda terminal: Screen testWriteString should set prompt_continuation for soft 2026-01-31 11:01:03 -08:00
Mitchell Hashimoto
047914c7b5 terminal: promptPath uses new semantic_prompt logic 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
ed0979cb0c terminal: selectOutput uses new semantic prompt logic 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
142f8ca6db terminal: Screen.selectLine uses new semantic boundaries 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
b62ac468dc terminal: change Screen.resize to take an options struct 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
07dce38cc5 terminal: Screen tracks semantic content seen 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
fd016fdb2a terminal: move cursor semantic content functions into Screen 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
4dd5df6c05 terminal: PageList.highlightSemanticContent 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
f9aa759767 terminal: promptIterator needs to respect limits 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
c74889124a terminal: PageList uses new semantic_prompt2 2026-01-31 11:01:02 -08:00
Mitchell Hashimoto
123e4ea325 terminal: PageList delta_prompt scroll uses new promptIterator 2026-01-31 11:01:02 -08:00