Terminal borders that don't cost a cell joshka.net · 48 points · 27 comments · H...

@best

Terminal borders that don't cost a cell joshka.net · 48 points · 27 comments · HN thread

TL;DR Joshka (maintainer of Ratatui) proposes a terminal protocol, implemented as a patch to Ghostty and an earlier Rio version, that draws thin border lines on the edges of character cells instead of using box-drawing glyphs, so borders take no rows or columns. The spec uses a DCS-namespaced escape sequence with a pen model, rectangle commands and a capability query that falls back to box characters, and he asks terminal and TUI authors for feedback, especially on rendering cost.

  • Each cell can carry up to twelve line segments (halves of its four edges plus four center arms), each with its own color, width, placement and style, so borders take no rows or columns.
  • Borders are stored as a cell attribute, so they scroll, erase, insert and reflow with the text, and are not copied as text when selecting.
  • Shared edges merge by priority, then width, then position, so a focused pane can keep its full outline.
  • Capability is detected by sending a query followed by DA1; if no cell-border reply arrives, apps fall back to box-drawing characters and reserve the space they need.
  • The Ghostty change is about 1,650 lines; each cell gets a 16-bit border ID in existing padding, and the shared border-set table could reach roughly 10-15 MB in the worst case. Rendering cost is not yet benchmarked.
  • Prior art includes DEC ruled lines, SGR 51-65 framing, Win32 and curses grid attributes, and IBM 3270 field outlines, none of which give per-edge color and width.

Discussion The thread splits between people who see cell borders as a useful, pragmatic step for TUIs and those who think the effort should go further, either toward a richer semantic UI protocol or toward HTML or GUI-style rendering over SSH. Several commenters float alternatives such as overstrike mode, and a question about RAM use and a question about why it would not work through tmux get short answers or go unanswered. The mood is mostly curious and appreciative, with some skepticism about the aesthetic and the broader direction.

  • Pragmatic terminal improvement is worth doing (some): Commenters welcome the work and want it in more terminals like Kitty and Ghostty, and some want borders kept out of copy and paste. They see it as a practical way to get better-looking TUIs without redesigning everything.
  • Terminals should become full UI frameworks (some): Several argue the protocol should go further, toward a semantic or structured UI protocol that handles accessibility, wrapping and scrollback. Joshka agrees that cells are the wrong unit and says he wants that too.
  • Overstrike mode is a simpler alternative (a few): One commenter suggests more emulators implement DECSET 20 overstrike, which would let apps draw border characters over existing cells. They note that mintty is the only emulator they know of with it, and that rounded corners with a filled interior are harder under that model.
  • Keep TUIs terminal-native, not GUI-like (a few): Some commenters say the limits of the terminal are the point and that a GUI in a browser or GTK over SSH is not what they want. They argue HTML is a poor UI basis and that heavy protocols add complexity.
  • Borders need breathing room; aesthetic doubt (a few): One commenter prefers borders with space around them and feels the thin-line treatment loses that.
  • Multiplexer and RAM questions unresolved (a few): Commenters ask how much RAM it uses and why it would not work through tmux. The post itself covers multiplexers, and these questions suggest that section did not fully satisfy readers.

Links from the comments

#terminal #TUI #Ratatui #Ghostty #escapeSequences #borders