174 Commits

Author SHA1 Message Date
Mitchell Hashimoto
ae11cc9042 add a new highlight state that requires modifiers 2024-01-27 19:03:03 -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
Mitchell Hashimoto
ee08346dfe Merge pull request #968 from mitchellh/urls
Clickable URLs
2023-11-30 12:15:55 -08:00
Mitchell Hashimoto
bc7643eae9 input: update preventsText comment 2023-11-29 21:36:10 -08:00
Mitchell Hashimoto
659b43de37 input: Kitty encoding suppress associated text on macOS with alt 2023-11-29 21:34:30 -08:00
Mitchell Hashimoto
c66273e91c input: better docs on links 2023-11-29 15:30:23 -08:00
Mitchell Hashimoto
be05c3af53 input: add Link 2023-11-29 15:30:22 -08:00
Tim Culverhouse
07e6cf900f key-encode: only set associated text when there is printable text
Associated text should only be sent to the terminal when printable text
is generated from the keypress. Prevent sending associated text when any
modifier is pressed, except for Shift, NumLock, and Capslock

This brings Ghostty inline with the output of Kitty.
2023-11-24 14:27:37 -06: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
a67d90710c input: kitty encoding should ignore committed preedit state
Fixes #952
2023-11-24 07:58:31 -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
Mitchell Hashimoto
4cff8d972c input: do not encode enter with utf8 as pc style key
If the enter key has utf-8 attach, we assume its a dead key state being
committed so we don't process it.
2023-11-15 08:58:12 -08:00
Mitchell Hashimoto
35e78939e5 macos: ignore alt key with other modifiers set
This enables shifted alt-prefixed keys, such as `shift+alt+.` on
US standard becoming `M->`. To do this, we needed to fix a few bugs:

  (1) translation mods should strip alt even if other mods are set
  (2) AppKit translation event needs to construct new characters with
      the translation mods.
  (3) Alt-prefix handling in KeyEncoder needs to allow ASCII utf8
      translations even for macOS.
2023-11-13 19:21:51 -08:00
Mitchell Hashimoto
63e106390f input: fix failing test on Linux 2023-11-13 13:58:41 -08:00
Mitchell Hashimoto
b4d393fdcf input: process alt-prefix even if utf8 text doesn't exist 2023-11-13 13:50:00 -08: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