terminal: CSI q requires a space intermediate

This commit is contained in:
Mitchell Hashimoto
2023-09-10 22:01:17 -07:00
parent 1a9ebf3048
commit 24af24a086
3 changed files with 52 additions and 11 deletions

View File

@ -15,6 +15,4 @@ pub const Wasm = if (!builtin.target.isWasm()) struct {} else @import("config/Wa
test {
@import("std").testing.refAllDecls(@This());
_ = @import("config/c_get.zig");
}

View File

@ -721,6 +721,32 @@ test "csi: request mode decrqm" {
}
}
test "csi: change cursor" {
var p = init();
_ = p.next(0x1B);
for ("[3 ") |c| {
const a = p.next(c);
try testing.expect(a[0] == null);
try testing.expect(a[1] == null);
try testing.expect(a[2] == null);
}
{
const a = p.next('q');
try testing.expect(p.state == .ground);
try testing.expect(a[0] == null);
try testing.expect(a[1].? == .csi_dispatch);
try testing.expect(a[2] == null);
const d = a[1].?.csi_dispatch;
try testing.expect(d.final == 'q');
try testing.expectEqual(@as(usize, 1), d.intermediates.len);
try testing.expectEqual(@as(usize, 1), d.params.len);
try testing.expectEqual(@as(u16, ' '), d.intermediates[0]);
try testing.expectEqual(@as(u16, 3), d.params[0]);
}
}
test "osc: change window title" {
var p = init();
_ = p.next(0x1B);

View File

@ -600,7 +600,17 @@ pub fn Stream(comptime Handler: type) type {
// DECSCUSR - Select Cursor Style
// TODO: test
'q' => if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle(
'q' => switch (action.intermediates.len) {
1 => cursor: {
if (action.intermediates[0] != ' ') {
log.warn(
"ignoring unimplemented CSI q with intermediates: {s}",
.{action.intermediates},
);
break :cursor;
}
if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle(
switch (action.params.len) {
0 => ansi.CursorStyle.default,
1 => @enumFromInt(action.params[0]),
@ -609,7 +619,14 @@ pub fn Stream(comptime Handler: type) type {
return;
},
},
) else log.warn("unimplemented CSI callback: {}", .{action}),
) else log.warn("unimplemented CSI callback: {}", .{action});
},
else => log.warn(
"ignoring unimplemented CSI p with intermediates: {s}",
.{action.intermediates},
),
},
'r' => switch (action.intermediates.len) {
// DECSTBM - Set Top and Bottom Margins