mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
input: printable, comment on what magic indexes mean
This commit is contained in:
@ -243,4 +243,77 @@ pub const Key = enum(c_int) {
|
|||||||
else => null,
|
else => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// True if this key represents a printable character.
|
||||||
|
pub fn printable(self: Key) bool {
|
||||||
|
return switch (self) {
|
||||||
|
.a,
|
||||||
|
.b,
|
||||||
|
.c,
|
||||||
|
.d,
|
||||||
|
.e,
|
||||||
|
.f,
|
||||||
|
.g,
|
||||||
|
.h,
|
||||||
|
.i,
|
||||||
|
.j,
|
||||||
|
.k,
|
||||||
|
.l,
|
||||||
|
.m,
|
||||||
|
.n,
|
||||||
|
.o,
|
||||||
|
.p,
|
||||||
|
.q,
|
||||||
|
.r,
|
||||||
|
.s,
|
||||||
|
.t,
|
||||||
|
.u,
|
||||||
|
.v,
|
||||||
|
.w,
|
||||||
|
.x,
|
||||||
|
.y,
|
||||||
|
.z,
|
||||||
|
.zero,
|
||||||
|
.one,
|
||||||
|
.two,
|
||||||
|
.three,
|
||||||
|
.four,
|
||||||
|
.five,
|
||||||
|
.six,
|
||||||
|
.seven,
|
||||||
|
.eight,
|
||||||
|
.nine,
|
||||||
|
.semicolon,
|
||||||
|
.space,
|
||||||
|
.apostrophe,
|
||||||
|
.comma,
|
||||||
|
.grave_accent,
|
||||||
|
.period,
|
||||||
|
.slash,
|
||||||
|
.minus,
|
||||||
|
.equal,
|
||||||
|
.left_bracket,
|
||||||
|
.right_bracket,
|
||||||
|
.backslash,
|
||||||
|
.kp_0,
|
||||||
|
.kp_1,
|
||||||
|
.kp_2,
|
||||||
|
.kp_3,
|
||||||
|
.kp_4,
|
||||||
|
.kp_5,
|
||||||
|
.kp_6,
|
||||||
|
.kp_7,
|
||||||
|
.kp_8,
|
||||||
|
.kp_9,
|
||||||
|
.kp_decimal,
|
||||||
|
.kp_divide,
|
||||||
|
.kp_multiply,
|
||||||
|
.kp_subtract,
|
||||||
|
.kp_add,
|
||||||
|
.kp_equal,
|
||||||
|
=> true,
|
||||||
|
|
||||||
|
else => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,14 +8,12 @@ const Key = @import("key.zig").Key;
|
|||||||
|
|
||||||
/// The full list of entries for the current platform.
|
/// The full list of entries for the current platform.
|
||||||
pub const entries: []const Entry = entries: {
|
pub const entries: []const Entry = entries: {
|
||||||
const native_idx = if (builtin.target.isDarwin())
|
const native_idx = switch (builtin.os.tag) {
|
||||||
4
|
.macos => 4, // mac
|
||||||
else if (builtin.target.isWindows())
|
.windows => 3, // win
|
||||||
3
|
.linux => 2, // xkb
|
||||||
else if (builtin.target.isLinux())
|
else => @compileError("unsupported platform"),
|
||||||
2
|
};
|
||||||
else
|
|
||||||
@compileError("unsupported platform");
|
|
||||||
|
|
||||||
var result: [raw_entries.len]Entry = undefined;
|
var result: [raw_entries.len]Entry = undefined;
|
||||||
for (raw_entries, 0..) |raw, i| {
|
for (raw_entries, 0..) |raw, i| {
|
||||||
|
Reference in New Issue
Block a user