mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
various tests to ensure we parse curly underlines correctly
This commit is contained in:
@ -524,12 +524,67 @@ test "csi: SGR ESC [ 38 : 2 m" {
|
||||
|
||||
const d = a[1].?.csi_dispatch;
|
||||
try testing.expect(d.final == 'm');
|
||||
try testing.expect(d.sep == .colon);
|
||||
try testing.expect(d.params.len == 2);
|
||||
try testing.expectEqual(@as(u16, 38), d.params[0]);
|
||||
try testing.expectEqual(@as(u16, 2), d.params[1]);
|
||||
}
|
||||
}
|
||||
|
||||
test "csi: SGR ESC [4:3m colon" {
|
||||
var p = init();
|
||||
_ = p.next(0x1B);
|
||||
_ = p.next('[');
|
||||
_ = p.next('4');
|
||||
_ = p.next(':');
|
||||
_ = p.next('3');
|
||||
|
||||
{
|
||||
const a = p.next('m');
|
||||
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 == 'm');
|
||||
try testing.expect(d.sep == .colon);
|
||||
try testing.expect(d.params.len == 2);
|
||||
try testing.expectEqual(@as(u16, 4), d.params[0]);
|
||||
try testing.expectEqual(@as(u16, 3), d.params[1]);
|
||||
}
|
||||
}
|
||||
|
||||
test "csi: SGR with many blank and colon" {
|
||||
var p = init();
|
||||
_ = p.next(0x1B);
|
||||
for ("[58:2::240:143:104") |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('m');
|
||||
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 == 'm');
|
||||
try testing.expect(d.sep == .colon);
|
||||
try testing.expect(d.params.len == 6);
|
||||
try testing.expectEqual(@as(u16, 58), d.params[0]);
|
||||
try testing.expectEqual(@as(u16, 2), d.params[1]);
|
||||
try testing.expectEqual(@as(u16, 0), d.params[2]);
|
||||
try testing.expectEqual(@as(u16, 240), d.params[3]);
|
||||
try testing.expectEqual(@as(u16, 143), d.params[4]);
|
||||
try testing.expectEqual(@as(u16, 104), d.params[5]);
|
||||
}
|
||||
}
|
||||
|
||||
test "csi: mixing semicolon/colon" {
|
||||
var p = init();
|
||||
_ = p.next(0x1B);
|
||||
|
@ -344,6 +344,12 @@ test "sgr: underline styles" {
|
||||
try testing.expect(v.underline == .single);
|
||||
}
|
||||
|
||||
{
|
||||
const v = testParseColon(&[_]u16{ 4, 3 });
|
||||
try testing.expect(v == .underline);
|
||||
try testing.expect(v.underline == .curly);
|
||||
}
|
||||
|
||||
{
|
||||
const v = testParseColon(&[_]u16{ 4, 4 });
|
||||
try testing.expect(v == .underline);
|
||||
|
@ -385,7 +385,10 @@ pub fn Stream(comptime Handler: type) type {
|
||||
// SGR - Select Graphic Rendition
|
||||
'm' => if (@hasDecl(T, "setAttribute")) {
|
||||
var p: sgr.Parser = .{ .params = action.params, .colon = action.sep == .colon };
|
||||
while (p.next()) |attr| try self.handler.setAttribute(attr);
|
||||
while (p.next()) |attr| {
|
||||
//log.info("SGR attribute: {}", .{attr});
|
||||
try self.handler.setAttribute(attr);
|
||||
}
|
||||
} else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||
|
||||
// CPR - Request Cursor Postion Report
|
||||
|
@ -1081,7 +1081,7 @@ const StreamHandler = struct {
|
||||
|
||||
pub fn setAttribute(self: *StreamHandler, attr: terminal.Attribute) !void {
|
||||
switch (attr) {
|
||||
.unknown => |unk| log.warn("unimplemented or unknown attribute: {any}", .{unk}),
|
||||
.unknown => |unk| log.warn("unimplemented or unknown SGR attribute: {any}", .{unk}),
|
||||
|
||||
else => self.terminal.setAttribute(attr) catch |err|
|
||||
log.warn("error setting attribute {}: {}", .{ attr, err }),
|
||||
|
Reference in New Issue
Block a user