Terminal borders that don't cost a cell

(joshka.net)

136 points | by vinhnx 5 hours ago ago

62 comments

  • matheusmoreira 11 minutes ago ago

    As awesome as this is, but I can't shake the feeling terminals are becoming lightweight browsers...

  • joouha 4 hours ago ago

    A much better alternative to this would be to for more terminal emulators to implement overstrike mode (DECSET 20, as available on the VK100). That way you could just draw border characters over existing text cells to achieve the same thing.

    Unfortunately mintty is the only terminal emulator I'm aware of which supports overstrike [0], as this would open up a world of new possibilities for TUI apps if more widely supported.

    [0] https://github.com/mintty/mintty/wiki/CtrlSeqs#overstrike

    • inguz an hour ago ago

      Overstrike is underrated!

      I've really enjoyed using it on paper: https://hughpyle.com/ASR33/

    • hnlmorg 4 hours ago ago

      I’m not against overstrike, but I can think of one drawback of that solution: it becomes significantly harder to have rounded corners with a filled interior.

      But I’m not trying to argue for nor against either solution.

    • joshka 3 hours ago ago

      There's some downsides to this - I can't recall where I called this out off the top of my head, but this also adds a bunch more things that that wouldn't do that are covered in the spec.

      • iainmerrick 2 hours ago ago

        If you mean your proposal adds more things, that sounds like it might be over-complicated. To solve the problem of tightly-fitting boxes around terminal text -- if you consider that to be a real problem -- overstrike sounds like a really elegant solution.

        • joshka an hour ago ago

          Which things do you consider in your experience of writing tuis that are mentioned as being wanted in the blog post / rationale doc linked to be unnecessary?

          If you want those things then overstrike is insufficient.

        • zem 41 minutes ago ago

          cell borders sound even more elegant imo, they are a targeted, precise fix for a useful feature. overstrike sounds messy to me though I can see where it has a lot of uses.

    • muqsitnawaz 3 hours ago ago

      Expecting Terminal Emulators to support overstrike is a high bar even many text editors don't even support strikethrough. Would love to see it though

  • tptacek 5 hours ago ago

    I love this work and everything else Ratatui does but I have to ask: if you're changing the terminal protocol and the terminal itself to do this, why not do something more ambitious; a full monospaced information-dense UI framework, a terminal designed for user interfaces, rather than one designed to replicate the limitations of dumb terminals?

    • joshka 3 hours ago ago

      Yep,and I want to do that too :)

      I've written about it before, but in brief the mountain of standards is worth ripping out wholesale and doing write as a semantic protocol. It's needed to solve several things that work really poorly in terminals because their unit of compatibility is cells rather than a higher primitive. It's hard to bake something on top that works well.

      The need is most strong in Accessibility, Text wrapping, Scrollback handling (i.e. making the scrollback editable and not dead text), and various other bits that make writing highly functional TUIs. Coding agents tend to find all those edge cases.

      This often gets push back that it's easy, to which I can point nay sayers at the various many months long issues on things in Codex, Gemini, Claude etc. on flickering, scrolling, key handline, IME, ... doing anything moderately complex involves modeling a terminal in a terminal app effectively.

      Ghostty and Rex sort of do the opposite bit. If you think of it like a stack, they write a new layer underneath that transports the cells on a better multiplexer layer 0. I think a new semantic layer 2 is an approach that would be neat to work with.

      • tptacek 2 hours ago ago

        I think I mostly just want to see someone do it so I can see what it looks like; it just feels like something that should exist. You're taking baby steps towards it! :)

        • joshka 2 hours ago ago

          I kinda keep talking about it in the hopes that someone will be nerd sniped enough to throw tokens at it as an idea. Sort of what you're probably doing too I guess. ;)

    • fc417fc802 3 hours ago ago

      > a full monospaced information-dense UI framework, a terminal designed for user interfaces, rather than one designed to replicate the limitations of dumb terminals?

      I can only speak for myself but I use the CLI and TUIs specifically because of the limitations those modalities impose on software that uses them as the primary method for interfacing with the end user. If you want a full featured UI and all that comes with it why not just use QT or GTK or modern HTML or etc?

      I think the only "improvements" I'd like to see are thing such as metadata regarding what the different streams are for, an official way to communicate using structured data as opposed to raw bytes, that sort of thing. Spiritually in the same ballpark as the difference between HTML before and after CSS.

    • kccqzy 2 hours ago ago

      You can save all that effort and instead come up with a CSS framework that enforces monospaced fonts, uniform font sizes, encourage information-dense layouts, have borders that don’t take up a cell (border: solid 0.1rem black; padding: 0.5rem;). Pair it up with a small JavaScript framework that listens to keypresses and buffers them. Furthermore, the framework makes the user decide on fonts, whether to allow images, whether to adhere to a strict character grid etc.

    • unshavedyak 4 hours ago ago

      I actually am exploring exactly this. Ironically from the perspective of someone that was trying to leave the Terminal.

      How i got here i find kinda interesting. Originally i was trying to leave the terminal. Using GPUI/etc frameworks. I kept running into the terminal though, because no matter how nice the UI is - the terminal still needs to work excellently.

      Eventually i decided to try an abomination. To use a custom terminal which, not unlike Kitty images, allows generic apps to pass escape codes to control the UI components. Where the UI components have no restriction on "dumb terminals". So my text editor is a two part app, an editor and a tty to render the actual custom UI APC codes.

      This paved the way for true smooth scrolling from within a terminal editor, as the editor effectively paginates but the tty scrolls within the buffered pages. It allows for different UI components to mix fonts and font sizes, eg popup docs being a different size than the other text, and .. well, anything i suppose.

      I have to say it's working excellently and is slowly becoming my daily driver. I won't link it though, it's a fully vibe coded and even claude designed horror.

      I'm surprised i've not seen more of this in the past to be honest.

      • kodoman 2 hours ago ago

        I am running ewm (not exwm) which makes emacs into a wayland compositor and it's fantastic, most of the primitives dissolve and you script it with elisp, wayland windows are just a special buffer and where applicable normal windowing and buffering rules can be applied.

        The developer seems to have used AI heavily in the elisp code and it works very well.

      • skydhash 2 hours ago ago

        > To use a custom terminal which, not unlike Kitty images, allows generic apps to pass escape codes to control the UI components.

        > I'm surprised i've not seen more of this in the past to be honest.

        This is what emacs is. It's a text buffer, but text can have properties like how to render, and custom values. then a bunch of commands to manipulate the buffer and it's contents.

    • eviks 16 minutes ago ago

      Or even more ambitious - ditch the monospace

    • octoberfranklin an hour ago ago

      Because it will turn into the kitchen-sink mess that the Web is.

      Terminals work so well because there's a huge frictional cost to adding to the protocol. That's what keeps the protocol simple, which is what keeps multiple implementations feasible. Unlike the web, where unless you have GoogleBux you can't afford to implement it properly.

    • hedgehog 4 hours ago ago

      Text terminal with every keystroke round-tripped through the server is not a design that makes sense for any reason other than backwards compatibility. It's kind of annoying to design for and atrocious for performance.

      • toast0 4 hours ago ago

        Teletypes and dumb terminals managed to implement local echo. You don't need to round trip everything.

  • joshka 3 hours ago ago

    The big thing to note on this is one last caveat. I don't care about the actual spec on this - happy for that to be whatever works. I care more about the capability than how it's done / implemented.

    There's some bits that feel like they probably make sense to consider doing other ways, like how border placement works (inside, outside, on the border, etc.), and how the filling works - to make borders incorporate external or internal padding.

  • CGamesPlay an hour ago ago

    I am in general against the big push to fit GUI interfaces into the tty, but I have to say that this feature looks genuinely good. Vim will look great with this.

  • kodoman 3 hours ago ago

    This is pretty cool but this does feel like we are just reinventing another GUI display at this point.

    I don't generally like TUI's and think one gets more flexibility with raw text interfaces and being able to glue things together is more important then them looking nice. I think less fancy out put is better to be honest.

  • montroser 5 hours ago ago

    I appreciate the innovation happening with TUIs in these modern times. But, aesthetically, I have to say, I like my borders to have some breathing room, which gets lost in this particular treatment.

  • hnlmorg 4 hours ago ago

    Why wouldn’t this work over tmux? The authors claims don’t make a whole lot of sense because if this were a cell property, like any other CSI, then it’ll get rendered in the terminal emulator exactly as intended. And we know this because none of the other CSI sequences get garbled over multiplextors.

    But for there to be a dedicated section on how multiplexors wouldn’t work suggests to me that the authors already tried this via tmux.

    So I’m left wondering what they’ve done with the implementation of this to make that a problem.

    I spotted they are using DCS sequences. But even that shouldn’t be an issue itself.

    • joshka 3 hours ago ago

      Tmux drops DCS that it doesn't know like this. That aside, this is extra state per cell that needs to be tracked, handled, understood from a rendering perspective etc. It can work, but would require maybe a thousand lines of code or so to support storing and handling state, redraw etc. and all the various edge cases.

  • cobychapple 5 hours ago ago

    Would be cool to get borders and lines out of copy/paste

  • dead_hn_theory 3 hours ago ago

    There's a nice thread about this on lobsters, but the author is getting piled on.

    • joshka 3 hours ago ago

      I upvote naysayers comments there as I don't think votes should be used to indicate (dis)agreement at least not without commenting why, more an indication that this is a useful thing to discuss. So if you see my comments not getting votes while every other one has a bump, that's my vote on them :)

      It's kind of funny, I posted this here and there at similar times. Expected to be spam flagged there due to the anti-AI brigade, but my submission here was the one that actually got hit (likely because I disclosed AI use in the post body is my guess).

  • nmstoker 3 hours ago ago

    Love this. And the people who like more space can opt for that (this doesn't look things in).

  • octoberfranklin 2 hours ago ago

    Having markdown tables render with zero-cell spacing (use underlines for horizontal and different background shades for vertical) is just one of the billion reasons I will never, ever, ever go back to closed-source coding agents.

  • eviks 18 minutes ago ago

    Thanks for that slop warning, on a general point: wondering whether there might be enough momentum to finally ditch the whole terminal garbage and use proper GUIs in spite of what the card-punching devils intended?

  • krautburglar an hour ago ago

    Why do you people have to ruin terminals? If you wanted a web browser, we already have those, and they already have borders.

  • kevin_thibedeau 3 hours ago ago

    How much RAM does this use?

    • joshka 3 hours ago ago

      Nothing really - Ghostty has a bit of padding that's unused per cell - 16 bits. The implementation stores an ID into a lookup table with border combinations. If all of those were used and never cleaned up, 65535 at around 100 for each combination used, order of magnitude 25MB absolute worst case assuming no real optimization in place for this.

  • ganelonhb 3 hours ago ago

    This is gorgeous and I need it in trunk for both kitty and ghostty

  • movingimage an hour ago ago

    “….that don’t cost a cell.” How much do I hate AI hustle bro passive riddle writing.

  • TacticalCoder an hour ago ago

    A pet peeve of mine is that most people / WM get "useless gaps" wrong. You do want a gap between two terminals because otherwise there are times where things can get really confusing (where you don't know what belong to which terminal / window).

    So the "borderless" (0 pixels) / zero "useless gaps" simply are confusing and... Wrong.

    But then people who do use useless gap, as in TFA, get it wrong too: they typically add gaps near the monitor's edges.

    Yeah. But no. Sorry but my monitor's edge is a perfectly fine gap. I don't risk mistaking it for anything.

    So I modified my WM (the Awesome WM) to do proper "useless gaps" computation and remove the ones that really are useless: and that'd be those near the monitor's physical border.

    I mean: nearly everybody gets it wrong, but it's not complicated to get it right, is it?

    P.S: even the terminology is wrong... People calling those "useless gaps" haven't got a clue: they are useful. The only useless ones are the one on the monitor's edge (if your monitor has physical edges, which it probably does).

    • db48x an hour ago ago

      Man, I’d really like a monitor with no edges. One that just keeps going and going, past my window and the tree outside until it’s completely out of sight. 100% useful area.

  • 0c3ca83 5 hours ago ago

    What if, dare I say it, we just served HTML over ssh, and let the browser render a proper UI, instead of layering hacks on top of hacks?

    • kodoman 3 hours ago ago

      I think the other side of things is why have the graphic program run over ssh, just have raw text cli tools to manipulate what ever then have a program driving it. This for me is where emacs excels and some programs already fit well with this model and the fantastic (albeit hacky) tramp.

    • tcfhgj 2 hours ago ago

      No, i really don't want to have electron level bloat as a terminal

    • rvz 4 hours ago ago

      Honestly why? It is not designed at all for that.

      In fact it just makes it less secure.

      • echoangle 3 hours ago ago

        You mean serving html over SSH?

        It can already port forward so you can basically already do this, I don’t think that’s insecure per se.

        • zokier 3 hours ago ago

          Doing it through port forwarding is kinda bad though because generally access to network ports is not very well access controlled. Doing it through unix sockets (like x) would be much better but annoyingly browsers do not support http over uds

          https://bugzilla.mozilla.org/show_bug.cgi?id=1688774 etc

      • 0c3ca83 3 hours ago ago

        Ssh lets you forward arbitrary ports, and forward X11 directly. Why is HTML more of a problem?

    • drdaeman 4 hours ago ago

      > HTML

      > instead of hacks on top of hacks

      Afraid that’s a contradiction. In this role, HTML is a pile of hacks upon hacks that was not originally intended for UIs.

      But, yeah, people are trying to reinvent GUIs. By layering hacks over TTYs. If only there’d be some protocol for widgets and events over a stream connection…

      • PeeMcGee 2 hours ago ago

        > In this role, HTML is a pile of hacks upon hacks that was not originally intended for UIs.

        I get where you're going and am genuinely curious, what does a "better" system designed to do what HTML/JS have become actually look like? (or what would one look like?) There has to be markup of some sort, and there has to be scriptable interactions of some sort, right? If not, how else would it work?

      • masfuerte 4 hours ago ago

        While we're figuring it out let's call this hypothetical protocol X.

        • ncruces 4 hours ago ago

          We could even use `ssh -X` to send it over SSH if that flag is otherwise unused.

          • cluckindan 4 hours ago ago

            I think it would make sense if it had a client-server architecture.

            • arboles 3 hours ago ago

              And for the ecosystem's sake, punish (harshly) GUI toolkit developers that use bitmap rendering (GTK4 and Qt Quick applications are slow on ssh -X).

        • em-bee 3 hours ago ago

          the thing with X and wayland etc is, that they are low level. which is fine if you want full control over the presentation. what HTML was trying to do is to go higher level, send over some data and let the browser figure out how to present it. but it went wrong and people are abusing it as a low level presentation interface like X or wayland.

          what we are missing is a really high level protocol/system that takes really high level data and figures out the presentation on its own.

          take a list of files for example. you can run ls -l in a terminal and it will attempt a crude text based formatting of the output. or you can run a full gui filemanager.

          what if there was a command that would produce ls output as a table data structure, run in a sort of terminal that knows how to format a table nicely without the ls command having to include any formatting instructions? this terminal would have support for all sorts of data types and structures to display all of them nicely.

          • skydhash 2 hours ago ago

            > Take a list of files for example. you can run ls -l in a terminal and it will attempt a crude text based formatting of the output. or you can run a full gui filemanager.

            ls's output (and a few other programs') are human facing. They're not meant to be machine readable.

            > what if there was a command that would produce ls output as a table data structure, run in a sort of terminal that knows how to format a table nicely without the ls command having to include any formatting instructions? this terminal would have support for all sorts of data types and structures to display all of them nicely.

            Because that's just complexity for its own sake. What's simpler is to just create a shell alias for a particular view you want. The shell is for interactive usage, with some capabilities for automation. If something better is needed, you write a real program for it.

          • arboles 3 hours ago ago

            > what if there was a command that would produce ls output as a table data structure, run in a sort of terminal that knows how to format a table nicely without the ls command having to include any formatting instructions? this terminal would have support for all sorts of data types and structures to display all of them nicely.

            So, powershell? For some reason only IT jockeys on Microsoft's death grip remember and use its full capability after learning it.

            • drdexebtjl 3 hours ago ago

              There are many problems with powershell, but to me the absolute worst, won't even touch it with a 10-feet pole, is UTF-16.

      • em-bee 4 hours ago ago

        plan 9?

    • orbital-decay 3 hours ago ago

      UI in a browser is a massive hack in itself, a clean design would be better. For example a compact semantic remote access protocol to use with UIs, something like SPICE but better optimized for networks, fully presentation-independent, and less janky. This would let everyone use a GUI framework of their choice with an adapter. But people building terminal GUIs are culturally not ready for this, they'd rather continue reinventing the wheel and piling up hacks in terminals. I wonder when they realize that proportional fonts are more readable when vertical alignment is handled separately, and introduce terminals with variable-width fonts. And the presentation layer (I suggest calling it CSS).

  • movingimage an hour ago ago

    “That don’t cost a cell.” Can’t stand AI bro speak.

  • charles_f 2 hours ago ago

    > If that bothers you, feel free to close the tab.

    I probably missed on something, but I stopped there