Stream: beginners

Topic: Roc native TUI


view this post on Zulip Luke Boswell (Jun 14 2023 at 10:42):

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?

view this post on Zulip Luke Boswell (Jun 14 2023 at 10:45):

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.

view this post on Zulip Luke Boswell (Jun 14 2023 at 10:51):

$ roc dev Experiments/TUI.roc
^[[44;162R
Row: 44, Col: 162

view this post on Zulip Richard Feldman (Jun 14 2023 at 11:18):

according to GPT-4, it can't be done just by sending bytes

view this post on Zulip Richard Feldman (Jun 14 2023 at 11:18):

you have to use a library like termios

view this post on Zulip Ayaz Hafiz (Jun 14 2023 at 13:28):

Yeah you’ll need a separate task, because entering raw mode requires touching device drivers

view this post on Zulip Luke Boswell (Jun 15 2023 at 23:52):

@Richard Feldman would you consider a PR that adds this for basic-cli?

view this post on Zulip Richard Feldman (Jun 15 2023 at 23:53):

:thinking: what happens if you switch back and forth to/from raw mode?

view this post on Zulip Luke Boswell (Jun 15 2023 at 23:54):

I'll do some experimentation

view this post on Zulip Richard Feldman (Jun 15 2023 at 23:54):

sounds good!


Last updated: Jul 06 2025 at 12:14 UTC