macOS: build

This commit is contained in:
Mitchell Hashimoto
2025-05-08 10:58:41 -07:00
parent 24d433333b
commit b991d36343
5 changed files with 379 additions and 476 deletions

View File

@@ -270,7 +270,7 @@ pub const Action = enum(c_int) {
/// UTF-8 and are produced by the associated apprt. Ghostty core has
/// no mechanism to map input events to strings without the apprt.
///
/// IMPORTANT: Any changes here update include/ghostty.h
/// IMPORTANT: Any changes here update include/ghostty.h ghostty_input_key_e
pub const Key = enum(c_int) {
unidentified,
@@ -618,61 +618,61 @@ pub const Key = enum(c_int) {
/// Returns the cimgui key constant for this key.
pub fn imguiKey(self: Key) ?c_uint {
return switch (self) {
.a => cimgui.c.ImGuiKey_A,
.b => cimgui.c.ImGuiKey_B,
.c => cimgui.c.ImGuiKey_C,
.d => cimgui.c.ImGuiKey_D,
.e => cimgui.c.ImGuiKey_E,
.f => cimgui.c.ImGuiKey_F,
.g => cimgui.c.ImGuiKey_G,
.h => cimgui.c.ImGuiKey_H,
.i => cimgui.c.ImGuiKey_I,
.j => cimgui.c.ImGuiKey_J,
.k => cimgui.c.ImGuiKey_K,
.l => cimgui.c.ImGuiKey_L,
.m => cimgui.c.ImGuiKey_M,
.n => cimgui.c.ImGuiKey_N,
.o => cimgui.c.ImGuiKey_O,
.p => cimgui.c.ImGuiKey_P,
.q => cimgui.c.ImGuiKey_Q,
.r => cimgui.c.ImGuiKey_R,
.s => cimgui.c.ImGuiKey_S,
.t => cimgui.c.ImGuiKey_T,
.u => cimgui.c.ImGuiKey_U,
.v => cimgui.c.ImGuiKey_V,
.w => cimgui.c.ImGuiKey_W,
.x => cimgui.c.ImGuiKey_X,
.y => cimgui.c.ImGuiKey_Y,
.z => cimgui.c.ImGuiKey_Z,
.key_a => cimgui.c.ImGuiKey_A,
.key_b => cimgui.c.ImGuiKey_B,
.key_c => cimgui.c.ImGuiKey_C,
.key_d => cimgui.c.ImGuiKey_D,
.key_e => cimgui.c.ImGuiKey_E,
.key_f => cimgui.c.ImGuiKey_F,
.key_g => cimgui.c.ImGuiKey_G,
.key_h => cimgui.c.ImGuiKey_H,
.key_i => cimgui.c.ImGuiKey_I,
.key_j => cimgui.c.ImGuiKey_J,
.key_k => cimgui.c.ImGuiKey_K,
.key_l => cimgui.c.ImGuiKey_L,
.key_m => cimgui.c.ImGuiKey_M,
.key_n => cimgui.c.ImGuiKey_N,
.key_o => cimgui.c.ImGuiKey_O,
.key_p => cimgui.c.ImGuiKey_P,
.key_q => cimgui.c.ImGuiKey_Q,
.key_r => cimgui.c.ImGuiKey_R,
.key_s => cimgui.c.ImGuiKey_S,
.key_t => cimgui.c.ImGuiKey_T,
.key_u => cimgui.c.ImGuiKey_U,
.key_v => cimgui.c.ImGuiKey_V,
.key_w => cimgui.c.ImGuiKey_W,
.key_x => cimgui.c.ImGuiKey_X,
.key_y => cimgui.c.ImGuiKey_Y,
.key_z => cimgui.c.ImGuiKey_Z,
.zero => cimgui.c.ImGuiKey_0,
.one => cimgui.c.ImGuiKey_1,
.two => cimgui.c.ImGuiKey_2,
.three => cimgui.c.ImGuiKey_3,
.four => cimgui.c.ImGuiKey_4,
.five => cimgui.c.ImGuiKey_5,
.six => cimgui.c.ImGuiKey_6,
.seven => cimgui.c.ImGuiKey_7,
.eight => cimgui.c.ImGuiKey_8,
.nine => cimgui.c.ImGuiKey_9,
.digit_0 => cimgui.c.ImGuiKey_0,
.digit_1 => cimgui.c.ImGuiKey_1,
.digit_2 => cimgui.c.ImGuiKey_2,
.digit_3 => cimgui.c.ImGuiKey_3,
.digit_4 => cimgui.c.ImGuiKey_4,
.digit_5 => cimgui.c.ImGuiKey_5,
.digit_6 => cimgui.c.ImGuiKey_6,
.digit_7 => cimgui.c.ImGuiKey_7,
.digit_8 => cimgui.c.ImGuiKey_8,
.digit_9 => cimgui.c.ImGuiKey_9,
.semicolon => cimgui.c.ImGuiKey_Semicolon,
.space => cimgui.c.ImGuiKey_Space,
.apostrophe => cimgui.c.ImGuiKey_Apostrophe,
.quote => cimgui.c.ImGuiKey_Apostrophe,
.comma => cimgui.c.ImGuiKey_Comma,
.grave_accent => cimgui.c.ImGuiKey_GraveAccent,
.backquote => cimgui.c.ImGuiKey_GraveAccent,
.period => cimgui.c.ImGuiKey_Period,
.slash => cimgui.c.ImGuiKey_Slash,
.minus => cimgui.c.ImGuiKey_Minus,
.equal => cimgui.c.ImGuiKey_Equal,
.left_bracket => cimgui.c.ImGuiKey_LeftBracket,
.right_bracket => cimgui.c.ImGuiKey_RightBracket,
.bracket_left => cimgui.c.ImGuiKey_LeftBracket,
.bracket_right => cimgui.c.ImGuiKey_RightBracket,
.backslash => cimgui.c.ImGuiKey_Backslash,
.up => cimgui.c.ImGuiKey_UpArrow,
.down => cimgui.c.ImGuiKey_DownArrow,
.left => cimgui.c.ImGuiKey_LeftArrow,
.right => cimgui.c.ImGuiKey_RightArrow,
.arrow_up => cimgui.c.ImGuiKey_UpArrow,
.arrow_down => cimgui.c.ImGuiKey_DownArrow,
.arrow_left => cimgui.c.ImGuiKey_LeftArrow,
.arrow_right => cimgui.c.ImGuiKey_RightArrow,
.home => cimgui.c.ImGuiKey_Home,
.end => cimgui.c.ImGuiKey_End,
.insert => cimgui.c.ImGuiKey_Insert,
@@ -703,48 +703,47 @@ pub const Key = enum(c_int) {
.f11 => cimgui.c.ImGuiKey_F11,
.f12 => cimgui.c.ImGuiKey_F12,
.kp_0 => cimgui.c.ImGuiKey_Keypad0,
.kp_1 => cimgui.c.ImGuiKey_Keypad1,
.kp_2 => cimgui.c.ImGuiKey_Keypad2,
.kp_3 => cimgui.c.ImGuiKey_Keypad3,
.kp_4 => cimgui.c.ImGuiKey_Keypad4,
.kp_5 => cimgui.c.ImGuiKey_Keypad5,
.kp_6 => cimgui.c.ImGuiKey_Keypad6,
.kp_7 => cimgui.c.ImGuiKey_Keypad7,
.kp_8 => cimgui.c.ImGuiKey_Keypad8,
.kp_9 => cimgui.c.ImGuiKey_Keypad9,
.kp_decimal => cimgui.c.ImGuiKey_KeypadDecimal,
.kp_divide => cimgui.c.ImGuiKey_KeypadDivide,
.kp_multiply => cimgui.c.ImGuiKey_KeypadMultiply,
.kp_subtract => cimgui.c.ImGuiKey_KeypadSubtract,
.kp_add => cimgui.c.ImGuiKey_KeypadAdd,
.kp_enter => cimgui.c.ImGuiKey_KeypadEnter,
.kp_equal => cimgui.c.ImGuiKey_KeypadEqual,
.numpad_0 => cimgui.c.ImGuiKey_Keypad0,
.numpad_1 => cimgui.c.ImGuiKey_Keypad1,
.numpad_2 => cimgui.c.ImGuiKey_Keypad2,
.numpad_3 => cimgui.c.ImGuiKey_Keypad3,
.numpad_4 => cimgui.c.ImGuiKey_Keypad4,
.numpad_5 => cimgui.c.ImGuiKey_Keypad5,
.numpad_6 => cimgui.c.ImGuiKey_Keypad6,
.numpad_7 => cimgui.c.ImGuiKey_Keypad7,
.numpad_8 => cimgui.c.ImGuiKey_Keypad8,
.numpad_9 => cimgui.c.ImGuiKey_Keypad9,
.numpad_decimal => cimgui.c.ImGuiKey_KeypadDecimal,
.numpad_divide => cimgui.c.ImGuiKey_KeypadDivide,
.numpad_multiply => cimgui.c.ImGuiKey_KeypadMultiply,
.numpad_subtract => cimgui.c.ImGuiKey_KeypadSubtract,
.numpad_add => cimgui.c.ImGuiKey_KeypadAdd,
.numpad_enter => cimgui.c.ImGuiKey_KeypadEnter,
.numpad_equal => cimgui.c.ImGuiKey_KeypadEqual,
// We map KP_SEPARATOR to Comma because traditionally a numpad would
// have a numeric separator key. Most modern numpads do not
.kp_separator => cimgui.c.ImGuiKey_Comma,
.kp_left => cimgui.c.ImGuiKey_LeftArrow,
.kp_right => cimgui.c.ImGuiKey_RightArrow,
.kp_up => cimgui.c.ImGuiKey_UpArrow,
.kp_down => cimgui.c.ImGuiKey_DownArrow,
.kp_page_up => cimgui.c.ImGuiKey_PageUp,
.kp_page_down => cimgui.c.ImGuiKey_PageUp,
.kp_home => cimgui.c.ImGuiKey_Home,
.kp_end => cimgui.c.ImGuiKey_End,
.kp_insert => cimgui.c.ImGuiKey_Insert,
.kp_delete => cimgui.c.ImGuiKey_Delete,
.kp_begin => cimgui.c.ImGuiKey_NamedKey_BEGIN,
.numpad_left => cimgui.c.ImGuiKey_LeftArrow,
.numpad_right => cimgui.c.ImGuiKey_RightArrow,
.numpad_up => cimgui.c.ImGuiKey_UpArrow,
.numpad_down => cimgui.c.ImGuiKey_DownArrow,
.numpad_page_up => cimgui.c.ImGuiKey_PageUp,
.numpad_page_down => cimgui.c.ImGuiKey_PageUp,
.numpad_home => cimgui.c.ImGuiKey_Home,
.numpad_end => cimgui.c.ImGuiKey_End,
.numpad_insert => cimgui.c.ImGuiKey_Insert,
.numpad_delete => cimgui.c.ImGuiKey_Delete,
.numpad_begin => cimgui.c.ImGuiKey_NamedKey_BEGIN,
.left_shift => cimgui.c.ImGuiKey_LeftShift,
.left_control => cimgui.c.ImGuiKey_LeftCtrl,
.left_alt => cimgui.c.ImGuiKey_LeftAlt,
.left_super => cimgui.c.ImGuiKey_LeftSuper,
.right_shift => cimgui.c.ImGuiKey_RightShift,
.right_control => cimgui.c.ImGuiKey_RightCtrl,
.right_alt => cimgui.c.ImGuiKey_RightAlt,
.right_super => cimgui.c.ImGuiKey_RightSuper,
.shift_left => cimgui.c.ImGuiKey_LeftShift,
.control_left => cimgui.c.ImGuiKey_LeftCtrl,
.alt_left => cimgui.c.ImGuiKey_LeftAlt,
.meta_left => cimgui.c.ImGuiKey_LeftSuper,
.shift_right => cimgui.c.ImGuiKey_RightShift,
.control_right => cimgui.c.ImGuiKey_RightCtrl,
.alt_right => cimgui.c.ImGuiKey_RightAlt,
.meta_right => cimgui.c.ImGuiKey_RightSuper,
.invalid,
// These keys aren't represented in cimgui
.f13,
.f14,
.f15,
@@ -758,9 +757,51 @@ pub const Key = enum(c_int) {
.f23,
.f24,
.f25,
.intl_backslash,
.intl_ro,
.intl_yen,
.convert,
.kana_mode,
.non_convert,
.numpad_backspace,
.numpad_clear,
.numpad_clear_entry,
.numpad_comma,
.numpad_memory_add,
.numpad_memory_clear,
.numpad_memory_recall,
.numpad_memory_store,
.numpad_memory_subtract,
.numpad_paren_left,
.numpad_paren_right,
.@"fn",
.fn_lock,
.browser_back,
.browser_favorites,
.browser_forward,
.browser_home,
.browser_refresh,
.browser_search,
.browser_stop,
.eject,
.launch_app_1,
.launch_app_2,
.launch_mail,
.media_play_pause,
.media_select,
.media_stop,
.media_track_next,
.media_track_previous,
.power,
.sleep,
.audio_volume_down,
.audio_volume_mute,
.audio_volume_up,
.wake_up,
.help,
=> null,
// These keys aren't represented in cimgui
.plus,
.unidentified,
=> null,
};
}

View File

@@ -19,7 +19,7 @@ pub const entries: []const Entry = entries: {
for (raw_entries, 0..) |raw, i| {
@setEvalBranchQuota(10000);
result[i] = .{
.key = code_to_key.get(raw[5]) orelse .invalid,
.key = code_to_key.get(raw[5]) orelse .unidentified,
.usb = raw[0],
.code = raw[5],
.native = raw[native_idx],
@@ -45,42 +45,42 @@ pub const Entry = struct {
const code_to_key = code_to_key: {
@setEvalBranchQuota(5000);
break :code_to_key std.StaticStringMap(Key).initComptime(.{
.{ "KeyA", .a },
.{ "KeyB", .b },
.{ "KeyC", .c },
.{ "KeyD", .d },
.{ "KeyE", .e },
.{ "KeyF", .f },
.{ "KeyG", .g },
.{ "KeyH", .h },
.{ "KeyI", .i },
.{ "KeyJ", .j },
.{ "KeyK", .k },
.{ "KeyL", .l },
.{ "KeyM", .m },
.{ "KeyN", .n },
.{ "KeyO", .o },
.{ "KeyP", .p },
.{ "KeyQ", .q },
.{ "KeyR", .r },
.{ "KeyS", .s },
.{ "KeyT", .t },
.{ "KeyU", .u },
.{ "KeyV", .v },
.{ "KeyW", .w },
.{ "KeyX", .x },
.{ "KeyY", .y },
.{ "KeyZ", .z },
.{ "Digit1", .one },
.{ "Digit2", .two },
.{ "Digit3", .three },
.{ "Digit4", .four },
.{ "Digit5", .five },
.{ "Digit6", .six },
.{ "Digit7", .seven },
.{ "Digit8", .eight },
.{ "Digit9", .nine },
.{ "Digit0", .zero },
.{ "KeyA", .key_a },
.{ "KeyB", .key_b },
.{ "KeyC", .key_c },
.{ "KeyD", .key_d },
.{ "KeyE", .key_e },
.{ "KeyF", .key_f },
.{ "KeyG", .key_g },
.{ "KeyH", .key_h },
.{ "KeyI", .key_i },
.{ "KeyJ", .key_j },
.{ "KeyK", .key_k },
.{ "KeyL", .key_l },
.{ "KeyM", .key_m },
.{ "KeyN", .key_n },
.{ "KeyO", .key_o },
.{ "KeyP", .key_p },
.{ "KeyQ", .key_q },
.{ "KeyR", .key_r },
.{ "KeyS", .key_s },
.{ "KeyT", .key_t },
.{ "KeyU", .key_u },
.{ "KeyV", .key_v },
.{ "KeyW", .key_w },
.{ "KeyX", .key_x },
.{ "KeyY", .key_y },
.{ "KeyZ", .key_z },
.{ "Digit1", .digit_1 },
.{ "Digit2", .digit_2 },
.{ "Digit3", .digit_3 },
.{ "Digit4", .digit_4 },
.{ "Digit5", .digit_5 },
.{ "Digit6", .digit_6 },
.{ "Digit7", .digit_7 },
.{ "Digit8", .digit_8 },
.{ "Digit9", .digit_9 },
.{ "Digit0", .digit_0 },
.{ "Enter", .enter },
.{ "Escape", .escape },
.{ "Backspace", .backspace },
@@ -88,12 +88,12 @@ const code_to_key = code_to_key: {
.{ "Space", .space },
.{ "Minus", .minus },
.{ "Equal", .equal },
.{ "BracketLeft", .left_bracket },
.{ "BracketRight", .right_bracket },
.{ "BracketLeft", .bracket_left },
.{ "BracketRight", .bracket_left },
.{ "Backslash", .backslash },
.{ "Semicolon", .semicolon },
.{ "Quote", .apostrophe },
.{ "Backquote", .grave_accent },
.{ "Quote", .quote },
.{ "Backquote", .backquote },
.{ "Comma", .comma },
.{ "Period", .period },
.{ "Slash", .slash },
@@ -131,37 +131,37 @@ const code_to_key = code_to_key: {
.{ "Delete", .delete },
.{ "End", .end },
.{ "PageDown", .page_down },
.{ "ArrowRight", .right },
.{ "ArrowLeft", .left },
.{ "ArrowDown", .down },
.{ "ArrowUp", .up },
.{ "ArrowRight", .arrow_right },
.{ "ArrowLeft", .arrow_left },
.{ "ArrowDown", .arrow_down },
.{ "ArrowUp", .arrow_up },
.{ "NumLock", .num_lock },
.{ "NumpadDivide", .kp_divide },
.{ "NumpadMultiply", .kp_multiply },
.{ "NumpadSubtract", .kp_subtract },
.{ "NumpadAdd", .kp_add },
.{ "NumpadEnter", .kp_enter },
.{ "Numpad1", .kp_1 },
.{ "Numpad2", .kp_2 },
.{ "Numpad3", .kp_3 },
.{ "Numpad4", .kp_4 },
.{ "Numpad5", .kp_5 },
.{ "Numpad6", .kp_6 },
.{ "Numpad7", .kp_7 },
.{ "Numpad8", .kp_8 },
.{ "Numpad9", .kp_9 },
.{ "Numpad0", .kp_0 },
.{ "NumpadDecimal", .kp_decimal },
.{ "NumpadEqual", .kp_equal },
.{ "NumpadDivide", .numpad_divide },
.{ "NumpadMultiply", .numpad_multiply },
.{ "NumpadSubtract", .numpad_subtract },
.{ "NumpadAdd", .numpad_add },
.{ "NumpadEnter", .numpad_enter },
.{ "Numpad1", .numpad_1 },
.{ "Numpad2", .numpad_2 },
.{ "Numpad3", .numpad_3 },
.{ "Numpad4", .numpad_4 },
.{ "Numpad5", .numpad_5 },
.{ "Numpad6", .numpad_6 },
.{ "Numpad7", .numpad_7 },
.{ "Numpad8", .numpad_8 },
.{ "Numpad9", .numpad_9 },
.{ "Numpad0", .numpad_0 },
.{ "NumpadDecimal", .numpad_decimal },
.{ "NumpadEqual", .numpad_equal },
.{ "ContextMenu", .context_menu },
.{ "ControlLeft", .left_control },
.{ "ShiftLeft", .left_shift },
.{ "AltLeft", .left_alt },
.{ "MetaLeft", .left_super },
.{ "ControlRight", .right_control },
.{ "ShiftRight", .right_shift },
.{ "AltRight", .right_alt },
.{ "MetaRight", .right_super },
.{ "ControlLeft", .control_left },
.{ "ShiftLeft", .shift_left },
.{ "AltLeft", .alt_left },
.{ "MetaLeft", .meta_left },
.{ "ControlRight", .control_right },
.{ "ShiftRight", .shift_right },
.{ "AltRight", .alt_right },
.{ "MetaRight", .meta_right },
});
};