From 21f09a91594dab6064f679d81ecd798feca86104 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Mar 2024 20:45:39 -0800 Subject: [PATCH] remove point.Viewport --- src/Surface.zig | 6 +++--- src/renderer/State.zig | 2 +- src/terminal/PageList.zig | 2 +- src/terminal/point.zig | 11 ++--------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index b0cc4b7db..ccfbd732c 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -172,7 +172,7 @@ const Mouse = struct { left_click_time: std.time.Instant = undefined, /// The last x/y sent for mouse reports. - event_point: ?terminal.point.Viewport = null, + event_point: ?terminal.point.Coordinate = null, /// Pending scroll amounts for high-precision scrolls pending_scroll_x: f64 = 0, @@ -186,7 +186,7 @@ const Mouse = struct { /// The last x/y in the cursor position for links. We use this to /// only process link hover events when the mouse actually moves cells. - link_point: ?terminal.point.Viewport = null, + link_point: ?terminal.point.Coordinate = null, }; /// The configuration that a surface has, this is copied from the main @@ -2886,7 +2886,7 @@ pub fn colorSchemeCallback(self: *Surface, scheme: apprt.ColorScheme) !void { if (report) try self.reportColorScheme(); } -fn posToViewport(self: Surface, xpos: f64, ypos: f64) terminal.point.Viewport { +fn posToViewport(self: Surface, xpos: f64, ypos: f64) terminal.point.Coordinate { // xpos/ypos need to be adjusted for window padding // (i.e. "window-padding-*" settings. const pad = if (self.config.window_padding_balance) diff --git a/src/renderer/State.zig b/src/renderer/State.zig index 6c69d30a9..6bff5b219 100644 --- a/src/renderer/State.zig +++ b/src/renderer/State.zig @@ -34,7 +34,7 @@ pub const Mouse = struct { /// The point on the viewport where the mouse currently is. We use /// viewport points to avoid the complexity of mapping the mouse to /// the renderer state. - point: ?terminal.point.Viewport = null, + point: ?terminal.point.Coordinate = null, /// The mods that are currently active for the last mouse event. /// This could really just be mods in general and we probably will diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index c05bb9fcf..96368109f 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -1621,7 +1621,7 @@ pub fn pointFromPin(self: *const PageList, tag: point.Tag, p: Pin) ?point.Point const tl = self.getTopLeft(tag); // Count our first page which is special because it may be partial. - var coord: point.Point.Coordinate = .{ .x = p.x }; + var coord: point.Coordinate = .{ .x = p.x }; if (p.page == tl.page) { // If our top-left is after our y then we're outside the range. if (tl.y > p.y) return null; diff --git a/src/terminal/point.zig b/src/terminal/point.zig index 19ab36777..41b7a3558 100644 --- a/src/terminal/point.zig +++ b/src/terminal/point.zig @@ -53,11 +53,6 @@ pub const Point = union(Tag) { screen: Coordinate, history: Coordinate, - pub const Coordinate = struct { - x: usize = 0, - y: usize = 0, - }; - pub fn coord(self: Point) Coordinate { return switch (self) { .active, @@ -69,13 +64,11 @@ pub const Point = union(Tag) { } }; -/// A point in the terminal that is always in the viewport area. -/// TODO(paged-terminal): remove -pub const Viewport = struct { +pub const Coordinate = struct { x: usize = 0, y: usize = 0, - pub fn eql(self: Viewport, other: Viewport) bool { + pub fn eql(self: Coordinate, other: Coordinate) bool { return self.x == other.x and self.y == other.y; } };