Originally Posted by
Nominal Animal
Truly portable code can avoid any issues the standard C I/O implementation may have, by instead using custom low-level I/O functions instead. In particular, a subset of functions provided by curses libraries would definitely be doable. (This is what GNU readline library does, for example.)
If there is interest, I could show some example code for that too. In particular, it might be useful to have non-blocking input (that parses ANSI escape sequences into a single int on input), and some limited curses-like functions; plus of course a normal printf() function to output to standard output and/or error (regardless of whether they are the terminal or something else).