From 7a8f2bfed6da83fc57774e34ee39a5870e3eca2a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 10 Oct 2023 12:24:11 -0700 Subject: [PATCH] terminal: decscusr --- src/terminal/stream.zig | 34 ++++++++++++++++++++++++++++++++ website/app/vt/decscusr/page.mdx | 24 ++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 website/app/vt/decscusr/page.mdx diff --git a/src/terminal/stream.zig b/src/terminal/stream.zig index 0abe37182..5d6f5cdae 100644 --- a/src/terminal/stream.zig +++ b/src/terminal/stream.zig @@ -1487,3 +1487,37 @@ test "stream: DECEL, DECSEL" { try testing.expect(!s.handler.protected.?); } } + +test "stream: DECSCUSR" { + const H = struct { + style: ?ansi.CursorStyle = null, + + pub fn setCursorStyle(self: *@This(), style: ansi.CursorStyle) !void { + self.style = style; + } + }; + + var s: Stream(H) = .{ .handler = .{} }; + try s.nextSlice("\x1B[ q"); + try testing.expect(s.handler.style.? == .default); + + try s.nextSlice("\x1B[1 q"); + try testing.expect(s.handler.style.? == .blinking_block); +} + +test "stream: DECSCUSR without space" { + const H = struct { + style: ?ansi.CursorStyle = null, + + pub fn setCursorStyle(self: *@This(), style: ansi.CursorStyle) !void { + self.style = style; + } + }; + + var s: Stream(H) = .{ .handler = .{} }; + try s.nextSlice("\x1B[q"); + try testing.expect(s.handler.style == null); + + try s.nextSlice("\x1B[1q"); + try testing.expect(s.handler.style == null); +} diff --git a/website/app/vt/decscusr/page.mdx b/website/app/vt/decscusr/page.mdx new file mode 100644 index 000000000..ffa1d963f --- /dev/null +++ b/website/app/vt/decscusr/page.mdx @@ -0,0 +1,24 @@ +import VTSequence from "@/components/VTSequence"; + +# Set Cursor Style (DECSCUSR) + + + +Set the mouse cursor style. + +If `n` is omitted, `n` defaults to `0`. `n` must be an integer between +0 and 6 (inclusive). The mapping of `n` to cursor style is below: + +| n | style | +| --- | --------------------- | +| 0 | terminal default | +| 1 | blinking block | +| 2 | steady block | +| 3 | blinking underline | +| 4 | steady underline | +| 5 | blinking vertical bar | +| 6 | steady vertical bar | + +For `n = 0`, the terminal default is up to the terminal and is inconsistent +across terminal implementations. The default may also be impacted by terminal +configuration.