From 9a6469743389509ad2d200eb95e832337ec277f7 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Mon, 2 Oct 2023 16:51:45 -0500 Subject: [PATCH] mouse: set mouse to text when bypassing mouse reporting When shift is held, we are bypassing mouse reporting mode. Change the cursor to text to indicate this to the user. On release, change back to whatever we were before. --- src/Surface.zig | 11 +++++++++++ src/termio/Exec.zig | 1 + 2 files changed, 12 insertions(+) diff --git a/src/Surface.zig b/src/Surface.zig index 40b6a2f90..6d694ea3e 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -1121,6 +1121,17 @@ pub fn keyCallback( self.hideMouse(); } + if (self.io.terminal.flags.mouse_event != .none and + event.physical_key == .left_shift or + event.physical_key == .right_shift) + { + switch (event.action) { + .press => try self.rt_surface.setMouseShape(.text), + .release => try self.rt_surface.setMouseShape(self.io.terminal.mouse_shape), + else => {}, + } + } + // No binding, so we have to perform an encoding task. This // may still result in no encoding. Under different modes and // inputs there are many keybindings that result in no encoding diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index b89e9a64c..5fc3c6c1f 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -2024,6 +2024,7 @@ const StreamHandler = struct { self: *StreamHandler, shape: terminal.MouseShape, ) !void { + self.terminal.mouse_shape = shape; _ = self.ev.surface_mailbox.push(.{ .set_mouse_shape = shape, }, .{ .forever = {} });