Merge pull request #649 from mitchellh/ris-tabs

terminal: RIS should reset tabstops, ESC ? W should reset every 8
This commit is contained in:
Mitchell Hashimoto
2023-10-10 09:16:38 -07:00
committed by GitHub
5 changed files with 46 additions and 5 deletions

View File

@ -1487,6 +1487,11 @@ pub fn tabSet(self: *Terminal) void {
self.tabstops.set(self.screen.cursor.x); self.tabstops.set(self.screen.cursor.x);
} }
/// TODO: test
pub fn tabReset(self: *Terminal) void {
self.tabstops.reset(TABSTOP_INTERVAL);
}
/// Carriage return moves the cursor to the first column. /// Carriage return moves the cursor to the first column.
pub fn carriageReturn(self: *Terminal) void { pub fn carriageReturn(self: *Terminal) void {
const tracy = trace(@src()); const tracy = trace(@src());
@ -1922,7 +1927,7 @@ pub fn fullReset(self: *Terminal, alloc: Allocator) void {
self.screen.charset = .{}; self.screen.charset = .{};
self.modes = .{}; self.modes = .{};
self.flags = .{}; self.flags = .{};
self.tabstops.reset(0); self.tabstops.reset(TABSTOP_INTERVAL);
self.screen.cursor = .{}; self.screen.cursor = .{};
self.screen.saved_cursor = .{}; self.screen.saved_cursor = .{};
self.screen.selection = null; self.screen.selection = null;

View File

@ -169,9 +169,11 @@ const ModeEntry = struct {
/// they're used within Ghostty or google their values. It is not /// they're used within Ghostty or google their values. It is not
/// valuable to redocument them all here. /// valuable to redocument them all here.
const entries: []const ModeEntry = &.{ const entries: []const ModeEntry = &.{
// ANSI
.{ .name = "insert", .value = 4, .ansi = true }, .{ .name = "insert", .value = 4, .ansi = true },
.{ .name = "cursor_keys", .value = 1 }, // DEC
.{ .name = "cursor_keys", .value = 1 }, // DECCKM
.{ .name = "132_column", .value = 3 }, .{ .name = "132_column", .value = 3 },
.{ .name = "reverse_colors", .value = 5 }, .{ .name = "reverse_colors", .value = 5 },
.{ .name = "origin", .value = 6 }, .{ .name = "origin", .value = 6 },

View File

@ -376,10 +376,10 @@ pub fn Stream(comptime Handler: type) type {
'W' => { 'W' => {
switch (action.params.len) { switch (action.params.len) {
0 => if (action.intermediates.len == 1 and action.intermediates[0] == '?') { 0 => if (action.intermediates.len == 1 and action.intermediates[0] == '?') {
if (@hasDecl(T, "tabClear")) if (@hasDecl(T, "tabReset"))
try self.handler.tabClear(.all) try self.handler.tabReset()
else else
log.warn("unimplemented tab clear callback: {}", .{action}); log.warn("unimplemented tab reset callback: {}", .{action});
}, },
1 => switch (action.params[0]) { 1 => switch (action.params[0]) {

View File

@ -1653,6 +1653,10 @@ const StreamHandler = struct {
self.terminal.tabSet(); self.terminal.tabSet();
} }
pub fn tabReset(self: *StreamHandler) !void {
self.terminal.tabReset();
}
pub fn saveCursor(self: *StreamHandler) !void { pub fn saveCursor(self: *StreamHandler) !void {
self.terminal.saveCursor(); self.terminal.saveCursor();
} }

View File

@ -0,0 +1,30 @@
import VTSequence from "@/components/VTSequence";
# Full Reset (RIS)
<VTSequence sequence={["ESC", "c"]} />
Reset the terminal.
The full reset operation does the following:
- Set the cursor shape to the default
- Reset the scroll region to the full screen
- Disable [left and right margin mode (mode 69)](#TODO)
- Disable [origin mode (mode 6)](#TODO)
- Unset cursor foreground and background colors
- Reset charsets to the default
- Reset [cursor key mode (DECCKM)](#TODO)
- Reset [disable keyboard input (KAM)](#TODO)
- Reset [application keypad mode](/vt/deckpnm)
- Reset xterm keyboard modifier state to the default
- Disable cursor [protected attribute](#TODO)
- Disable any [protected area](#TODO)
- Reset all [mouse tracking modes](#TODO)
- Reset tabstops to default
- Enable [send-receive mode (mode 12)](#TODO)
- Reset [backspace sends delete (mode 67)](#TODO)
- Return to the primary screen and clear it
- Move the cursor to the top-left corner
- Reset the pending wrap state
- Reset saved cursor state