ghostty/website/app/vt/su/page.mdx
Mitchell Hashimoto 12054087e1 terminal: scroll up full top/bottom region was off by one
Fixes #689

See test cases, verified with xterm.
2023-10-16 09:25:47 -07:00

114 lines
2.0 KiB
Plaintext

import VTSequence from "@/components/VTSequence";
# Scroll Up (SU)
<VTSequence sequence={["CSI", "Pn", "S"]} />
Remove `n` lines from the top of the scroll region and shift existing
lines up.
The parameter `n` must be an integer greater than or equal to 1. If `n` is less than
or equal to 0, adjust `n` to be 1. If `n` is omitted, `n` defaults to 1.
This sequence executes [Delete Line (DL)](/vt/dl) with the cursor position
set to the top of the scroll region. There are some differences from DL
which are explained below.
The cursor position after the operation must be unchanged from when SU was
invoked. The pending wrap state is _not_ reset.
## Validation
### SU V-1: Simple Usage
```bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[2;2H"
printf "\033[S"
```
```
|DEF_____|
|GHI_____|
```
### SU V-2: Top/Bottom Scroll Region
```bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC\n"
printf "DEF\n"
printf "GHI\n"
printf "\033[2;3r" # scroll region top/bottom
printf "\033[1;1H"
printf "\033[S"
```
```
|ABC_____|
|GHI_____|
```
### SU V-3: Left/Right Scroll Regions
```bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "ABC123\n"
printf "DEF456\n"
printf "GHI789\n"
printf "\033[?69h" # enable left/right margins
printf "\033[2;4s" # scroll region left/right
printf "\033[2;2H"
printf "\033[S"
```
```
|AEF423__|
|DHI756__|
|G___89__|
```
### SU V-4: Preserves Pending Wrap
```bash
cols=$(tput cols)
printf "\033[1;${cols}H" # move to top-right
printf "\033[2J" # clear screen
printf "A"
printf "\033[2;${cols}H"
printf "B"
printf "\033[3;${cols}H"
printf "C"
printf "\033[S"
printf "X"
```
```
|_______B|
|_______C|
|________|
|X_______|
```
### SU V-5: Scroll Full Top/Bottom Scroll Region
```bash
printf "\033[1;1H" # move to top-left
printf "\033[0J" # clear screen
printf "top"
printf "\033[5;1H"
printf "ABCDEF"
printf "\033[2;5r" # scroll region top/bottom
printf "\033[4S"
```
```
|top_____|
```