Ok, something small but fun to share!
I put together a very basic TUI package to help with printing nice stuff to the terminal.
The API
main =
Term.print
[ Term.empty
, Term.empty
, Term.row [ Term.yellow ]
[ Term.text "──"
, Term.text " Welcome to Roc Terminal UI! "
, Term.fill "─"
, Term.text "Term.roc"
|> Term.with [ Term.cyan ]
]
, Term.lines [ Term.indent 3 ]
[ Term.empty
, Term.text "An indented thing!"
, Term.text "and another"
, Term.text "Maybe we want a list of other stuff!"
, Term.empty
, Term.lines [ Term.yellow ]
[ Term.row []
[ Term.text "Intro to Terminal UI"
, Term.fill "."
, Term.text "Page 5"
|> Term.with [ Term.red ]
]
, Term.row []
[ Term.text "Intro to Roc"
, Term.fill "."
, Term.text "Page 6"
|> Term.with [ Term.red ]
]
]
]
, Term.empty
, Term.fill "─"
, Term.text "Hello!!!!!!"
|> Term.with [ Term.indent 5, Term.red ]
, Term.empty
, Term.empty
]
The Result
It was really fun and satisfying to write :muscle:
I have an idea for a super simple animation API and a few convenience things for gathering input from the user too.
Looks great! Also, Term.fill
is simple and wonderful.
ooo, looks lovely! :smiley:
Terminal ascii command codes are haunted, no one go in there.
https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 is a great resource. I used it a lot for https://package.elm-lang.org/packages/wolfadex/elm-ansi/latest
I think I have some other links in comments for other useful ANSI things like measuring character (not Char) widths and such
Nice! I have that github gist in my notes, it's great :raised_hands:
I was running into some weird things where doing the "move up" command was erasing lines, which basically just meant that my understanding of what the cursor is was...well, I'm still slightly confused.
Last updated: Jul 06 2025 at 12:14 UTC