diff --git a/src/input/mouse_encode.zig b/src/input/mouse_encode.zig index 9dceb0ab3..0cf431303 100644 --- a/src/input/mouse_encode.zig +++ b/src/input/mouse_encode.zig @@ -93,7 +93,7 @@ pub fn encode( // If we don't have a motion-tracking event mode, do nothing, // because events outside the viewport are never reported in // such cases. - if (!opts.event.motion()) return; + if (!terminal.mouse.eventSendsMotion(opts.event)) return; // For motion modes, we only report if a button is currently pressed. // This lets a TUI detect a click over the surface + drag out diff --git a/src/terminal/mouse.zig b/src/terminal/mouse.zig index 758369ae9..e72e166f7 100644 --- a/src/terminal/mouse.zig +++ b/src/terminal/mouse.zig @@ -1,31 +1,32 @@ const std = @import("std"); const build_options = @import("terminal_options"); const lib = @import("../lib/main.zig"); +const lib_target: lib.Target = if (build_options.c_abi) .c else .zig; /// The event types that can be reported for mouse-related activities. /// These are all mutually exclusive (hence in a single enum). -pub const Event = enum(u3) { - none = 0, - x10 = 1, // 9 - normal = 2, // 1000 - button = 3, // 1002 - any = 4, // 1003 +pub const Event = lib.Enum(lib_target, &.{ + "none", + "x10", // 9 + "normal", // 1000 + "button", // 1002 + "any", // 1003 +}); - /// Returns true if this event sends motion events. - pub fn motion(self: Event) bool { - return self == .button or self == .any; - } -}; +/// Returns true if this event sends motion events. +pub fn eventSendsMotion(event: Event) bool { + return event == .button or event == .any; +} /// The format of mouse events when enabled. /// These are all mutually exclusive (hence in a single enum). -pub const Format = enum(u3) { - x10 = 0, - utf8 = 1, // 1005 - sgr = 2, // 1006 - urxvt = 3, // 1015 - sgr_pixels = 4, // 1016 -}; +pub const Format = lib.Enum(lib_target, &.{ + "x10", + "utf8", // 1005 + "sgr", // 1006 + "urxvt", // 1015 + "sgr_pixels", // 1016 +}); /// The possible cursor shapes. Not all app runtimes support these shapes. /// The shapes are always based on the W3C supported cursor styles so we