Ratatui maintainer proposes a terminal protocol for lines on cell edges
The maintainer of the open-source Ratatui library, Joshka, has drafted a protocol that lets terminals draw borders on cell edges without using up a whole row or column. It is implemented as a Ghostty terminal patch, and the author is asking terminal and TUI developers for feedback.

Joshka, who maintains Ratatui, a popular library for building text user interfaces (TUIs), has published a draft terminal protocol for drawing thin lines on the edges of character cells. Terminals today usually draw borders with the Unicode Box Drawing block, so every line occupies a whole cell. The author is seeking feedback from terminal and TUI developers.
The problem
Box-drawing characters are text, so they take up space. The author notes that in a 200x50 terminal with several nested panels, 6 to 8 of the 50 rows can go to lines alone. A line cannot be placed between two filled cells either, so underlining a text field or outlining a button requires extra padding. Copying text from an app also copies the frame characters.
How it works
A cell border is a cell attribute, much like a background color. Each cell can hold up to twelve line segments: both halves of each of its four edges and four arms from the center. Every segment has its own color, width, placement and style. Lines can be solid, double, dashed or dotted, and corners can be square or rounded. Borders are stored in the cells, so they scroll, erase and reflow along with the text.
Commands are sent as a single DCS string. An app checks for support with a query followed by a DA1 request; if there is no support, it falls back to ordinary box characters. Terminals that do not understand the protocol ignore the string. Multiplexers such as tmux that are unaware of it should drop it.
Implementation
The Ghostty patch is about 1,650 lines, a fair share of which is tests. Each cell gets a 16-bit border ID, so cells do not grow in size. The author admits performance has not yet been properly benchmarked. The patch has only been run on macOS, and the protocol should be read as a draft.


