sgr pixels mouse report format

This commit is contained in:
Mitchell Hashimoto
2022-08-26 14:59:44 -07:00
parent 1039ad76bf
commit fe6ba02709
3 changed files with 17 additions and 3 deletions

View File

@ -933,7 +933,19 @@ fn mouseReport(
try self.queueWrite(resp);
},
else => @panic("TODO"),
.sgr_pixels => {
// Response always is at least 4 chars, so this leaves the
// remainder for numbers which are very large...
var buf: [32]u8 = undefined;
const resp = try std.fmt.bufPrint(&buf, "\x1B[<{d};{d};{d}{c}", .{
button_code,
pos.xpos,
pos.ypos,
@as(u8, if (action == .release) 'm' else 'M'),
});
try self.queueWrite(resp);
},
}
}
@ -1513,6 +1525,7 @@ pub fn setMode(self: *Window, mode: terminal.Mode, enabled: bool) !void {
.mouse_format_utf8 => self.terminal.modes.mouse_format = if (enabled) .utf8 else .x10,
.mouse_format_sgr => self.terminal.modes.mouse_format = if (enabled) .sgr else .x10,
.mouse_format_urxvt => self.terminal.modes.mouse_format = if (enabled) .urxvt else .x10,
.mouse_format_sgr_pixels => self.terminal.modes.mouse_format = if (enabled) .sgr_pixels else .x10,
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
}

View File

@ -96,8 +96,6 @@ pub const MouseFormat = enum(u3) {
utf8 = 1, // 1005
sgr = 2, // 1006
urxvt = 3, // 1015
// TODO:
sgr_pixels = 4, // 1016
};

View File

@ -89,6 +89,9 @@ pub const Mode = enum(u16) {
/// Report mouse position in the urxvt format.
mouse_format_urxvt = 1015,
/// Report mouse position in the SGR format as pixels, instead of cells.
mouse_format_sgr_pixels = 1016,
/// Alternate screen mode with save cursor and clear on enter.
alt_screen_save_cursor_clear_enter = 1049,