Re: Phix, numbers, printf, log10
- Posted by jimcbrown (admin) in April
- 605 views
Doesn't work with Linux, at least not for now. The input editor needs video_config() for the screen width, but even more important are get_position() and position() for the cursor, and since they don't work under Linux,
Must be Phix specific? get_position() and position() work fine under OE iirc - though if memory serves correctly this is tied to ncurses (which Phix is not likely using).
And it looks like it's a problem for everyone: https://unix.stackexchange.com/questions/714209/get-cursor-location-in-tty-without-reading-from-stdin-need-help-with-redirectio
I suspect that this is what ncurses does internally - on startup (before any user input has happened) set the position by writing to stdout. That way the position is at some known fixed value.
Use a state machine of some kind, so with every write to the screen, a variable gets updated with the current position.
When writing to the screen, prefix each write with the escape sequence to set the position - this minimizes sides from other processes writing on the terminal and changing the position behind our backs.
Finally, when getting the current position, consult the variable instead of asking the terminal. That way there's no issue of reading from stdin and losing data.