mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-29 02:21:43 +00:00
input: extract mouse encoding to a pure, testable file
Move mouse event encoding logic from Surface.zig into a new input/mouse_encode.zig file. The new file encapsulates event filtering (shouldReport), button code computation, viewport bounds checking, motion deduplication, and all five wire formats (X10, UTF-8, SGR, urxvt, SGR-pixels). This makes the encoding independently testable and adds unit tests covering each format and edge case. Additionally, Surface `mouseReport` can no longer fail, since the only failure mode is no buffer space which should be impossible. Updated the signature to remove the error set.
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// The type of action associated with a mouse event. This is different
|
||||
/// from ButtonState because button state is simply the current state
|
||||
/// of a mouse button but an action is something that triggers via
|
||||
/// an GUI event and supports more.
|
||||
pub const Action = enum { press, release, motion };
|
||||
|
||||
/// The state of a mouse button.
|
||||
///
|
||||
/// This is backed by a c_int so we can use this as-is for our embedding API.
|
||||
|
||||
Reference in New Issue
Block a user