plumb CSI to set cursor style, but haven't implemented any styles

This commit is contained in:
Mitchell Hashimoto
2022-05-19 21:43:30 -07:00
parent 16d4648cf6
commit 37f621bc19
4 changed files with 39 additions and 0 deletions

View File

@ -669,3 +669,14 @@ pub fn deviceStatusReport(
else => log.warn("unimplemented device status req: {}", .{req}),
}
}
pub fn setCursorStyle(
self: *Window,
style: terminal.CursorStyle,
) !void {
_ = self;
switch (style) {
else => log.warn("unimplemented cursor style: {}", .{style}),
}
}

View File

@ -58,3 +58,17 @@ pub const DeviceStatusReq = enum(u16) {
// Non-exhaustive so that @intToEnum never fails for unsupported modes.
_,
};
/// Possible cursor styles (ESC [ q)
pub const CursorStyle = enum(u16) {
default = 0,
blinking_block = 1,
steady_block = 2,
blinking_underline = 3,
steady_underline = 4,
blinking_bar = 5,
steady_bar = 6,
// Non-exhaustive so that @intToEnum never fails for unsupported modes.
_,
};

View File

@ -7,6 +7,7 @@ pub const color = @import("color.zig");
pub const Terminal = @import("Terminal.zig");
pub const Parser = @import("Parser.zig");
pub const Stream = stream.Stream;
pub const CursorStyle = ansi.CursorStyle;
pub const DeviceAttributeReq = ansi.DeviceAttributeReq;
pub const DeviceStatusReq = ansi.DeviceStatusReq;
pub const Mode = ansi.Mode;

View File

@ -307,6 +307,19 @@ pub fn Stream(comptime Handler: type) type {
},
) else log.warn("unimplemented CSI callback: {}", .{action}),
// DECSCUSR - Select Cursor Style
// TODO: test
'q' => if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle(
switch (action.params.len) {
0 => ansi.CursorStyle.default,
1 => @intToEnum(ansi.CursorStyle, action.params[0]),
else => {
log.warn("invalid set curor style command: {}", .{action});
return;
},
},
) else log.warn("unimplemented CSI callback: {}", .{action}),
// DECSTBM - Set Top and Bottom Margins
// TODO: test
'r' => if (@hasDecl(T, "setTopAndBottomMargin")) switch (action.params.len) {