diff --git a/docs/sequences.md b/docs/sequences.md index 7f82aeaff..77422875e 100644 --- a/docs/sequences.md +++ b/docs/sequences.md @@ -19,3 +19,4 @@ Status meanings: | `ENQ` | `0x05` | [Enquiry](sequences/enq.md) | ✅ | | `BEL` | `0x07` | [Bell](sequences/bel.md) | ❌ | | `BS` | `0x08` | [Backspace](sequences/bs.md) | ⚠️ | +| `TAB` | `0x09` | [Tab](sequences/tab.md) | ⚠️ | diff --git a/docs/sequences/tab.md b/docs/sequences/tab.md new file mode 100644 index 000000000..8ba00e4d6 --- /dev/null +++ b/docs/sequences/tab.md @@ -0,0 +1,21 @@ +# Tab + +| | | +| --- | --- | +| Text | | +| Hex | `0x09` | + +Move the cursor right to the next tab stop. + +A tab stop is a specifically marked column that a cursor stops when a tab +is invoked. Tab stops are typically thought of as uniform spacing (i.e. +four spaces) but in terminals this is not the case: tab stops can be set +at any column number using the [tab set](#) and [tab clear](#) +sequences. + +Initially, tab stops are set on every 8th column. + +## TODO + + * Integration with left/right margins of the scrolling region. + * How does horizontal tab interact with the pending wrap state? diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 63515e60e..df9a03a58 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -543,8 +543,8 @@ pub fn horizontalTab(self: *Terminal) !void { defer tracy.end(); while (self.cursor.x < self.cols) { - // Clear - try self.print(' '); + // Move the cursor right + self.cursor.x += 1; // If the last cursor position was a tabstop we return. We do // "last cursor position" because we want a space to be written