194 Commits

Author SHA1 Message Date
Mitchell Hashimoto
91ba47af1f input: add test for backspace change 2024-04-05 08:25:14 -07:00
rok
51bfde69ba input: do not emit sequence on <BS> when their's UTF-8 text 2024-04-05 19:55:17 +09:00
Mitchell Hashimoto
0bd673435f input: add test for esc clearing dead key state 2024-04-04 21:57:32 -07:00
rok
9326ae363c input: escape can be used to clear dead key state
This fixes korean input method issue on mac. When typing korean
and press escape in vim, composing korean character should remain.
2024-04-05 03:17:39 +09:00
Mitchell Hashimoto
461b16ce34 font sizes are limited to u8 (max size = 255 points)
Fixes #1618

Font sizes in configuration were always a u8, but the keybinding and
internal state was a u16 so it allowed for an ever-growing font size. At
a certain point, there is an integer overflow which causes it to wrap
around. This is all silly, 255 should be large enough for anyone[1]

[1]: Ready to be super wrong about this
2024-03-27 20:36:59 -07:00
Gregory Anders
c634ba363a input: fix associated text on macOS
Ghostty does not report associated text on macOS when
macos-option-as-alt is enabled for _any_ key press, whether or not the
Alt modifier is actually present. The "option as alt" decision should
only be made when the alt modifier is present.
2024-03-25 13:43:32 -05:00
ProfOak
96daf97d19 Add keybind support for shift+insert selection paste 2024-02-21 19:33:05 -06:00
Gregory Anders
cff9671bdf Omit release events for backspace, enter, and tab if report_all is unset 2024-02-18 09:43:05 -06:00
Mitchell Hashimoto
1170cee550 input: encode ctrl+shift+<ascii letter> in CSIu as lowercase + shift
This follows a specific behavior Kitty has, but no other terminal seems
to have, but it is a reasonable behavior that is in use by real programs
as found by our beta testing community.

We diverge from Kitty though in that we only apply this to ASCII
letters. Kitty does not CSIu encode special characters like `@` or `$`.
For these characters, Ghostty still encodes it as specified by fixterms.
2024-02-17 13:45:49 -08:00
Mitchell Hashimoto
4a6ba59f73 input: send shifted uppercase ASCII letters as CSIu
Related to #1507

The comments in this change have most of the detail. The primary gist:

  - caps-lock is handled correctly so #1501 is still fixed
  - only characters pressed with the shift key are affected
2024-02-17 08:39:27 -08:00
Mitchell Hashimoto
2f36fd4b5f input: ctrl ASCII uppercase behaves the same as ctrl lowercase
Fixes #1505

I verified this behavior with every other terminal and I've added test
cases for it. We previously had a test case to assert the opposite,
which is incorrect.
2024-02-11 14:28:53 -08:00
Mitchell Hashimoto
f414787779 move SplitDirection to apprt 2024-02-04 20:42:42 -08:00
Tim Culverhouse
1824a0fe87 split: add auto as split option
Add an `auto` split direction which splits along the larger direction.
2024-02-04 21:28:17 -06:00
Erlend Lind Madsen
4475f5b9c5 url/Link: simplify regex, remove 'find_longest' param and add new tests 2024-02-02 01:23:39 +01:00
Mitchell Hashimoto
88e7c96eac Merge pull request #1431 from mitchellh/mouse-mods-alt
core: handle mouse capture events with link highlighting
2024-02-01 09:20:04 -08:00
Mitchell Hashimoto
6de4533afb core: handle mouse capture events with link highlighting
Fixes #1416

At a high level, the issue is that when mouse capture is enabled (i.e. in
neovim), "shift" escapes the capture. So "cmd+shift" is equal to "cmd"
which doesn't get sent to the TUI program and so on. For link
highlighting which now requires "cmd" (super) is held, we were sending
"cmd+shift" to the renderer so we weren't checking for links.

So the core of this commit is respecting this scenario and stripping the
shift modifier.

This commit also found that when the mouse wasn't over a link, we were
always checking and highlighting links on line one of the visible
screen. This bug is fixed and should also result in a very slight
performance improvement on rendering in all cases.
2024-02-01 09:19:39 -08:00
Mitchell Hashimoto
eafc9559d7 core: add "reset" keybinding to reset the terminal
Fixes #1425
2024-02-01 08:46:39 -08:00
Mitchell Hashimoto
f65989fd92 Merge pull request #1387 from mattrobenolt/cmd-click
Open links with Super+click
2024-01-27 21:04:51 -08:00
Mitchell Hashimoto
3efe88c85c input: add link highlight always/hover w/ mods 2024-01-27 19:07:49 -08:00
Mitchell Hashimoto
ae11cc9042 add a new highlight state that requires modifiers 2024-01-27 19:03:03 -08:00
Mitchell Hashimoto
0726a8d1fa apprt/embedded: ctrl-only should use binding-mods only
This allows it to ignore control side differences.
2024-01-27 11:15:54 -08:00
Mitchell Hashimoto
bf4211e060 input: handle more ctrl+<key> sequences, namely ctrl+_
Previously, we encoded `ctrl+_` in the CSIu format[1]. This breaks most
notably emacs which expects the legacy ambiguous encoding.

This commit utilizes the generator from Kitty to generate our control
key mappings. We also switch from keycode mapping to key contents
mapping which appears to be the correct behavior also compared to other
terminals.

