mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 17:26:09 +03:00
gtk: silence bad accelerator warnings
Before this a commit a keybind of CTRL + \ would create a GTK accelerator of <Ctrl>\, which is incorrect. It needs to be <Ctrl>backslash, which can be retrieved with gdk_keyval_name(). Signed-off-by: Tristan Partin <tristan@partin.io>
This commit is contained in:
@ -20,7 +20,13 @@ pub fn accelFromTrigger(buf: []u8, trigger: input.Binding.Trigger) !?[:0]const u
|
||||
try writer.writeAll(std.mem.sliceTo(c.gdk_keyval_name(keyval), 0));
|
||||
},
|
||||
|
||||
.unicode => |cp| try writer.print("{u}", .{cp}),
|
||||
.unicode => |cp| {
|
||||
if (c.gdk_keyval_name(cp)) |name| {
|
||||
try writer.writeAll(std.mem.sliceTo(name, 0));
|
||||
} else {
|
||||
try writer.print("{u}", .{cp});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// We need to make the string null terminated.
|
||||
@ -74,6 +80,11 @@ test "accelFromTrigger" {
|
||||
.mods = .{ .super = true },
|
||||
.key = .{ .translated = .q },
|
||||
})).?);
|
||||
|
||||
try testing.expectEqualStrings("<Shift><Ctrl><Alt><Super>backslash", (try accelFromTrigger(&buf, .{
|
||||
.mods = .{ .ctrl = true, .alt = true, .super = true, .shift = true },
|
||||
.key = .{ .unicode = 92 },
|
||||
})).?);
|
||||
}
|
||||
|
||||
/// A raw entry in the keymap. Our keymap contains mappings between
|
||||
|
Reference in New Issue
Block a user