Created
August 15, 2025 10:31
-
-
Save trmcnvn/2e22c986bd4db315a230bc386e6d8c97 to your computer and use it in GitHub Desktop.
Patching Ghostty for caps lock -> escape rebinding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Commit ID: b9104392d70a94e65c904abaa91f0ea519935310 | |
| Change ID: nxwpumuvrsnyuxovlzlytstqzvxpsqml | |
| Author : trmcnvn <[email protected]> (1 month ago) | |
| Committer: trmcnvn <[email protected]> (7 seconds ago) | |
| patch: caps-lock -> escape | |
| diff --git a/src/apprt/gtk-ng/class/surface.zig b/src/apprt/gtk-ng/class/surface.zig | |
| index 9fa82f4eee..90926857e6 100644 | |
| --- a/src/apprt/gtk-ng/class/surface.zig | |
| +++ b/src/apprt/gtk-ng/class/surface.zig | |
| @@ -885,6 +885,33 @@ | |
| break :consumed gtk_key.translateMods(@bitCast(masked)); | |
| }; | |
| + const key = if (!priv.im_composing) key: { | |
| + if (gtk_key.keyFromKeyval(keyval)) |key| { | |
| + break :key key; | |
| + } | |
| + if (priv.im_len > 0) { | |
| + if (input.Key.fromASCII(priv.im_buf[0])) |key| { | |
| + break :key key; | |
| + } | |
| + } | |
| + if (keyval_unicode != 0) { | |
| + if (std.math.cast(u8, keyval_unicode)) |byte| { | |
| + if (input.Key.fromASCII(byte)) |key| { | |
| + break :key key; | |
| + } | |
| + } | |
| + } | |
| + if (std.math.cast(u8, keyval_unicode_unshifted)) |ascii| { | |
| + if (input.Key.fromASCII(ascii)) |key| { | |
| + break :key key; | |
| + } | |
| + } | |
| + if (priv.im_len > 0 or keyval_unicode_unshifted != 0) { | |
| + break :key .unidentified; | |
| + } | |
| + break :key physical_key; | |
| + } else .unidentified; | |
| + | |
| // log.debug("key pressed key={} keyval={x} physical_key={} composing={} text_len={} mods={}", .{ | |
| // key, | |
| // keyval, | |
| @@ -915,7 +942,7 @@ | |
| const surface = priv.core_surface orelse return false; | |
| const effect = surface.keyCallback(.{ | |
| .action = action, | |
| - .key = physical_key, | |
| + .key = key, | |
| .mods = mods, | |
| .consumed_mods = consumed_mods, | |
| .composing = priv.im_composing, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment