Merge pull request #2200 from tristan957/gtk-accel-warning

gtk: silence bad accelerator warnings
This commit is contained in:
Mitchell Hashimoto
2024-09-05 18:20:53 -07:00
committed by GitHub

View File

@ -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)); 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. // We need to make the string null terminated.
@ -74,6 +80,11 @@ test "accelFromTrigger" {
.mods = .{ .super = true }, .mods = .{ .super = true },
.key = .{ .translated = .q }, .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 /// A raw entry in the keymap. Our keymap contains mappings between