605 Commits

Author SHA1 Message Date
Mitchell Hashimoto
0277a0fb4c renderer/metal: detect frame commit failures and notify surface 2024-01-16 10:51:36 -08:00
Mitchell Hashimoto
adb7958f61 remove tracy usage from all files 2024-01-13 15:06:08 -08:00
Mitchell Hashimoto
50a119d300 Selection: add adjust method, unit test it, swap for adjustments 2024-01-11 22:14:40 -08:00
Qwerasd
3f3703deb6 Fixed accidentally consuming ALL shift+<key> releases 😅 2024-01-11 21:58:19 -05:00
Qwerasd
8cf3b6bef3 Shift+keys selection: Fixed up/down logic, added page up/down, home, & end. 2024-01-11 21:19:41 -05:00
Qwerasd
e0867801a5 Added use of shift+arrow keys to expand current selection 2024-01-11 20:58:12 -05:00
Mitchell Hashimoto
cba27e26cf input: manage application keypad state with mode 1035
Fixes #1099

We previously applied application keypad mode logic (`ESC=` or mode 66)
whenever it was active. However, from looking at the behavior of other
terminals (xterm and foot) it appears this isn't correct.

For xterm, application keypad mode only applies unconditionally if the
keyboard mode is VT220 (`-kt vt220`). For modern terminals, application
keypad mode is only applied if mode 1035 is disabled.

Mode 1035 is the "ignore numpad state with keypad mode" mode. It
defaults to true on terminal startup. If this is true, keypads are
always encoded in numerical mode. If this is false, the numlock state
will be respected.
2024-01-09 11:57:09 -08:00
Mitchell Hashimoto
96d33fef20 custom shader animation can be set to "always" to always remain active
Fixes #1225

The `custom-shader-animation` configuration can now be set to "always"
which keeps animation active even if the terminal is unfocused.
2024-01-09 09:21:15 -08:00
Mitchell Hashimoto
bc80073ffd core: add emoji fallback on macOS after built-in font
This doesn't fix any issues, but it slightly improves performance since
we'll try our text font first which is most likely to hit most input.
2024-01-08 08:01:17 -08:00
Mitchell Hashimoto
383b7c5870 core: clear_screen binding doesn't consume on alt screen
The clear_screen binding does nothing on the alternate screen already,
but we were still marking the action as "performed" which caused the
binding to be consumed.

This meant that alt screen applications like neovim, tmux, etc. couldn't
see "cmd+k" (default binding for clear_screen on macOS) without the
Ghostty user unbinding it completely.

We already have other bindings that do not consume only when they do not
perform, such as `previous_tab` and `next_tab`. This extends the
framework we built for that to this action.
2024-01-07 07:54:42 -08:00
Mitchell Hashimoto
962be81f71 core: add Apple Color Emoji on macOS if its available 2024-01-05 21:03:37 -08:00
Mitchell Hashimoto
b4f403f152 font-family settings are repeatable to specify fallback 2024-01-03 09:30:12 -08:00
Chris Marchesi
ffb9ebf6d9 macos: middle click always pastes from clipboard
Following up on #1145, this changes middle-click behavior on MacOS to
always paste from the system clipboard. This does not alter any of the
selection behavior, i.e. default behavior is to allow paste, but you
still need to manually copy. MacOS users still need to enable
"copy-on-select = clipboard" for that respective functionality.
2023-12-22 17:51:51 -08:00
Mitchell Hashimoto
900b127a04 core: cursor click to move can be disabled 2023-12-20 22:12:04 -08:00
Mitchell Hashimoto
3776b8a777 core: if click-to-move is done, stop mouse processing 2023-12-20 21:41:49 -08:00
Mitchell Hashimoto
3f9c42fd67 core: fast path out of click to move if no semantic prompts 2023-12-20 21:40:02 -08:00
Mitchell Hashimoto
82e5080cd6 core: click to move cursor only works on primary screen 2023-12-20 21:38:21 -08:00
Mitchell Hashimoto
4a3e1e15e5 core: click to move cursor 2023-12-20 21:33:13 -08:00
Mitchell Hashimoto
9c0de96c79 Merge pull request #1116 from clebs/feature/settings-shortcut
macos: Add settings shortcut
2023-12-18 08:08:48 -08:00
Mitchell Hashimoto
97433d3aa1 macos: close all windows
Fixes #1052

This implements a `close_all_windows` binding in the core and implements
it for macOS specifically. This will ask for close confirmation if any
surface in any of the windows requires confirmation.

This is bound by default to option+shift+command+w to match Safari. The
binding is generall option+command+w but users may expect this to also
mean "Close All Other Tabs" which is the changed behavior if any tabs
are present in a standard macOS application. So I chose to follow Safari
instead.

This doesn't implement this feature for GTK, that's left as an exercise
for a contributor.
2023-12-17 20:54:57 -08:00
Borja Clemente
646e3c365c Add settings shortcut on MacOS
- Settings shortcut opens the config file in the default editor.

Signed-off-by: Borja Clemente <borja.clemente@gmail.com>
2023-12-17 16:19:22 +01:00
Chris Marchesi
a6aad756e5 Surface: ensure keyToMouseShape respects hidden state
This fixes keyToMouseShape (the new handler for mouse shape state for
key combinations, e.g. during mouse tracking override or rectangle
select) so that it respects whether or not the mouse is currently
hidden, and will not send back a shape to change the mouse to in these
situations.

Fixes #1107.
2023-12-16 22:29:01 -08:00
Chris Marchesi
6e8ed4e8b3 Surface: set crosshair, change event processing logic for mouse tracking
This work is mainly targeted at adding the crosshair for when
ctrl/super+alt is pressed. We also add this for when mouse tracking is
enabled so that we show the crosshair when ctrl/super+alt+shift is
pressed at the same time.

I've also changed the event processing logic here because the amount of
keys we have to process has greatly increased. Instead of processing
each individual event, we now process the modifier state.

Additionally, some refactoring has been done geared at starting to
re-work the mouse for the core surface into a something stateful. My
hope is that we can continue to unravel some of this from the core
surface so that we can process key inputs, motion events, and anything
else relevant as inputs to transitions for shape display, click
behavior, etc.

This commit now also moves the ctrlOrSuper handlers to respective parts
in the Key hierarchy, while also adding additional helpers for other
modifiers.
2023-12-15 19:23:10 -08:00
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