117 Commits

Author SHA1 Message Date
Mitchell Hashimoto
167bf6f098 font: DeferredFace can no longer represent a loaded face 2023-08-25 13:28:46 -07:00
Mitchell Hashimoto
ad6c2b6cc8 font: move auto-italicization to Group 2023-08-25 13:16:42 -07:00
Mitchell Hashimoto
f2f2b1eaf1 termio/exec: initial subprocess screen size should be sub padding 2023-08-24 08:45:32 -07:00
Mitchell Hashimoto
3ca759bac6 core: send pixel-level surface sizing to the pty 2023-08-20 22:03:19 -07:00
Mitchell Hashimoto
7ccf86b175 remove imgui and devmode
imgui has been a source of compilation challenges (our fault not theirs)
and devmode hasn't worked in awhile, so drop it.
2023-08-20 08:50:24 -07:00
Mitchell Hashimoto
95b88d38c2 mouse scroll events were flipped for non-cursor key events
Fixes #302
2023-08-18 08:45:24 -07:00
Mitchell Hashimoto
37daf02804 core: use Kitty encoding if enabled 2023-08-17 09:02:43 -07:00
Mitchell Hashimoto
07d722b77e bindings should not use consumed modifiers
Over time, they probably should, but GTK is a bit too aggressive right
now with consumed modifiers and I need to take a closer look at that.
2023-08-16 17:09: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
1a918bc64b apprt/gtk: call new key2callback using the all-in-one key event 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
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
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
951aa00c63 terminal: move to new modes struct 2023-08-15 11:30:33 -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
2e54a825bf modify keys state 2 depends on some scenarios
Trying to port xterms logic...
2023-08-14 21:17:12 -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
cbd6a325e9 config: macos-option-as-alt now accepts "left", "right" 2023-08-14 12:50:21 -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
4a384aa272 parse and respect mode 1036 2023-08-13 15:12:13 -07:00
Mitchell Hashimoto
66aa1d9be3 terminal: parse and handle set modify key format (ESC[>{a};{b}m) 2023-08-13 14:55:32 -07:00
Mitchell Hashimoto
d94474463b terminal: handle set application keypad mode (both ESC and modes) 2023-08-13 14:55:32 -07:00
Mitchell Hashimoto
c0736676ce core: match and emit function keys 2023-08-13 14:55:32 -07:00
Mitchell Hashimoto
5e2fa50d0b macos-option-as-alt config, handle alt-prefix for charCallback 2023-08-13 14:55:31 -07:00
Mitchell Hashimoto
c964a3f4c8 core: translate alt- prefix to an esc (0x1B) prefix 2023-08-13 14:55:31 -07:00
Mitchell Hashimoto
387c62d226 add more ctrl key sequencs for legacy ascii 2023-08-13 14:55:29 -07:00
Mitchell Hashimoto
619d2ade3e only initialize font discovery mechanism once, cache on App
Fontconfig in particular appears unsafe to initialize multiple times.

Font discovery is a singleton object in an application and only ever
accessed from the main thread so we can work around this by only
initializing and caching the font discovery mechanism exactly once on
the app singleton.
2023-08-13 08:01:33 -07:00
Mitchell Hashimoto
d62161e2c3 support preedit text rendering in core and metal 2023-08-11 12:20:48 -07:00
Mitchell Hashimoto
65c4aada02 input: rename "unmapped" to "physical" 2023-08-11 12:02:01 -07:00
Mitchell Hashimoto
ce4eb2112c core: get rid of ignore_char, apprt must handle this now 2023-08-11 12:02:01 -07:00
Mitchell Hashimoto
4fe739cae0 core: note when keyCallback processed the input 2023-08-11 12:02:00 -07:00
Mitchell Hashimoto
68cb3288be do not process charCallback if control character was processed
Fixes #267

We have a mechanism `ignore_char` to ignore the `charCallback` exactly
once. It is guaranteed by all app runtimes that `keyCallback` is called
before `charCallback` and that they're called in order by key press
(you'll never get 3 `keyCallbacks` and then `charCallback` for the first
press).

We use this for example to ensure that if you bind `a` to something,
that we never actually print 'a', since the binding consumes it.

This commit sets `ignore_char` whenever we detect a key that should be
translated to a control character and written to the pty. As the comment
in the code states: we probably should've been doing this anyways. It is
a complete mystery why macOS behaves the way it does that caused us to
figure this out.
2023-08-10 11:51:11 -07:00
Mitchell Hashimoto
688ab84661 apprt/embedded: allow noting that selection clipboard is not supported 2023-08-09 14:52:22 -07:00
Mitchell Hashimoto
5d6086a1b1 "copy-on-select" configuation to disable 2023-08-09 14:44:24 -07:00
Mitchell Hashimoto
347c60d9bd selection copies to the selection clipboard 2023-08-09 14:00:48 -07:00
Mitchell Hashimoto
f3996ff0f8 apprt: primary clipboard awareness (selection clipboard) 2023-08-09 13:41:22 -07:00
Mitchell Hashimoto
6cf22f841c ctrl+backspace should send 0x08
Fixes #260
2023-08-09 10:16:23 -07:00
Mitchell Hashimoto
0ed76b4300 scroll_page_fractional keybinding 2023-08-09 07:37:18 -07:00
Mitchell Hashimoto
a8380e937d scroll top, bot, page up, page down binding actions 2023-08-09 07:24:11 -07:00
Mitchell Hashimoto
7ac61469c9 bind sequences for PC style function keys from xterm
Fixes #256

This makes a whole lot more sequences work, such as `ctrl+left`,
`ctrl+shift+f1`, etc. We were just missing these completely.

This also found an issue where if you split a sequence across two
`write()` syscalls, then `/bin/sh` (I didn't test other shells)
treats it as two literals rather than parsing as a single sequence.
Great.
2023-08-08 16:43:27 -07:00
Mitchell Hashimoto
bfe6cfeb1a keyboard bindings should never take caps/num lock into account 2023-08-08 10:58:05 -07:00
Mitchell Hashimoto
6b45d931c3 plumb through the resources dir to termio 2023-08-08 09:29:38 -07:00
Kevin Hovsäter
22b8173164 Fix typos 2023-08-08 14:27:34 +02:00
Mitchell Hashimoto
22296b377a Revert "Merge pull request #244 from mitchellh/alt-as-esc"
This reverts commit c139279d479682c17f63d9b57c2d56608d09d16a, reversing
changes made to 4ed21047a734d7c586debe0026e3b6ea90ed1622.

We do want to do this but this broke bindings.
2023-08-07 17:06:40 -07:00
Mitchell Hashimoto
67cbabd605 make keyboard modifiers left/right-aware throughout core 2023-08-07 14:33:56 -07:00
Mitchell Hashimoto
0bb286eeb2 C API for invoking bindings 2023-08-05 14:46:47 -07:00
Mitchell Hashimoto
437c1ca261 only send resize messages to renderer/io thread if changes happen
Previously, we'd send renderer screen size updates and termio sigwnch
updates on every single resize event even if the screen size or grid
sizes didn't change. This is super noisy and given how many resize
events macOS sends, its also very expensive.

This commit makes it so that we only update the renderer if the screen
changed. If the screen size didn't change, the grid size couldn't have
changed either.

If the screen size did change, its still possible the grid size didn't
change since Ghostty supports fluid pixel-level resizing. We have to
send the screen size event to the renderer so all the GPU shader vars
are right but we do not have to send a termio event.

So, only if the grid size changed do we then notify the pty that the
terminal dimensions changed. Note that the resize event for ptys does
have a pixel-level x/y but I don't think the granularity is useful
beyond grid changes.
2023-08-04 19:50:21 -07:00