2217 Commits

Author SHA1 Message Date
Mitchell Hashimoto
2ff2e018ba input: clarify why we use all mods for unicode CSI u 2023-08-16 14:04:38 -07:00
Mitchell Hashimoto
dcf9cdd8bf input: CSI u encoding for modified unicode chars 2023-08-16 13:57:17 -07:00
Mitchell Hashimoto
33bef28850 rename key2callback to keycallback 2023-08-16 13:40:57 -07:00
Mitchell Hashimoto
4e8f5d3997 remove charCallback/keyCallback 2023-08-16 13:39:44 -07:00
Mitchell Hashimoto
dd385cc633 apprt/glfw: convert to new key2callback 2023-08-16 13:34:31 -07:00
Mitchell Hashimoto
cd90b2a716 apprt/embedded: only call new key2callback 2023-08-16 13:26:22 -07:00
Mitchell Hashimoto
896d0e8fcf apprt/gtk: only use key2callback 2023-08-16 13:02:31 -07:00
Mitchell Hashimoto
83ba2b9825 apprt/gtk: clean up keyval_unicode usage 2023-08-16 12:51:00 -07:00
Mitchell Hashimoto
1a918bc64b apprt/gtk: call new key2callback using the all-in-one key event 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
c254a8b09e input: encoding should always write to the buf 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
aadb78394b input: legacy encoding never emits sequence during dead key state 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
9b90692fc7 core: start on key2Callback for the new callback that uses KeyEncoder 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
a2d4e7ce29 input: legacy key encoding handles alt-as-esc for general utf8 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
871f797758 input: KeyEncoder handles the charCallback stuff now too 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
6555bb1410 input: KeyEncoder legacy encoding handles old keyCallback logic 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
f57fd99d3e input: starting to work on KeyEncoder, got ctrl sequences 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
62081a51b0 core: add KeyEvent 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
01282d3d15 core: process fixterms sequences for modified unicode characters 2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
759ae94f15 macos: do not send ctrl or super into UCKeyTranslate
see comment
2023-08-16 12:48:48 -07:00
Mitchell Hashimoto
e74a173704 apprt/gtk: translate keyval if there is no utf8
This is the same fix as #287 but for GTK.
2023-08-16 12:47:51 -07:00
Mitchell Hashimoto
8ca8da38d8 Merge pull request #291 from mitchellh/grapheme-sel
Fix multiple bugs related to selecting, copying grapheme clusters
2023-08-15 15:57:26 -07:00
Mitchell Hashimoto
40c8fa4907 Merge pull request #288 from mitchellh/push-pop-mode
Save/restore CSI sequences (CSI ? s, CSI ? r)
2023-08-15 15:34:44 -07:00
Mitchell Hashimoto
9e27dcdec9 font: shaper doesn't split run on selection if selection splits grapheme 2023-08-15 15:32:10 -07:00
Mitchell Hashimoto
c8d1745791 terminal: selection string must include grapheme data 2023-08-15 14:55:43 -07:00
Mitchell Hashimoto
67fb8d9bd4 terminal: do not crash if selecting a wide spacer on a soft-wrapped line 2023-08-15 14:38:13 -07:00
Mitchell Hashimoto
6a4b25714a terminal: add a test to verify our grapheme state is what we expect 2023-08-15 13:55:35 -07:00
Mitchell Hashimoto
ab68569281 renderer/opengl: fix compilation for new modes style 2023-08-15 13:33:06 -07:00
Mitchell Hashimoto
d0bf6a914f termio: on restore mode we need to call setMode no matter what 2023-08-15 11:47:31 -07:00
Mitchell Hashimoto
06f82ad713 terminal: parse and handle save/restore mode (CSI ? s, CSI ? r) 2023-08-15 11:43:07 -07:00
Mitchell Hashimoto
951aa00c63 terminal: move to new modes struct 2023-08-15 11:30:33 -07:00
Mitchell Hashimoto
c5439ca516 Merge pull request #287 from mitchellh/macos-key
apprt/embedded: keycallback should use nomod text to determine key
2023-08-15 11:15:36 -07:00
Mitchell Hashimoto
2b2b23dcf6 apprt/embedded: keycallback should use nomod text to determine key
To determine the logical key that was pressed, we previously just
trusted that the translated text would have the right value. But if
modifiers are pressed, the text may not translate.

For example on macOS, Ctrl+C does not produce any text. As a result, we
would fall back to the physical key. On layouts like Dvorak, the
physical key for "C" is "I". This means "Ctrl+C" sequences weren't
working.

