website: left/right margins

This commit is contained in:
Mitchell Hashimoto
2023-10-09 21:20:30 -07:00
parent 2354454907
commit d05e488cc4

View File

@ -0,0 +1,120 @@
import VTSequence from "@/components/VTSequence";
# Set Left and Right Margins (DECSLRM)
<VTSequence sequence={["CSI", "Pl", ";", "Pr", "s"]} />
Sets the left and right margins, otherwise known as the scroll region.
To learn more about scroll regions in general, see
[Set Top and Bottom Margins](/vt/decstbm).
Parameters `l` and `r` are integer values. If either value is zero the
value will be reset to default values. The default value for `l` is `1`
and the default value of `r` is the number of columns in the screen.
Values `l` and `r` can be omitted. If either value is omitted, their
default values will be used. Note that it is impossible to omit `l`
and not omit `r`.
This sequence requires [enable left and right margin (mode 69)](#TODO)
to be set. If mode 69 is not set, this sequence does nothing and left
and right margins will not be set.
This sequence conflicts with [save cursor (`CSI s`)](#TODO). If
mode 69 is disabled, save cursor will be invoked. If mode 69 is enabled,
the `CSI s` save cursor sequence will be disabled, but save cursor is always
also available as `ESC 7`.
If left is larger or equal to right, this sequence does nothing. A
scroll region must be at least two columns (`r` must be greater than `l`).
The rest of this sequence description assumes valid values for `l` and `r`.
This sequence unsets the pending wrap state and moves the cursor to
the top-left of the screen. If [origin mode](#TODO) is set, the cursor is
moved to the top-left of the scroll region.
To reset the left and right margins, call this sequence with both values set to
"0". This will force the default values for both `l` and `r` which is
the full screen. Unsetting mode 69 will also reset the left and right margins.
## Validation
### DECSLRM V-1: Full Screen
```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[?69h" # enable left/right margins
printf "\033[s" # scroll region left/right
printf "\033[X"
```
```
|cBC_____|
|DEF_____|
|GHI_____|
```
### DECSLRM V-2: Left Only
```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[?69h" # enable left/right margins
printf "\033[2s" # scroll region left/right
printf "\033[2G" # move cursor to column 2
printf "\033[L"
```
```
|Ac______|
|DBC_____|
|GEF_____|
| HI_____|
```
### DECSLRM V-3: Left And Right
```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[?69h" # enable left/right margins
printf "\033[1;2s" # scroll region left/right
printf "\033[2G" # move cursor to column 2
printf "\033[L"
```
```
|_cC_____|
|ABF_____|
|DEI_____|
|GH______|
```
### DECSLRM V-4: Left Equal to Right
```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[?69h" # enable left/right margins
printf "\033[2;2s" # scroll region left/right
printf "\033[X"
```
```
|cBC_____|
|DEF_____|
|GHI_____|
```