Terminal borders that don't cost a cell

(joshka.net)

65 points | by vinhnx 2 hours ago

13 comments

  • joouha 2 hours 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

    • joshka 38 minutes 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.
    • muqsitnawaz 37 minutes 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
    • hnlmorg 1 hour 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 16 minutes 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.

  • tptacek 2 hours 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 48 minutes 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.

    • fc417fc802 49 minutes 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.

    • unshavedyak 1 hour 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.

    • hedgehog 1 hour 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 1 hour ago
        Teletypes and dumb terminals managed to implement local echo. You don't need to round trip everything.
  • nmstoker 6 minutes ago
    Love this. And the people who like more space can opt for that (this doesn't look things in).
  • kodoman 16 minutes 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.

  • dead_hn_theory 34 minutes ago
    There's a nice thread about this on lobsters, but the author is getting piled on.
    • joshka 8 minutes 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).

  • montroser 2 hours 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 1 hour 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 32 minutes 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.
  • ganelonhb 1 hour ago
    This is gorgeous and I need it in trunk for both kitty and ghostty
  • cobychapple 2 hours ago
    Would be cool to get borders and lines out of copy/paste
  • kevin_thibedeau 44 minutes ago
    How much RAM does this use?
    • joshka 21 minutes 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.
  • 0c3ca83 2 hours 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 7 minutes 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.
    • rvz 1 hour ago
      Honestly why? It is not designed at all for that.

      In fact it just makes it less secure.

      • echoangle 41 minutes 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 31 minutes 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 35 minutes ago
        Ssh lets you forward arbitrary ports, and forward X11 directly. Why is HTML more of a problem?
    • orbital-decay 57 minutes 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).
    • drdaeman 2 hours 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…

      • masfuerte 1 hour ago
        While we're figuring it out let's call this hypothetical protocol X.
        • ncruces 1 hour ago
          We could even use `ssh -X` to send it over SSH if that flag is otherwise unused.
          • cluckindan 1 hour ago
            I think it would make sense if it had a client-server architecture.
            • arboles 56 minutes 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 53 minutes 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.

          • arboles 52 minutes 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 25 minutes 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 1 hour ago
        plan 9?
  • kenzo_cavanaugh 2 hours ago
    [flagged]