From: Michael Göhler Date: Sun, 20 Mar 2016 11:48:09 +0000 (+0100) Subject: fixed window refresh behavior for #100 X-Git-Url: https://git.danieliu.xyz/?p=smdp.git;a=commitdiff_plain;h=848c4a361effd594b47c90ea5e14d4b620393212 fixed window refresh behavior for #100 --- diff --git a/src/viewer.c b/src/viewer.c index d106a62..925efb1 100644 --- a/src/viewer.c +++ b/src/viewer.c @@ -229,12 +229,14 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa colors = 1; } - // set background color of main window + // set background color for main window if(colors) - wbkgd(stdscr, COLOR_PAIR(CP_YELLOW)); + wbkgd(stdscr, COLOR_PAIR(CP_WHITE)); - // setup main window + // setup content window WINDOW *content = newwin(LINES - bar_top - bar_bottom, COLS, 0 + bar_top, 0); + + // set background color of content window if(colors) wbkgd(content, COLOR_PAIR(CP_WHITE)); @@ -261,6 +263,10 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa // always resize window in case terminal geometry has changed wresize(content, LINES - bar_top - bar_bottom, COLS); + // set main window text color + if(colors) + wattron(stdscr, COLOR_PAIR(CP_YELLOW)); + // setup header if(bar_top) { line = deck->header; @@ -304,9 +310,8 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa break; } - // make header + fooder visible - wrefresh(content); - wrefresh(stdscr); + // copy changed lines in main window to virtual screen + wnoutrefresh(stdscr); line = slide->line; l = stop = 0; @@ -339,8 +344,11 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert, int reloa } } - // make content visible - wrefresh(content); + // copy changed lines in content window to virtual screen + wnoutrefresh(content); + + // compare virtual screen to physical screen and does the actual updates + doupdate(); // fade in if(fade) @@ -863,8 +871,11 @@ void fade_out(WINDOW *window, int trans, int colors, int invert) { init_pair(CP_BLACK, 16, white_ramp[i]); } - // refresh window with new color - wrefresh(window); + // refresh virtual screen with new color + wnoutrefresh(window); + + // compare virtual screen to physical screen and does the actual updates + doupdate(); // delay for our eyes to recognize the change usleep(FADE_DELAY); @@ -890,8 +901,11 @@ void fade_in(WINDOW *window, int trans, int colors, int invert) { init_pair(CP_BLACK, 16, white_ramp[i]); } - // refresh window with new color - wrefresh(window); + // refresh virtual screen with new color + wnoutrefresh(window); + + // compare virtual screen to physical screen and does the actual updates + doupdate(); // delay for our eyes to recognize the change usleep(FADE_DELAY);