In the course of doing this, I also found one bug with our fixterms
implementation. Fixterms states: "The Shift key should not be considered
as a modifier for Unicode characters, because it is most likely used to
obtain the character in the first place (e.g. the shift key is often
required to obtain the ! symbol)." We were not applying that logic and
now do.

[1]: https://www.leonerd.org.uk/hacks/fixterms/
2024-01-25 15:25:23 -08:00
gabydd
6f04bd4a79 don't write ":" when printing keybinding action with no argument 2024-01-22 21:01:16 -05:00
Aurélien Cibrario
509be969af Added plus + key 2024-01-21 21:09:24 -08:00
Jeffrey C. Ollie
9b1f72987a markdown-ify keybind actions help strings 2024-01-21 19:50:39 -06:00
Mitchell Hashimoto
87f5d6f6a8 apprt/embedded: do not depend on macOS APIs on non-macOS 2024-01-14 14:31:14 -08:00
Mitchell Hashimoto
3360a008cd build: build produces a broken object file for iOS
This gets `zig build -Dtarget=aarch64-ios` working. By "working" I mean
it produces an object file without compiler errors. However, the object
file certainly isn't useful since it uses a number of features that will
not work in the iOS sandbox.

This is just an experiment more than anything to see how hard it would be to
get libghostty working within iOS to render a terminal. Note iOS doesn't
support ptys so this wouldn't be a true on-device terminal. The
challenge right now is to just get a terminal rendering (not usable).
2024-01-13 21:38:58 -08: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
dcc3c17738 input: missing kp_begin encoding entry 2024-01-09 10:52:49 -08:00
Mitchell Hashimoto
baf8e04287 input: add unit test for no associated text on release 2024-01-08 08:12:54 -08:00
Tim Culverhouse
e90a6ee19f input: never report associated text on key release
Associated text should only be reported when it was generated from the
key event. To my knowledge, there are no release events which produce
text. This now matches kitty reporting for release events.
2024-01-08 07:32:18 -06:00
Jeffrey C. Ollie
f4292bccfc replace deprecated std.mem.tokenize with std.mem.tokenizeScalar 2024-01-03 10:22:33 -06:00
Mitchell Hashimoto
21db51ff9d input: only send keypad events for keypad application mode
Fixes #1099
2023-12-27 08:10:01 -08:00
Mitchell Hashimoto
0a1dfae2ef input: kitty keyboard modifier event changes from Kitty 0.32
> When the key event is related to an actual modifier key, the corresponding
> modifier's bit must be set to the modifier state including the effect for the
> current event. For example, when pressing the :kbd:`LEFT_CONTROL` key, the
> ``ctrl`` bit must be set and when releasing it, it must be reset. When both
> left and right control keys are pressed and one is released, the release event
> must have the ``ctrl`` bit set. See :iss:`6913` for discussion of this design.
2023-12-24 08:21:31 -08:00
Mitchell Hashimoto
ede7ec9c63 input: kitty encoding should only report alt key if not equal to utf8 2023-12-21 20:43:42 -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
aa9b7cd2e9 input: clarify some limitations of opening config 2023-12-18 08:07:41 -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
Mitchell Hashimoto
c97f6ac027 input: translate '\t' to Key.tab
This allows bindings with `tab` to work properly on Linux. The issue is
that in the key translation, we weren't mapping this and thought it was
invalid IME input so we were ignoring it.
2023-12-17 20:14:41 -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
Caleb Spare
ae94af37c0 config: improve link matching for URLs ending in . or )
Fixes #1098
2023-12-16 17:34:38 -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
Mitchell Hashimoto
9642dd3275 macos: proper event when sided mod released with other side pressed
Related to https://github.com/mitchellh/ghostty/issues/1082

This fixes two separate issues to follow along with the new spec changes
Kovid pushed to Kitty:

  1. When two modifiers are pressed and one is released, this shows up
     as a proper release event with the correct side. Previously, the
     correct side was shown but as a press event.

  2. When two modifiers are pressed and one is released, the Kitty event
     should not have that specific modifier set. For example, pressing
     left ctrl, then right ctrl, then releasing right ctrl should encode
     as "right ctrl released" but with NO modifiers still present.
2023-12-13 21:50:00 -08:00
Mitchell Hashimoto
5baab8f4f3 Merge pull request #1075 from rockorager/keypad
fix: keypad key encoding on GTK
2023-12-13 18:48:15 -08:00
Mitchell Hashimoto
89348fd73e include: add new keycodes 2023-12-13 18:46:55 -08:00
Mitchell Hashimoto
5a372f6a06 input/kitty: do not encode event with mods if press
Fixes #1082
2023-12-13 13:39:44 -08:00
Mitchell Hashimoto
c0eded766a input/kitty: do not encode event+mods if they're both default 2023-12-13 10:57:17 -08:00
Tim Culverhouse
4bd9b1365a key: add TODO's for media keys
Add TODO comments in places where we need to add media keys.
2023-12-13 06:57:15 -06:00
Tim Culverhouse
a0880bcfed key: add additional keypad keys
Add additional keypad keys to the encoding scheme. This allows Ghostty
to report KP_HOME and it's relatives. We also always check for a keyval
first, so we can report KP_7, etc as opposed to ASCII '7'.
2023-12-13 06:55:22 -06:00
RGBCube
d659b12fb9 input: add scroll_page_lines 2023-12-11 23:35:40 +03:00