mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
decaln
This commit is contained in:
10
conformance/esc_decaln.zig
Normal file
10
conformance/esc_decaln.zig
Normal file
@ -0,0 +1,10 @@
|
||||
//! DECALN - ESC # 8
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
try stdout.print("\x1B#8", .{});
|
||||
|
||||
// const stdin = std.io.getStdIn().reader();
|
||||
// _ = try stdin.readByte();
|
||||
}
|
@ -761,3 +761,7 @@ pub fn setCursorStyle(
|
||||
// it'll be updated the next time the window comes into focus.
|
||||
if (self.focused) try self.updateCursorStyle(grid_style, style.blinking());
|
||||
}
|
||||
|
||||
pub fn decaln(self: *Window) !void {
|
||||
self.terminal.decaln();
|
||||
}
|
||||
|
@ -174,6 +174,27 @@ pub fn print(self: *Terminal, c: u21) !void {
|
||||
}
|
||||
}
|
||||
|
||||
/// Resets all margins and fills the whole screen with the character 'E'
|
||||
///
|
||||
/// Sets the cursor to the top left corner.
|
||||
pub fn decaln(self: *Terminal) void {
|
||||
// Reset margins, also sets cursor to top-left
|
||||
self.setScrollingRegion(0, 0);
|
||||
|
||||
// Fill with Es, does not move cursor. We reset fg/bg so we can just
|
||||
// optimize here by doing row copies.
|
||||
const filled = self.screen.getRow(0);
|
||||
var col: usize = 0;
|
||||
while (col < self.cols) : (col += 1) {
|
||||
filled[col] = .{ .char = 'E' };
|
||||
}
|
||||
|
||||
var row: usize = 1;
|
||||
while (row < self.rows) : (row += 1) {
|
||||
std.mem.copy(Screen.Cell, self.screen.getRow(row), filled);
|
||||
}
|
||||
}
|
||||
|
||||
/// Move the cursor to the previous line in the scrolling region, possibly
|
||||
/// scrolling.
|
||||
///
|
||||
@ -950,3 +971,25 @@ test "Terminal: reverseIndex from the top" {
|
||||
try testing.expectEqualStrings("E\nD\nA\nB", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: DECALN" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 2, 2);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
// Initial value
|
||||
try t.print('A');
|
||||
t.carriageReturn();
|
||||
t.linefeed();
|
||||
try t.print('B');
|
||||
t.decaln();
|
||||
|
||||
try testing.expectEqual(@as(usize, 0), t.cursor.y);
|
||||
try testing.expectEqual(@as(usize, 0), t.cursor.x);
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("EE\nEE", str);
|
||||
}
|
||||
}
|
||||
|
@ -345,6 +345,24 @@ pub fn Stream(comptime Handler: type) type {
|
||||
action: Parser.Action.ESC,
|
||||
) !void {
|
||||
switch (action.final) {
|
||||
'8' => blk: {
|
||||
switch (action.intermediates.len) {
|
||||
1 => switch (action.intermediates[0]) {
|
||||
// DECALN - Fill Screen with E
|
||||
'#' => if (@hasDecl(T, "decaln")) {
|
||||
try self.handler.decaln();
|
||||
break :blk {};
|
||||
} else log.warn("unimplemented ESC callback: {}", .{action}),
|
||||
|
||||
else => {},
|
||||
},
|
||||
|
||||
else => {}, // fall through
|
||||
}
|
||||
|
||||
log.warn("unimplemented ESC action: {}", .{action});
|
||||
},
|
||||
|
||||
// RI - Reverse Index
|
||||
'M' => if (@hasDecl(T, "reverseIndex")) switch (action.intermediates.len) {
|
||||
0 => try self.handler.reverseIndex(),
|
||||
|
Reference in New Issue
Block a user