738 Commits

Author SHA1 Message Date
Mitchell Hashimoto
aa86031ff6 terminal: move line searching here, unit test 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
c7ccded359 terminal: Screen.getLine 2023-11-29 15:30:07 -08:00
Mitchell Hashimoto
3aba42c3f7 terminal: stringmaps 2023-11-29 15:30:07 -08:00
Mitchell Hashimoto
0487dbfb25 terminal: selectionString uses arraylist to build results 2023-11-29 15:30:07 -08:00
Mitchell Hashimoto
7fc95690bc terminal: basic lineIterator on screen 2023-11-29 15:30: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
ec3b570b3e terminal: know about autorepeat mode
Ignore it because xterm does
2023-11-21 18:48:05 -08:00
Mitchell Hashimoto
34cfe0abab xterm audit: DECOM (origin mode) 2023-11-21 18:32:00 -08:00
Mitchell Hashimoto
44e28e43d3 terminal: fix cursor pos when resizing more rows not at bottom
Fixes #906

This changes our resize behavior when increasing row height.

If the cursor was originally at the bottom of the viewport, existing
scrollback (if it exists) will be "pulled down" from the top,
effectively keeping the cursor at the bottom. This is the behavior
today, prior to this commit.

If the cursor is not at the bottom of the viewport, scrollback will NOT
be "pulled down" and instead blank lines will be added _below_. This is
new behavior.
2023-11-21 11:27:02 -08:00
Mitchell Hashimoto
fd84178cc7 terminal: switching alt/primary screen invalidates Kitty image state 2023-11-21 08:37:41 -08:00
Mitchell Hashimoto
3c98c6375a terminal: handle width==3 glyphs by just pretending they're width 2 2023-11-20 19:55:06 -08:00
Mitchell Hashimoto
db7262a8dd terminal: resize less cols attempts to preserve cursor y
Fixes #906

