Re: Wrong result of get_position()
- Posted by mattlewis (admin) Apr 26, 2011
- 1457 views
The interpreter simply tracks the number of characters output and updates based on that.
No, it doesn't. It uses some standard C-function from some lib of gcc, as far as I can see.
get_position() ultimately calls GetTextPositionP() in be_w.c:
struct rccoord GetTextPositionP() { struct rccoord p; p.row = screen_line; p.col = screen_col; return p; }
screen_line and screen_col are updated when you output anything to the console.
It's not UTF-8 aware, so it doesn't know that some of your characters are multi-byte. I'm not aware of a way to otherwise track the cursor position without using curses or something similar.
It doesn't use curses since 3.0
Yes, I know. There is an ncurses library in the archive, however. I haven't looked at it in a long time, but if you're working on a console app that relies on text positioning, it's probably worth a look.
Matt