353 Commits

Author SHA1 Message Date
Mitchell Hashimoto
f1887e7b1b terminal/new: resize more cols ignores trailing empty cells 2024-03-22 20:27:33 -07:00
Mitchell Hashimoto
7b70dd1338 terminal/new: more resize more cols tests 2024-03-22 20:27:33 -07:00
Mitchell Hashimoto
839fae55f4 terminal/new: port more screen resize tests 2024-03-22 20:27:33 -07:00
Mitchell Hashimoto
d71657ded1 terminal/new: start porting resize tests, bugs 2024-03-22 20:27:33 -07:00
Mitchell Hashimoto
4632dd359d terminal/new: more no reflow tests 2024-03-22 20:27:32 -07:00
Mitchell Hashimoto
eb3323940d terminal/new: more no reflow tests 2024-03-22 20:27:32 -07:00
Mitchell Hashimoto
2e21f2179d terminal/new: port lots of no reflow screen resizes 2024-03-22 20:27:32 -07:00
Mitchell Hashimoto
9269d70f03 terminal/new: resize less rows trims blank lines first 2024-03-22 20:27:32 -07:00
Mitchell Hashimoto
43ad442ffe terminal/new: screen resize stubs (don't work) 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
e5cb77fe62 terminal: mark off test 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
07639e48ab terminal/new: more screen tests 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
07eaedf1fb terminal/new: eraseRows viewport behavior 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
ee6344eac8 terminal/new: screen clone tests 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
e903d5ed22 terminal: remove old logs 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
06376fcb0b terminal/new: clone can take a shared pool 2024-03-22 20:27:31 -07:00
Mitchell Hashimoto
5fe495e228 terminal: noting uncopied tests 2024-03-22 20:27:30 -07:00
Mitchell Hashimoto
26edb51d0c terminal/new: screen scrollClear tests 2024-03-22 20:27:30 -07:00
Mitchell Hashimoto
3842ca9212 terminal/new: screen scrolling tests 2024-03-22 20:27:30 -07:00
Mitchell Hashimoto
7ce4010f7a terminal/new: scrolling viewport into active area pins to active 2024-03-22 20:27:30 -07:00
Mitchell Hashimoto
bfa574fa60 terminal/new: Screen new scrolldown should inherit bg color 2024-03-22 20:27:30 -07:00
Mitchell Hashimoto
eaa78477d5 terminal: fix tests for brackets on selectWord 2024-03-04 14:30:28 -08:00
Adam Stephens
59485713b4 screen/selectword: add more boundary characters 2024-02-29 22:30:30 -05:00
Mitchell Hashimoto
2d612ab168 terminal: preserve multi-point grapheme clusters on scrollback deletion
This codepath was not previously tested (an accident). Upon testing
this codepath its clear to see the logic was incorrect. When we have to
remove rows from our scrollback to fit new rows in the circular buffer,
we have to delete graphemes, but we were deleting them from the wrong
row offset.

For the row offset, we previously used the _active_ screen but the
proper offset is the _full_ screen. Tests verify.
2024-01-25 09:35:56 -08:00
Mitchell Hashimoto
48d6c93e09 terminal: select line considers semantic prompt change a boundary
Fixes #1329

Some shells and scripts use spaces and soft-wrapping as a way to move to
the next line instead of using newline (`\n`). Line selection
(triple-click by default) considers a soft-wrapped line as a single
line, so it was selecting the prompt.

This commit makes it so line selection considers semantic prompt state
(prompt vs command output) an additional boundary condition. This
requires shell integration but will make selection behave more
expectedly.
2024-01-19 15:48:53 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -08:00
Jeffrey C. Ollie
f4292bccfc replace deprecated std.mem.tokenize with std.mem.tokenizeScalar 2024-01-03 10:22:33 -06:00
Gregory Anders
060bdff117 terminal: track palette color in cell state
Rather than immediately converting a color palette index into an RGB
value for a cell color, when a palette color is used track the palette
color directly in the cell state and convert to an RGB value in the
renderer.

This causes palette color changes to take effect immediately instead of
only for newly drawn cells.
2024-01-02 22:34:06 -06:00
Mitchell Hashimoto
b573ff137a terminal: resize cols should treat old cursor pos as active point
Fixes #1159

The cursor position is an "active" coordinate (defined at the top of
Screen.zig), but our resize was treating it as a "viewport" coordinate.
2023-12-26 13:59:22 -08:00
Mitchell Hashimoto
4a3e1e15e5 core: click to move cursor 2023-12-20 21:33:13 -08:00
Mitchell Hashimoto
6b1fd2b9eb terminal: Screen.promptPath 2023-12-20 20:50:10 -08:00
Mitchell Hashimoto
9a32ea515b terminal: Screen.selectPrompt to get the selection of the prompt 2023-12-20 20:35:05 -08:00
Mitchell Hashimoto
b327aab3d0 terminal: resize to less rows with empty lines should trim lines
Fixes #1030
2023-12-09 14:30:54 -08:00
Chris Marchesi
b84fb25e55 Add rectangle select
This adds rectangle select mode; when dragging with ctrl+alt (or
super+alt on MacOS), this allows you to select a rectangular region of
the terminal instead of the full start-end points of the buffer.
2023-11-30 12:35:52 -08:00
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
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
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
a325ab5712 terminal: remove invalid test 2023-11-19 21:13:22 -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
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
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
4781a83e4a replace utf8proc with ziglyph 2023-11-07 13:17:56 -08:00