Previously, when the cursor isn't at the bottom and you resized to less
cols, the cursor would jump to the bottom of the viewport. But if you
resized to more columns it didn't do this. This was jarring. This commit
attempts to keep the cursor at the same place.
2023-11-20 14:00:14 -08:00
Mitchell Hashimoto
553d81afd1 terminal: enable kitty graphics commands on OpenGL 2023-11-19 21:39:30 -08:00
Mitchell Hashimoto
a325ab5712 terminal: remove invalid test 2023-11-19 21:13:22 -08:00
Mitchell Hashimoto
7066fb7bbb terminal: ESC [ 2 J does a scroll and clear if viewport is at a prompt 2023-11-19 21:07:16 -08:00
Mitchell Hashimoto
b5cad7184d terminal: ED handles invalid values 2023-11-19 20:47:04 -08:00
Mitchell Hashimoto
39c2549b1a terminal: add ESC [ 22 J (scroll and clear) 2023-11-19 20:45:57 -08:00
Mitchell Hashimoto
b220179c3a terminal: add "clear" screen scroll mode 2023-11-19 20:39:57 -08:00
Mitchell Hashimoto
542f605d54 terminal: add explicit errorset to scroll screen 2023-11-19 20:39:40 -08:00
Mitchell Hashimoto
f2513e0825 Merge pull request #876 from gpanders/notifications
Add support for desktop notifications
2023-11-17 21:57:09 -08:00
Mitchell Hashimoto
54d4aed762 Merge pull request #899 from Raiden1411/select-all
core: implement select all binding
2023-11-17 21:37:57 -08:00
Mitchell Hashimoto
cb0cfab438 comments 2023-11-17 21:37:37 -08:00
Raiden1411
e3b83249d6 core: implement select all binding 2023-11-17 18:01:39 +00:00
Krzysztof Wolicki
44a48f62f1 change unmodified vars to consts in anticipation of zig changes 2023-11-17 15:46:46 +01: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
3192b13546 terminal: our mode size changed 2023-11-12 22:20:28 -08:00
Mitchell Hashimoto
8783f6c925 xterm audit: slow scroll (DECSCLM) 2023-11-12 22:11:11 -08:00
Mitchell Hashimoto
f00c87e805 xterm audit: DECCOLM and 132COLS 2023-11-12 22:05:26 -08:00
Mitchell Hashimoto
af6cc66369 core: Fix various double-click word selection bugs
Fixes #741

This completely reimplements double-click-and-drag logic for selecting
by word. The previous implementation was horribly broken. See #741 for
all the details.

The implemented logic now is:

* A double-click initiates a select-by-word selection mechanism.
  - A double-click may start on a word or whitespace
  - If the initial double-click is on a word, that word is immediately selected.
  - If the initial double-click is on whitespace, the whitespace is not selected.
* A "word" is determined by a non-boundary character meeting a boundary character.
  - A boundary character is `NUL` ` ` (space) `\t` `'` `"`
  - This list is somewhat arbitrary to make the terminal "feel" good.
  - Cell SGR states (fg/bg, bold, italic, etc.) have no effect on boundary determination or selection logic.
* As the user drags _on the same line_:
  - No selection change occurs until the cursor is over a new word. Whitespace change does nothing.
  - When selection is over a new word, that entire word added to the selection.
* When the user drags _up_ one or more lines:
  - If the cursor is over whitespace, all lines from the selection point up to but not including the cursor line are selected.
    * This selection is done in accordance to the previous rules.
  - If the cursor is over a word, the word becomes the beginning of the selection.
  - The end of the selection in all cases is the first word at or before the initial double-click point.
* When the user drags _down_ one or more lines:
  - The same logic as _up_ but swap the "beginning" and "end" of selection terminology.
* With this logic, the behavior of Ghostty has the following invariants:
  - Whitespace is never selected unless it is between two selected words
  - Selection implies at least one word is highlighted
  - The initial double-click point marks the beginning or end of a selection, never the middle.
2023-11-11 22:45:31 -08: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
Mitchell Hashimoto
53a5734d09 terminal: change mask from u256 to StaticBitSet 2023-11-09 15:14:33 -08:00
Gregory Anders
171292a063 core: implement OSC 12 and OSC 112 to query/set/reset cursor color 2023-11-09 16:21:07 -06: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
49feaedef6 core: move color parsing functions into RGB namespace 2023-11-09 14:06:06 -06:00
Gregory Anders
006e93bd08 core: implement setting colors with OSC 4, 10, and 11 2023-11-09 11:59:20 -06:00
Gregory Anders
f397353282 core: implement querying with OSC 4 2023-11-09 11:49:06 -06:00
Mitchell Hashimoto
4781a83e4a replace utf8proc with ziglyph 2023-11-07 13:17:56 -08:00
Mitchell Hashimoto
d20c4866b1 some comments, make switch exaustive 2023-11-06 14:42:10 -08:00
Tim Culverhouse
49fb5c8688 gtk(mouse): use "text" enum as default value
Use the .text field of the enum as the default value of the mouse shape
instead of renaming .default. Store the default value as the current
value for use in subsequent commits
2023-11-06 14:36:57 -08:00
Mitchell Hashimoto
254365afab terminal: add sanitize.zig 2023-11-04 11:25:02 -07:00
Mitchell Hashimoto
a38220eade terminal: move sanitization check to this package, unit test 2023-11-04 11:19:25 -07:00
Chinmay Dalal
481af8039b disable zig fmt for aligned comments 2023-10-31 23:08:51 +05:30
Chinmay Dalal
bccf1216bc exit early when cursor is on a prompt line 2023-10-30 12:42:58 +05:30
Chinmay Dalal
0920ab08cd handle cursor on a prompt line 2023-10-30 11:52:35 +05:30
Chinmay Dalal
3ff20c7418 add tests 2023-10-30 10:19:21 +05:30
Chinmay Dalal
fae356be5a implement selecting output a ScreenPoint is in
This works by finding prompt markers provided by shell integration
Does not yet close #752 as this is not exposed
2023-10-30 01:30:43 +05:30
Mitchell Hashimoto
069e16cb46 terminal: restore cursor should clamp x/y 2023-10-27 09:42:39 -07:00
Mitchell Hashimoto
306689b8a4 terminal: sgr direct bg also had wrong slice len 2023-10-27 09:27:45 -07:00
Mitchell Hashimoto
d28e6739c7 terminal: sgr direct color fg missing color doesn't crash 2023-10-27 09:25:16 -07:00