mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-02 07:58:37 +00:00
terminal: use LibEnum for the command keys
This commit is contained in:
@@ -35,7 +35,8 @@ pub fn Enum(
|
||||
fields_i += 1;
|
||||
}
|
||||
|
||||
return @Type(.{ .@"enum" = .{
|
||||
// Assigned to var so that the type name is nicer in stack traces.
|
||||
const Result = @Type(.{ .@"enum" = .{
|
||||
.tag_type = switch (target) {
|
||||
.c => c_int,
|
||||
.zig => std.math.IntFittingRange(0, fields_i - 1),
|
||||
@@ -44,6 +45,7 @@ pub fn Enum(
|
||||
.decls = &.{},
|
||||
.is_exhaustive = true,
|
||||
} });
|
||||
return Result;
|
||||
}
|
||||
|
||||
pub const Target = union(enum) {
|
||||
|
@@ -1,5 +1,8 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// True if we're building the C library libghostty-vt.
|
||||
pub const is_c_lib = @import("root") == @import("../lib_vt.zig");
|
||||
|
||||
pub const Options = struct {
|
||||
/// The target artifact to build. This will gate some functionality.
|
||||
artifact: Artifact,
|
||||
|
@@ -63,7 +63,7 @@ pub const Attribute = sgr.Attribute;
|
||||
pub const isSafePaste = sanitize.isSafePaste;
|
||||
|
||||
/// This is set to true when we're building the C library.
|
||||
pub const is_c_lib = @import("root") == @import("../lib_vt.zig");
|
||||
pub const is_c_lib = @import("build_options.zig").is_c_lib;
|
||||
pub const c_api = @import("c/main.zig");
|
||||
|
||||
test {
|
||||
|
@@ -10,6 +10,8 @@ const builtin = @import("builtin");
|
||||
const mem = std.mem;
|
||||
const assert = std.debug.assert;
|
||||
const Allocator = mem.Allocator;
|
||||
const LibEnum = @import("../lib/enum.zig").Enum;
|
||||
const is_c_lib = @import("build_options.zig").is_c_lib;
|
||||
const RGB = @import("color.zig").RGB;
|
||||
const kitty_color = @import("kitty/color.zig");
|
||||
const osc_color = @import("osc/color.zig");
|
||||
@@ -17,7 +19,7 @@ pub const color = osc_color;
|
||||
|
||||
const log = std.log.scoped(.osc);
|
||||
|
||||
pub const Command = union(enum) {
|
||||
pub const Command = union(Key) {
|
||||
/// This generally shouldn't ever be set except as an initial zero value.
|
||||
/// Ignore it.
|
||||
invalid,
|
||||
@@ -172,6 +174,34 @@ pub const Command = union(enum) {
|
||||
/// ConEmu GUI macro (OSC 9;6)
|
||||
conemu_guimacro: []const u8,
|
||||
|
||||
pub const Key = LibEnum(
|
||||
if (is_c_lib) .c else .zig,
|
||||
// NOTE: Order matters, see LibEnum documentation.
|
||||
&.{
|
||||
"invalid",
|
||||
"change_window_title",
|
||||
"change_window_icon",
|
||||
"prompt_start",
|
||||
"prompt_end",
|
||||
"end_of_input",
|
||||
"end_of_command",
|
||||
"clipboard_contents",
|
||||
"report_pwd",
|
||||
"mouse_shape",
|
||||
"color_operation",
|
||||
"kitty_color_protocol",
|
||||
"show_desktop_notification",
|
||||
"hyperlink_start",
|
||||
"hyperlink_end",
|
||||
"conemu_sleep",
|
||||
"conemu_show_message_box",
|
||||
"conemu_change_tab_title",
|
||||
"conemu_progress_report",
|
||||
"conemu_wait_input",
|
||||
"conemu_guimacro",
|
||||
},
|
||||
);
|
||||
|
||||
pub const ProgressReport = struct {
|
||||
pub const State = enum(c_int) {
|
||||
remove,
|
||||
|
Reference in New Issue
Block a user