feat: TUIs through ex_ratatui - #34
Conversation
|
Hi @mcass19, this is absolutely incredible!! Super cool to see what you've done here, and I'm especially impressed as the rendering performance seems to be great. This is definitely something that I think we can integrate into the upcoming Nerves Starter Kit. That being said, I'm currently spending most of my time getting the NSK ready. One of the areas I'm working on in that regard is creating a framework for designing screens, which will be a standalone library that will be pushed to hex. The goal is to enable people to make libraries of reusable screens or components. As a part of this, I already know that there's interest in supporting various rendering engines, and so I'm working on designing the library to have an adapter pattern for renderers. I think ex_ratatui would fit very nicely in this abstraction. I'd love to work together to make this one of the officially supported rendering engines :) In terms of timelines - I'm really pushing on the starter kit right now, and I hope that I can clean up and make public an early version of the rendering library later this month (at which point we can start on implementing an ex_ratatui renderer). For this repo in general, it is somewhat in low-maintenance mode until I get the rendering framework more ready. At that point, I'd like to come back and update this entire repo to use the new framework. It will require a bit of a refactor, but at that point I'd love to merge in your screens! I'm reachable on the Nerves Discord if you want to discuss specifics on the library and architecture. There's a |
|
Thanks @gworkman!!! Of course, no need to do anything with these changes. I wanted to go end-to-end and demonstrate it working on the hardware I have, and share it with you all. Looking forward to the starter kit (already on the waiting list 🙂). Excited about the upcoming rendering framework, and happy to collaborate on making TUIs through ex_ratatui a first-class option once we have it. I'll share in Discord |
Hi @gworkman, hope you're doing well!
What
ex_ratatui recently got a CellSession transport that exposes ratatui's cell grid as a stream of
{row, col, char, fg, bg, modifiers}events instead of writing escape codes to a TTY. That makes it possible to bridge ex_ratatui to anything that can paint cells. Including this badge, so I went for it.There's a generic
Screen.ExRatatuiadapter that hosts anyuse ExRatatui.Appmodule as a screen, a small 6×8 bitmap font included inNameBadge.ExRatatui.Font, and a rasteriser inNameBadge.ExRatatui.Rasterthat walks the cells, draws each glyph into a 400×300 buffer, and inverts pixels forbg: :blackor:reversed.There's more in the README in the folder, including how easy is to add a new screen.
Demo
Three demos are wired into the carousel:
Here's me showing the three screens running on the real hardware:
badge_demo_compressed.mp4
Bonus
While I was at it I also registered a
nerves_sshsubsystem pointing at a system monitor TUI. Same library, much wider rendering surface. Plainssh nerves@wisteria.local(no-s) still drops into the usual IEx prompt.Next steps
Try it and let me know if useful :).
This is a BIG PR, it has a lot of commits with some back&forth. Each one a step along the way to making it work as clean as possible. Happy to split it however's most useful. One concrete option would be to extract
NameBadge.ExRatatui.Raster(plus the font) into its own small library so also the Nerves Starter Kit or any project with a framebuffer-ish display can host TUIs. Open to whatever direction you'd like to take if any. Very happy to collaborate.