terminal: TBC tests

This commit is contained in:
Mitchell Hashimoto
2023-10-09 10:01:23 -07:00
parent ed23f2f1d0
commit fc08f9ab17
2 changed files with 70 additions and 1 deletions

View File

@ -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);
}

View File

@ -0,0 +1,47 @@
import VTSequence from "@/components/VTSequence";
# Tab Clear (TBC)
<VTSequence sequence={["CSI", "Pn", "g"]} />
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|
```