Then, I realized I can do a hack, and use an ANSI code to move the cursor alllll the way to the bottom right, then use another ANSI code, that replies with the current cursor position. this works!
However, I can't read the stdin where the response goes, without pressing enter. And to read without pressing enter, requires going into "non-canonical" mode (A.K.A raw mode). Which, doesn't seem to be able to be done, without ioctl or termios :(
For a full screen matrix effect.
Attempted solutions
First I tried getting the
$LINES
and$COLUMNS
, but I guess that is not supported in programs.Doing some more researc, seems C programs seem to use
ioctl
ortermios
to do this: https://stackoverflow.com/questions/1022957/getting-terminal-width-in-c . However, in WASI we don't have this.Then, I realized I can do a hack, and use an ANSI code to move the cursor alllll the way to the bottom right, then use another ANSI code, that replies with the current cursor position. this works!
However, I can't read the stdin where the response goes, without pressing enter. And to read without pressing enter, requires going into "non-canonical" mode (A.K.A raw mode). Which, doesn't seem to be able to be done, without
ioctl
ortermios
:(See my fustration at: https://github.com/torch2424/wasm-matrix/commit/eb51dab3413e0f81aee21cf9e4abfbb053681506
Which has nice links to the POSIX behind the scenes on how this could be implemented.
This problem mostly steams from me not being able to find docs on how to implement an
ioctl
ortermios
API.