Standards for ANSI escape code... Note
Julia Evans

Standards for ANSI escape codes

ANSI escape codes are used to improve terminal usability, but they are not fully standardized, leading to reliability issues. The author learned about ANSI escape codes while studying the terminal and wanted to understand the standards surrounding them. Escape codes are used by terminal emulators to communicate with programs, and they come in two types: input codes for keypresses and mouse movements, and output codes for tasks like coloring text and moving the cursor. The ECMA-48 standard, published in 1976, defines general formats for escape codes and some specific codes, but it's not exhaustive. Xterm control sequences are another set of escape codes that have been widely implemented by terminal emulators, although they are not a formal standard. The terminfo database, managed by ncurses, stores escape codes for various terminals, and some programs use it to determine which codes to use. However, some programs choose not to use terminfo and instead hardcode a "single common set" of escape codes that work in most terminal emulators. There is no clear agreement on what this common set is, but it likely includes codes from the VT100, ECMA-48, and xterm. Despite challenges, standardizing ANSI escape codes could lead to a richer terminal experience, and the author hopes that a clearer standards landscape could facilitate innovation in terminal emulators and applications.