implement ESC c -- full reset

This commit is contained in:
Mitchell Hashimoto
2022-11-06 18:59:17 -08:00
parent e7c5cbf758
commit 9ee5a5c715
3 changed files with 29 additions and 0 deletions

View File

@ -1322,6 +1322,20 @@ pub fn setScrollingRegion(self: *Terminal, top: usize, bottom: usize) void {
self.setCursorPos(1, 1); self.setCursorPos(1, 1);
} }
/// Full reset
pub fn fullReset(self: *Terminal) void {
self.primaryScreen(.{});
self.selection = null;
self.charset = .{};
self.eraseDisplay(.scrollback);
self.eraseDisplay(.complete);
self.modes = .{};
self.tabstops.reset(0);
self.screen.cursor = .{};
self.screen.saved_cursor = .{};
self.scrolling_region = .{ .top = 0, .bottom = self.rows - 1 };
}
test "Terminal: input with no control characters" { test "Terminal: input with no control characters" {
var t = try init(testing.allocator, 80, 80); var t = try init(testing.allocator, 80, 80);
defer t.deinit(testing.allocator); defer t.deinit(testing.allocator);

View File

@ -567,6 +567,15 @@ pub fn Stream(comptime Handler: type) type {
}, },
} else log.warn("unimplemented invokeCharset: {}", .{action}), } else log.warn("unimplemented invokeCharset: {}", .{action}),
// RIS - Full Reset
'c' => if (@hasDecl(T, "fullReset")) switch (action.intermediates.len) {
0 => try self.handler.fullReset(),
else => {
log.warn("invalid full reset command: {}", .{action});
return;
},
} else log.warn("unimplemented ESC callback: {}", .{action}),
// LS2 - Locking Shift 2 // LS2 - Locking Shift 2
'n' => if (@hasDecl(T, "invokeCharset")) switch (action.intermediates.len) { 'n' => if (@hasDecl(T, "invokeCharset")) switch (action.intermediates.len) {
0 => try self.handler.invokeCharset(.GL, .G2, false), 0 => try self.handler.invokeCharset(.GL, .G2, false),

View File

@ -767,4 +767,10 @@ const StreamHandler = struct {
) !void { ) !void {
self.terminal.invokeCharset(active, slot, single); self.terminal.invokeCharset(active, slot, single);
} }
pub fn fullReset(
self: *StreamHandler,
) !void {
self.terminal.fullReset();
}
}; };