So, I thought I might experiment with using ANSI escape codes to see if it it possible to make a TUI just using basic-cli
. This gist is one experiment to get the size of the current window, and shows my current problem.
It works well, however it requires a newline input from the user to send the buffered bytes as the terminal is not in raw mode. I'm hoping someone might be able to help or have some insight here. Basically, is it possible to put a terminal into raw mode (so that bytes are not buffered) just by sending bytes down the line, or is that only possible within the platform using a library like termios
or rustyline
?
My current line of thought is that we could add a task to switch to raw mode from the platform, and then another to reset back to canonical mode.
$ roc dev Experiments/TUI.roc
^[[44;162R
Row: 44, Col: 162
according to GPT-4, it can't be done just by sending bytes
you have to use a library like termios
Yeah you’ll need a separate task, because entering raw mode requires touching device drivers
@Richard Feldman would you consider a PR that adds this for basic-cli
?
:thinking: what happens if you switch back and forth to/from raw mode?
I'll do some experimentation
sounds good!
Last updated: Jul 06 2025 at 12:14 UTC