ghostty/website/app/vt/cbt/page.mdx
2024-08-05 13:56:57 +02:00

84 lines
1.7 KiB
Plaintext

import VTSequence from "@/components/VTSequence";
# Cursor Backward Tabulation (CBT)
<VTSequence sequence={["CSI", "Pn", "Z"]} />
Move the cursor `n` tabs left.
The leftmost valid column for this operation is the first column. If
[origin mode](#TODO) is enabled, then the leftmost valid column for this
operation is the [left margin](#TODO).
Move the cursor left until the cursor position is on a tabstop. If the
cursor would move past the leftmost valid column, the cursor remains at
the leftmost valid column and the operation completes. Repeat this process
`n` times.
Tabstops are dynamic and can be set with escape sequences such as
[horizontal tab set (HTS)](/vt/hts), [tab clear (TBC)](/vt/tbc), etc.
A terminal emulator may default tabstops at any interval, though an interval
of 8 spaces is most common.
## Validation
### CBT V-1: Left Beyond First Column
```bash
printf "\033[?W" # reset tab stops
printf "\033[10Z"
printf "A"
```
```
|Ac________|
```
### CBT V-2: Left Starting After Tab Stop
```bash
printf "\033[?W" # reset tab stops
printf "\033[1;10H"
printf "X"
printf "\033[Z"
printf "A"
```
```
|________AX|
```
### CBT V-3: Left Starting on Tabstop
```bash
printf "\033[?W" # reset tab stops
printf "\033[1;9H"
printf "X"
printf "\033[1;9H"
printf "\033[Z"
printf "A"
```
```
|A_______X_|
```
### CBT V-4: Left Margin with Origin Mode
```bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "\033[?W" # reset tab stops
printf "\033[?6h" # enable origin mode
printf "\033[?69h" # enable left/right margins
printf "\033[3;6s" # scroll region left/right
printf "\033[1;2H" # move cursor in region
printf "X"
printf "\033[Z"
printf "A"
```
```
|__AX______|
```