urxvt reporting format

This commit is contained in:
Mitchell Hashimoto
2022-08-26 14:57:35 -07:00
parent f551c0ef66
commit 1039ad76bf
3 changed files with 18 additions and 1 deletions

View File

@ -920,6 +920,19 @@ fn mouseReport(
try self.queueWrite(resp);
},
.urxvt => {
// 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}M", .{
32 + button_code,
viewport_point.x + 1,
viewport_point.y + 1,
});
try self.queueWrite(resp);
},
else => @panic("TODO"),
}
}
@ -1499,6 +1512,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,
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
}

View File

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

View File

@ -86,6 +86,9 @@ pub const Mode = enum(u16) {
/// Report mouse position in the SGR format.
mouse_format_sgr = 1006,
/// Report mouse position in the urxvt format.
mouse_format_urxvt = 1015,
/// Alternate screen mode with save cursor and clear on enter.
alt_screen_save_cursor_clear_enter = 1049,