Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workaround a bug in cursor positioning
this testprogram is supposed to create a rotating wheel animation: #include <ncurses.h> #include <unistd.h> int main() { int i, x, y; initscr(); cbreak(); noecho(); printw("press a key to start - you should see a 'rotating wheel' animation"); getch(); getmaxyx(stdscr, y, x); for (i = 0; i < 16; i++) { move(0, x-1); addch("\\-/|"[i%4]); refresh(); sleep(1); } clear(); refresh(); endwin(); return 0; } however it actually produced output like "\-/|\-/|\-/|". this is due to an optimization that does not move the terminal cursor if the target position is the same as the supposedly current position. supposedly, because the code that writes a single character does not increment the internal cursor position, even though the terminal's cursor is advanced by one through the write. it is possible that the author of the code in question trusted in the domvcur() function to do the bookkeeping for him, and wasn't aware of the optimization, or vice versa the author of the optimization unaware of the usage of the function for syncing the cursor position.
- Loading branch information