Urgent.News

What's breaking now, across thousands of outlets.

Tech

Terminal borders that don't cost a cell

Terminal borders are often overlooked, resulting in plain and unappealing user interfaces. This article explores a solution that draws thin lines on the edges of cells instead of using Unicode Box Drawing block characters. The new approach allows for cell borders without taking up a row or column, improving the overall design.

The author has been working on a terminal protocol that enables this feature, demonstrating its effectiveness by building demo applications with Ratatui. The main advantage of cell borders is that they reside within each cell, unlike box-drawing characters which occupy a whole cell and bring various drawbacks.

Cell borders can be styled individually, with their own color, width, placement, and style, allowing for more flexibility and customization. They also handle scrolling, erasing, inserting, and reflowing with the text, similar to background colors. The proposed approach also supports lines in different styles, such as solid, double, dashed, or dotted, and cell corners can be either square or rounded with configurable radii and anti-aliased arcs.

By storing borders in cells, they automatically adjust with text scrolling, erasing, inserting, and reflowing, eliminating the need for additional space. The author demonstrates the practical benefits of this method through various examples, including nested panels, charts, tables, and dialogues. The border merging feature ensures that focused panes maintain their outlines, even when neighboring cells put lines on shared edges.

The implementation relies on a single Data Control String (DCS) with a namespace, simplifying the process and providing a common path for setting the pen (cell borders) and printing text. A capability query allows apps to check if the terminal supports cell borders, and if not, the application can fallback to using box-drawing characters.

In conclusion, cell borders offer a more efficient and visually appealing approach to terminal interfaces, providing a seamless and clutter-free user experience.

Written by urgent.news from Hacker News'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 →