Instead, if there is no text or the text doesn't map to a key, we
translate again using no modifiers to try to get the raw text of the
input and then base the key on that.
2023-08-15 11:13:01 -07:00
Mitchell Hashimoto
716c343f07 terminal: ModeState can save/restore one set of modes 2023-08-15 08:43:25 -07:00
Mitchell Hashimoto
e467a48df0 terminal: working on new modes storage abstraction 2023-08-15 08:43:24 -07:00
Mitchell Hashimoto
d27bc1f0fe termio: send VT220 device attributes on request, add secondary 2023-08-15 08:21:48 -07:00
Mitchell Hashimoto
2e54a825bf modify keys state 2 depends on some scenarios
Trying to port xterms logic...
2023-08-14 21:17:12 -07:00
Mitchell Hashimoto
28ff9118b0 Merge pull request #286 from mitchellh/modify-keys-ctrl
modifyOtherKeys state 2 should send sequences for all chars
2023-08-14 18:18:59 -07:00
Mitchell Hashimoto
a1e70afbb1 modifyOtherKeys state 2 should send sequences for all chars
See:
https://github.com/mitchellh/ghostty/issues/242#issuecomment-1678268533

Quoted:
@hovsater OKAY! I've consulted _the source_, i.e. `xterm`. None of the other reference material was illuminating and there is so much conflicting implementation out there and so very few terminals actually support `modifyOtherKeys`. I believe I've figured it out.

I believe that `C-S-h` is only supported via `modifyOtherKeys` state 2. iTerm emits it for state 1 but I think this is a mistake and I can't get any other terminal to do it, including `xterm`.

Here is my test script on Linux:

```
printf "\x1b[>4;1m" # change to "2" for state 2
showkey -a
```

With state 1, I couldn't get any terminal to output anything for `C-S-h`. **But with state 2, xterm outputs: ** `CSI 27;6;72~`. One thing to note is 72 is `H` (uppercase), so in even this case, iTerm appears to be sending the wrong code or `dte -K` is outputting the wrong case (less likely I think).

When I launch `dte` (the full editor), it only requests `modifyOtherKeys` state 1. So, with only `modifyOtherKeys` support, it shouldn't get access to `C-S-h`.

Note that I couldn't get any terminal on macOS to show the same sequences as xterm under any circumstance. I also cracked open the `xterm` source and I only eyeballed it but I believe this is not sending the sequences under state 1: https://sourcegraph.com/github.com/ThomasDickey/xterm-snapshots@c2b36af8d216926b8931c6f9cebefd69228e437c/-/blob/input.c?L579

**I could be very wrong, I'm not confident.** Every implementation (and there are only few) seems different and the behaviors are not consistent at all. Hence, I'm falling back to `xterm`, but even then I could be reading the source wrong. But when I ran `xterm` manually I could only get `C-S-h` to show up in state 2.
2023-08-14 17:53:20 -07:00
Mitchell Hashimoto
9d89c56bfc Merge pull request #285 from mitchellh/left-right-alt
macos: option-as-alt can specify left or right option key
2023-08-14 13:20:46 -07:00
Mitchell Hashimoto
cbd6a325e9 config: macos-option-as-alt now accepts "left", "right" 2023-08-14 12:50:21 -07:00
Mitchell Hashimoto
721087be76 macos: send the left/right status of modifier keys 2023-08-14 12:40:48 -07:00
Mitchell Hashimoto
e7bb9c60b2 input: expand Mods size, convert everything to use it 2023-08-14 12:31:16 -07:00
Mitchell Hashimoto
3556cf8407 input: unify binding-sensitive mods to a single func 2023-08-14 11:51:10 -07:00
Mitchell Hashimoto
2e69b22fcf Merge pull request #282 from mitchellh/kitty-keys
Many keyboard input improvements (no Kitty protocol yet)
2023-08-13 16:30:25 -07:00
Mitchell Hashimoto
49a9d626ec apprt/gtk: convert keyval to unicode if input method doesn't process
See comment for details.
2023-08-13 16:27:46 -07:00
Mitchell Hashimoto
a2310afa4e terminal: ignore ESC \ which enables ST mode since we're always in it 2023-08-13 15:52:38 -07:00
Mitchell Hashimoto
aec342918b input: various more helpers 2023-08-13 15:38:30 -07:00
Mitchell Hashimoto
cea6f5f51d terminal: parse mode 1039 2023-08-13 15:15:11 -07:00
Mitchell Hashimoto
6fb9a113c1 apprt/glfw: send mods to charcallback 2023-08-13 15:12:25 -07:00
Mitchell Hashimoto
4a384aa272 parse and respect mode 1036 2023-08-13 15:12:13 -07:00