# Bell (BEL)

> Ring the terminal's bell.

- **Sequence:** `BEL`
- **ECMA-48:** [§8.3.3 BEL – Bell, p. 33](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n46/mode/1up)
- **DEC STD 070:** [§5.7 Warning Bell, p. 5-114](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n368/mode/1up)
- **VT220:** [§4.2 Control Characters](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2)
- **VT510:** [4.2 Control Characters](https://vt100.net/docs/vt510-rm/chapter4.html#S4.2)

Ring the bell: get the attention of the person at the terminal. DEC STD 070
asks for a warning "bell", "or some similar audible indicator", whose volume
the user may be able to change or turn off. libghostty-vt only reports the
bell to its host, which decides what to do. Nothing on the screen changes,
and the cursor does not move.

BEL has a second job: it ends an operating system command, such as
[setting the window title](https://control-codes.page/osc/title/index.html.md), in place of the string terminator
`ESC \`. There it is part of the command, and does not ring.

A control character sent in the middle of a control sequence is carried
out as if it had come just before the sequence, and the sequence then
carries on; DEC STD 070 gives control characters precedence over every kind
of sequence
([§3.5.1.1, p. 3-18](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n122/mode/1up)).
It also warns that ANSI and ISO standards treat this as an error, so a
program should not rely on it.

## Validation

### BEL-1: Rings, and moves nothing

Input, one step per line:

```text
AB
\a
C
```

Expected screen:

```text
|ABC__|
cursor 1,4
bell 1
```

### BEL-2: Once for each

Input, one step per line:

```text
\a\a\a
```

Expected screen:

```text
|_____|
bell 3
```

### BEL-3: Ending a command does not ring

Input, one step per line:

```text
\e]2;hello\a
```

Expected screen:

```text
|_____|
title "hello"
bell 0
```

### BEL-4: In the middle of a control sequence

Input, one step per line:

```text
\e[2\a;3H # BEL inside CUP
```

Expected screen:

```text
|_____|
|_____|
cursor 2,3
bell 1
```

---

This is the Markdown version of <https://control-codes.page/c0/bel/>. 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>.
