Commit 4b9444c
committed
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.1 parent bf1e504 commit 4b9444c
1 file changed
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1238 | 1238 | | |
1239 | 1239 | | |
1240 | 1240 | | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1241 | 1244 | | |
1242 | 1245 | | |
1243 | 1246 | | |
| |||
1318 | 1321 | | |
1319 | 1322 | | |
1320 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1321 | 1333 | | |
1322 | 1334 | | |
| 1335 | + | |
1323 | 1336 | | |
1324 | 1337 | | |
1325 | 1338 | | |
| |||
0 commit comments