Urgent.News

What's breaking now, across thousands of outlets.

Tech

Terminal borders that don't cost a cell

Article URL: https://www.joshka.net/cell-borders/ Comments URL: https://news.ycombinator.com/item?id=50491423 Points: 324 # Comments: 141

This article discusses the limitations of using box-drawing characters for terminal borders and presents an alternative solution using a terminal protocol that draws thin lines on cell edges. The author, who has experience with terminal user interfaces (TUIs), has found that traditional box-drawing characters take up space and hinder proper design, leading to wasted rows and columns on the terminal screen.

The proposed solution involves storing cell borders as cell attributes, similar to background colors. Each cell can carry up to twelve line segments, including the two halves of each edge and four arms from the center. These segments can have their own color, width, placement, and style, allowing for more flexibility and control over the appearance of borders.

Some advantages of this approach include:

- Borders do not take up extra rows or columns, preserving screen real estate.

- Underlining text fields and outlining buttons becomes easier without requiring additional padding.

- Rounded corners can have a distinct outside color, maintaining visual consistency with the panel's background.

- Lines can be solid, double, dashed, or dotted, providing greater visual variety.

- Cell borders are stored within the cells themselves, allowing them to scroll, erase, insert, and reflow seamlessly alongside the text.

- When neighboring cells share an edge, they can merge their borders, simplifying the rendering process.

The author has implemented this idea in a patch for Ghostty and demonstrated its effectiveness with demo applications built using Ratatui. The proposed terminal protocol could have benefits for charting tools, such as btop-style braille graphs, which currently require giving up rows for gridlines and averages. With cell borders, these gridlines can sit on cell edges between the dots, preserving the available screen space.

The approach also addresses copy and paste behavior, as cell borders are cell attributes and do not get copied along with the text. This eliminates the usual cleanup dance when pasting terminal content into other applications.

Overall, the author believes that using cell borders instead of box-drawing characters offers a more efficient and visually appealing way to create aesthetically pleasing terminal interfaces without sacrificing functionality or screen space.

Written by urgent.news from Hacker News Best's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Every outlet that reported this, and when →

Read the original at joshka.net →

More in Tech

More from Friday 13 November →