Created
January 13, 2012 11:31
-
-
Save vext01/1605660 to your computer and use it in GitHub Desktop.
Window flicker test case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <curses.h> | |
int | |
main(void) | |
{ | |
WINDOW *lwin; /* large window */ | |
WINDOW *bwin; /* bar window */ | |
WINDOW *owin; /* other window - overlaps largewin */ | |
int i = 0; | |
initscr(); | |
/* make wins */ | |
if ((lwin = newwin(LINES - 1, COLS, 0, 0)) == NULL) | |
fprintf(stderr, "lwin newwin fail\n"); | |
if ((bwin = newwin(1, COLS, LINES - 1, 0)) == NULL) | |
fprintf(stderr, "lwin newwin fail\n"); | |
if ((owin = newwin(10, 10, 10, 10)) == NULL) | |
fprintf(stderr, "owin newwin fail\n"); | |
/* colours */ | |
if (start_color() == ERR) | |
fprintf(stderr, "Could not initialise colour terminal"); | |
init_pair(1, COLOR_YELLOW, COLOR_BLUE); | |
init_pair(2, COLOR_YELLOW, COLOR_RED); | |
init_pair(3, COLOR_YELLOW, COLOR_GREEN); | |
wbkgd(lwin, COLOR_PAIR(1)); | |
wbkgd(bwin, COLOR_PAIR(2)); | |
wbkgd(owin, COLOR_PAIR(3)); | |
/* put some text in */ | |
wprintw(lwin, "Large window"); | |
wprintw(bwin, "Bar window"); | |
wprintw(owin, "Other window"); | |
wrefresh(lwin); | |
wrefresh(bwin); | |
wrefresh(owin); | |
/* pause until a keypress */ | |
wgetch(lwin); | |
wclear(bwin); | |
for (i = 0; i < COLS; i ++) { | |
wclear(bwin); /* offending function call - makes whole screen update */ | |
wprintw(bwin, "*"); | |
wrefresh(bwin); | |
redrawwin(bwin); | |
usleep(100); | |
} | |
/* pause until a keypress */ | |
wgetch(lwin); | |
delwin(lwin); | |
delwin(bwin); | |
delwin(owin); | |
if (endwin() != OK) | |
fprintf(stderr, "fail"); | |
return (EXIT_SUCCESS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment