282 Commits

Author SHA1 Message Date
Chris Marchesi
aeaf5ea467 Surface: fix some rectangle select behaviors
This fixes a couple of subtle rectangle select behaviors:

* Corrects how selection rolls over when crossing the x-boundary; this
  was mentioned in #1021, this properly corrects it so both sides of the
  x-boundary do not share characters.

* Corrects a minor quirk in the selection of initial cells in a
  selection - this can be more readily observed when selecting a single
  line with rectangle select. To correct this, we only use the x axis
  when calculating this instead of both x and y.
2023-12-13 10:51:17 -08:00
RGBCube
d659b12fb9 input: add scroll_page_lines 2023-12-11 23:35:40 +03:00
Chris Marchesi
df142e08ad Selection: fix bottom-right/top-left rectangle selections
This fixes an issue where selections from the bottom-right to the
top-left (or top-left to bottom-right), in addition to some single-line
rectangle selections, were not working.

This works by handling situations where only one of the x or y
axes in the start or end points may need to be flipped to get the
correct top-left or bottom-right of a selection. We call these kinds of
orientations "mirrored", like you were looking in a mirror.

This also adds a small bit of logic that keeps these kinds of motions in
rectangle selection from selecting the character before or after it.
This has the current side-effect of anchoring a rectangle selection to
the original characters if you change directions during the selection,
something I will look at in a later commit.

Finally, this also removes rectangle select on double-click. I thought
this might be a good idea, but word select in rectangle mode really
does not work (the effect seems pretty erratic), and it's not
implemented in Kitty either.

Fixes #1008.
2023-12-07 23:51:37 -08:00
Mitchell Hashimoto
9de5d991a2 core: detect inputs that result in surface close and avoid segfault
Fixes #965

When processing keybindings that closed the surface (`close_surface`,
`close_window`), the surface and associated runtime structures would be
freed so we could segfault.

This PR introduces a new enum result for input events (only key for now)
that returns whether an event resulted in a close. In this case, callers
can properly return immediately and avoid writing to deallocated memory.
2023-12-07 10:24:39 -08:00
Mitchell Hashimoto
29312e76e5 core: mods change doesn't unhide mouse
Fixes #989
2023-12-06 11:38:26 -08:00
Mitchell Hashimoto
7ea0dfdd5d macos: if a preedit state is cleared, don't send key event
Fixes #992
2023-12-06 09:04:59 -08:00
Mitchell Hashimoto
55ba15fe66 change default embedded font to JetBrains Mono
Fixes #991

This changes the default embedded font from Fira to JetBrains Mono. This
only affects users who don't specify or font AND Ghostty can't find
another default font to use on their system.

This is one part an aesthetic choice: I've grown to personally like
JetBrains Mono more than Fira, and I think I have the right to change
the defaults ;)

But this is also partly because of #991: FiraCode contains glyphs for
symbolic ranges. This may not be Fira official... I think I may have
used a Nerd font patched one and that may be the issue. So I don't want
to blame the Fira font project. BUT, we have to replace the ttf in our
project and since I've been meaning to switch to JB Mono I just did that
now.
2023-12-06 08:08:14 -08:00
Mitchell Hashimoto
534de78d37 core: alternate scroll encoding should respect DECCKM 2023-12-05 09:43:53 -08:00
Mitchell Hashimoto
0cdefe8b8b core: remove size limit on preedit length by heap allocating
Fixes #882

We previously had a hardcoded limit of 16 codepoints. In #882, a user
pointed out that in Chinese, is reasonable for a preedit input to be
longer than this.

To avoid any future issues, this commit moves to a heap-allocated
variant. Preedits aren't that common, they aren't high throughput, and
they're generally pretty small, so using a heap allocation is fine. The
memory is owned by the person who set it.
2023-12-03 19:54:26 -08:00
Gregory Anders
b448501bf4 Preserve cursor shape when over a link
If mouse events are active and the cursor is hovered over a link,
pressing Shift does not change the cursor to a pointer, but to the text
selection shape, until the cursor is moved again. The pointer shape
should have higher priority over the text selection shape when the
cursor is hovered over a pointer.
2023-12-01 10:06:27 -06:00
Mitchell Hashimoto
f974a6f55d Merge pull request #953 from der-teufel-programming/update_once_more
Update to latest master
2023-11-30 14:17:46 -08:00
Krzysztof Wolicki
9238bdb4da Fix src/Surface.zig
Change fastmem.copy to use memcpy builtin
2023-11-30 21:58:14 +01: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
2d2495350f core: on mod change, rerun cursor pos callback 2023-11-29 18:44:22 -08:00
Mitchell Hashimoto
be1be2c64d core: only process link detection on cursor pos if cell changes 2023-11-29 15:54:13 -08:00
Mitchell Hashimoto
0938a0d638 core: handle URL clicking properly with shift-escaping mouse events 2023-11-29 15:30:23 -08:00
Mitchell Hashimoto
056e96748a core: don't crash if link processing fails 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
995e4e3757 os: open 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
dcbe0b8a5f core: only update mouse hover point when no other mouse action 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
8fcf3f08dd core: send mouse hover point 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
172a91e95d core: change mouse cursor over link 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
20cc369561 core: detect link click 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
aa86031ff6 terminal: move line searching here, unit test 2023-11-29 15:30:22 -08:00
Mitchell Hashimoto
2ee493c972 Merge pull request #942 from mitchellh/themes
Built-in Themes (based on iTerm2-Color-Schemes)
2023-11-28 08:13:19 -08:00
Burak Yildiz
44a3b22db8 fix selection clearing after a key press 2023-11-27 21:03:24 +01:00
Mitchell Hashimoto
115e8130ba Merge pull request #955 from mitchellh/text_action
Text action: input any text you want
2023-11-24 10:37:12 -08:00
Mitchell Hashimoto
6fc0d2d4a8 input: allocate for text bindings 2023-11-24 10:36:43 -08:00
Mitchell Hashimoto
0e2970bdeb config: add string parse, tests 2023-11-24 10:26:55 -08:00
Mitchell Hashimoto
2e02083eef Revert "parse string literal at load time"
This reverts commit 9c3e2b4ddd546e5f0c9d60c25a22bc5ab0be1283.
2023-11-24 10:06:34 -08:00
Guillaume Wenzek
9c3e2b4ddd parse string literal at load time 2023-11-24 18:15:47 +01:00
Guillaume Wenzek
223accb4c8 add "text" action 2023-11-24 17:53:46 +01:00
Mitchell Hashimoto
78420119df core: clear selection on mouse cursor keys
Fixes #939
2023-11-23 14:46:09 -08:00
Mitchell Hashimoto
b34e0f6ec7 core: do not send repeat/release events if the press consumed a binding
Fixes #943
2023-11-23 08:40:52 -08:00
Mitchell Hashimoto
45a4be6873 core: move resources dir to main global state 2023-11-22 21:12:01 -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
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
5290070be9 clipboard: add Clipboard variant for primary clipboard
In practice, the primary and selection clipboards are treated exactly
the same, but this allows OSC 52 sequences to use either 's' or 'p' as
the clipboard target.
2023-11-16 16:35:48 -06:00
Mitchell Hashimoto
df99c6e8e0 core: comment out log statements 2023-11-15 10:57:51 -08:00
Mitchell Hashimoto
50f0aaf26b renderer/metal: support multi-codepoint preedit text 2023-11-15 09:49:28 -08:00
Gregory Anders
689199251a core: use arrays instead of WriteReq for desktop notifications 2023-11-15 11:21:30 -06: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
5001e2c60c macos: filter option in AppKit when option-as-alt set
Fixes #872

In #867 we fixed macos-option-as-alt, but unfortunately AppKit ALSO does
some translation so some behaviors were not working correctly.
Specifically, when you had macos-option-as-alt set, option+e would
properly send `esc+e` to the pty but it would ALSO set the dead key
state for "`" since AppKit was still translating the option key.

This commit introduces a function to strip alt when necessary from the
translation modifiers used at the AppKit layer, preventing this
behavior.
2023-11-13 13:26:37 -08:00
Mitchell Hashimoto
86fbc6a85b macos-option-as-alt works again
This regressed sometime -- I can't find the exact commit -- but in any
case I've moved this handling directly into the KeyEncoder so we can
unit test it and prevent future regressions.
2023-11-12 15:26:55 -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
2489ef4c13 stylistic tweaks 2023-11-11 15:15:52 -08:00
Gregory Anders
06cdbc1a96 config: export ClipboardAccess 2023-11-11 17:25:48 -05:00
Gregory Anders
2a64180ebd config: rename ClipboardRequest to ClipboardAccess 2023-11-10 23:12:39 -05:00
Gregory Anders
960a1bb091 gtk: implement OSC 52 prompts 2023-11-10 23:12:39 -05:00