diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 2930ad367..e845c6e46 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1452,7 +1452,6 @@ pub fn horizontalTabBack(self: *Terminal) !void { } /// Clear tab stops. -/// TODO: test pub fn tabClear(self: *Terminal, cmd: csi.TabClear) void { switch (cmd) { .current => self.tabstops.unset(self.screen.cursor.x), @@ -5441,3 +5440,26 @@ test "Terminal: scrollDown left/right scroll region" { try testing.expectEqualStrings("A 23\nDBC156\nGEF489\n HI7", str); } } + +test "Terminal: tabClear single" { + const alloc = testing.allocator; + var t = try init(alloc, 30, 5); + defer t.deinit(alloc); + + try t.horizontalTab(); + t.tabClear(.current); + t.setCursorPos(1, 1); + try t.horizontalTab(); + try testing.expectEqual(@as(usize, 16), t.screen.cursor.x); +} + +test "Terminal: tabClear all" { + const alloc = testing.allocator; + var t = try init(alloc, 30, 5); + defer t.deinit(alloc); + + t.tabClear(.all); + t.setCursorPos(1, 1); + try t.horizontalTab(); + try testing.expectEqual(@as(usize, 29), t.screen.cursor.x); +} diff --git a/website/app/vt/tbc/page.mdx b/website/app/vt/tbc/page.mdx new file mode 100644 index 000000000..acb39330b --- /dev/null +++ b/website/app/vt/tbc/page.mdx @@ -0,0 +1,47 @@ +import VTSequence from "@/components/VTSequence"; + +# Tab Clear (TBC) + + + +Clear one or all tab stops. + +The parameter `n` must be `0` or `3`. If `n` is omitted, `n` defaults to `0`. + +If the parameter `n` is `0`, the cursor column position is marked as +not a tab stop. If the column was already not a tab stop, this does nothing. + +If the parameter `n` is `3`, all tab stops are cleared. + +## Validation + +### TBC V-1: Tab Clear Single + +```bash +printf "\033[1;1H" # move to top-left +printf "\033[0J" # clear screen +printf "\033[?W" # reset tabs +printf "\t" +printf "\033[g" +printf "\033[1G" +printf "\t" +``` + +``` +|_______________c_______| +``` + +### TBC V-3: Clear All Tabstops + +```bash +printf "\033[1;1H" # move to top-left +printf "\033[0J" # clear screen +printf "\033[?W" # reset tabs +printf "\033[3g" +printf "\033[1G" +printf "\t" +``` + +``` +|______________________c| +```