# Select Implicit Movement Direction (SIMD)

> ECMA-48's choice of which way text runs, which xterm takes as Scroll Down.

- **Sequence:** `CSI Ps ^`
- **Defaults:** Ps = 0
- **ECMA-48:** [§8.3.120 SIMD – Select Implicit Movement Direction, p. 63](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n76/mode/1up)
- **xterm:** [Functions using CSI](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

In ECMA-48, `CSI Ps ^` chooses which way the active position moves after a
character is written: `0` the same way as the character path, `1` the
opposite way, for text that runs right to left. It belongs with the
standard's other functions for
bidirectional text, listed on [the rest of ECMA-48](https://control-codes.page/catalog/index.html.md) page, which no
terminal on this site implements.

xterm does something else with it. Its parser sends a final `^` to
[SD](https://control-codes.page/csi/sd/index.html.md)
([`VTPrsTbl.c`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/VTPrsTbl.c#L597)),
and the handler says it is there to "cater to ECMA-48's typographical error"
([`CASE_SD`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L4058-L4066)).
xterm's control sequence documentation lists `CSI Ps ^` as "Scroll down Ps
lines", and calls it a publication error in the 1991 edition of ECMA-48 that
was corrected in 2003. The copy of the fifth edition this site links to
already gives SD as `CSI Pn 05/04`, that is `CSI Pn T`, in
[§8.3.113, p. 59](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n72/mode/1up)
and puts SIMD at 05/14 in its table of final bytes
([Table 3, p. 11](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n24/mode/1up)),
so the error was presumably in another printing.

Either way, a default xterm scrolls: `CSI Ps ^` moves the scrolling region
down `Ps` lines exactly as `CSI Ps T` does, with `0` taken as `1`, and the
parameter's ECMA-48 meaning plays no part. The cases follow xterm.
libghostty-vt has no case for `^` in its CSI dispatch and ignores the
sequence, so they are marked as known differences.

## Validation

### SIMD-1: xterm scrolls down one line

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABC\r\n
DEF\r\n
GHI
\e[^
```

Expected screen:

```text
|____|
|ABC_|
|DEF_|
cursor 3,4
```

### SIMD-2: The ECMA-48 parameter is a count

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABC\r\n
DEF\r\n
GHI
\e[1^     # ECMA-48: the opposite direction
```

Expected screen:

```text
|____|
|ABC_|
|DEF_|
cursor 3,4
```

### SIMD-3: Two lines

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABC\r\n
DEF\r\n
GHI
\e[2^
```

Expected screen:

```text
|____|
|____|
|ABC_|
cursor 3,4
```

### SIMD-4: Within the scrolling region

*A known difference: libghostty-vt does not pass this case.*

Input, one step per line:

```text
ABC\r\n
DEF\r\n
GHI\r\n
JKL
\e[2;3r
\e[^
```

Expected screen:

```text
|ABC_|
|____|
|DEF_|
|JKL_|
cursor 1,1
```

---

This is the Markdown version of <https://control-codes.page/csi/simd/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
