diff --git a/src/config.zig b/src/config.zig index 23687d14b..7115b04a6 100644 --- a/src/config.zig +++ b/src/config.zig @@ -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"); } diff --git a/src/terminal/Parser.zig b/src/terminal/Parser.zig index ee65a165f..d376d5d10 100644 --- a/src/terminal/Parser.zig +++ b/src/terminal/Parser.zig @@ -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); diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 7504f4682..04d2b9aef 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -600,16 +600,33 @@ pub fn Stream(comptime Handler: type) type { // DECSCUSR - Select Cursor Style // TODO: test - 'q' => if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle( - switch (action.params.len) { - 0 => ansi.CursorStyle.default, - 1 => @enumFromInt(action.params[0]), - else => { - log.warn("invalid set curor style command: {}", .{action}); - return; - }, + '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]), + else => { + log.warn("invalid set curor style command: {}", .{action}); + 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