mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
Merge pull request #426 from mitchellh/cursor-q
Underline cursor, fix CSI q parsing
This commit is contained in:
@ -15,6 +15,4 @@ pub const Wasm = if (!builtin.target.isWasm()) struct {} else @import("config/Wa
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
|
||||||
_ = @import("config/c_get.zig");
|
|
||||||
}
|
}
|
||||||
|
@ -1423,6 +1423,7 @@ fn addCursor(
|
|||||||
.block => .cursor_rect,
|
.block => .cursor_rect,
|
||||||
.block_hollow => .cursor_hollow_rect,
|
.block_hollow => .cursor_hollow_rect,
|
||||||
.bar => .cursor_bar,
|
.bar => .cursor_bar,
|
||||||
|
.underline => .underline,
|
||||||
};
|
};
|
||||||
|
|
||||||
const glyph = self.font_group.renderGlyph(
|
const glyph = self.font_group.renderGlyph(
|
||||||
|
@ -1024,6 +1024,7 @@ fn addCursor(
|
|||||||
.block => .cursor_rect,
|
.block => .cursor_rect,
|
||||||
.block_hollow => .cursor_hollow_rect,
|
.block_hollow => .cursor_hollow_rect,
|
||||||
.bar => .cursor_bar,
|
.bar => .cursor_bar,
|
||||||
|
.underline => .underline,
|
||||||
};
|
};
|
||||||
|
|
||||||
const glyph = self.font_group.renderGlyph(
|
const glyph = self.font_group.renderGlyph(
|
||||||
|
@ -9,13 +9,14 @@ pub const CursorStyle = enum {
|
|||||||
block,
|
block,
|
||||||
block_hollow,
|
block_hollow,
|
||||||
bar,
|
bar,
|
||||||
|
underline,
|
||||||
|
|
||||||
/// Create a cursor style from the terminal style request.
|
/// Create a cursor style from the terminal style request.
|
||||||
pub fn fromTerminal(style: terminal.Cursor.Style) ?CursorStyle {
|
pub fn fromTerminal(style: terminal.Cursor.Style) ?CursorStyle {
|
||||||
return switch (style) {
|
return switch (style) {
|
||||||
.bar => .bar,
|
.bar => .bar,
|
||||||
.block => .block,
|
.block => .block,
|
||||||
.underline => null, // TODO
|
.underline => .underline,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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" {
|
test "osc: change window title" {
|
||||||
var p = init();
|
var p = init();
|
||||||
_ = p.next(0x1B);
|
_ = p.next(0x1B);
|
||||||
|
@ -600,16 +600,33 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
|
|
||||||
// DECSCUSR - Select Cursor Style
|
// DECSCUSR - Select Cursor Style
|
||||||
// TODO: test
|
// TODO: test
|
||||||
'q' => if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle(
|
'q' => switch (action.intermediates.len) {
|
||||||
switch (action.params.len) {
|
1 => cursor: {
|
||||||
0 => ansi.CursorStyle.default,
|
if (action.intermediates[0] != ' ') {
|
||||||
1 => @enumFromInt(action.params[0]),
|
log.warn(
|
||||||
else => {
|
"ignoring unimplemented CSI q with intermediates: {s}",
|
||||||
log.warn("invalid set curor style command: {}", .{action});
|
.{action.intermediates},
|
||||||
return;
|
);
|
||||||
},
|
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) {
|
'r' => switch (action.intermediates.len) {
|
||||||
// DECSTBM - Set Top and Bottom Margins
|
// DECSTBM - Set Top and Bottom Margins
|
||||||
|
Reference in New Issue
Block a user