Reputation: 105
I'm trying to get the current location of the cursor and I can't seem to be able to do that.
Apparently, the stdscr.getxy()
is supposed to return the current position, however it does not seem to return the correct location.
As you can see, getyx()
returns a very similar value to getmaxyx()
.
The cursor is on line 2 at character 24, so the Y coordinate (27) makes sense, however the X coordinate (99) doesn't. Shouldn't it be something like 76 (100-24)?
Upvotes: 1
Views: 1374
Reputation: 54475
curses uses a virtual screen and a physical screen. The virtual screen contains the information that your program sets, while the physical screen is what actually appears on the terminal after optimizing the cursor movement.
You're seeing the latter (the physical screen), which will only correspond to the virtual screen after doing a refresh. Normally (when your program reads a character from the keyboard), those are equivalent (because getch
does a refresh).
Upvotes: 0