From 89c3512a1b6f9abd105f613f81e244f37c8d8aac Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Mon, 11 Jul 2011 17:57:52 +1000 Subject: [PATCH] Modify the wait_for_key() routine to take a window attribute parameter --- src/game.c | 2 +- src/intf.c | 13 +++++++++++-- src/intf.h | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/game.c b/src/game.c index f0d53ab..78d778f 100644 --- a/src/game.c +++ b/src/game.c @@ -368,7 +368,7 @@ void init_game (void) center(curwin, 3, ATTR_HIGHLIGHT_STR, "%1.46s", player[first_player].name); - wait_for_key(curwin, 5); + wait_for_key(curwin, 5, ATTR_WAITNORMAL_STR); deltxwin(); txrefresh(); } diff --git a/src/intf.c b/src/intf.c index 2d9e589..ff2b029 100644 --- a/src/intf.c +++ b/src/intf.c @@ -327,6 +327,7 @@ int center (WINDOW *win, int y, int attr, const char *format, ...) } oldattr = getbkgd(win) & ~A_CHARTEXT; + wbkgdset(win, A_NORMAL); wattrset(win, attr); va_start(args, format); @@ -342,6 +343,7 @@ int center (WINDOW *win, int y, int attr, const char *format, ...) ret = mvwprintw(win, y, fill > 0 ? fill : 0, "%s", buf); wattrset(win, oldattr); + wbkgdset(win, oldattr); free(buf); return ret; @@ -368,6 +370,7 @@ int attrpr (WINDOW *win, int attr, const char *format, ...) oldattr = getbkgd(win) & ~A_CHARTEXT; + wbkgdset(win, A_NORMAL); wattrset(win, attr); va_start(args, format); @@ -375,6 +378,7 @@ int attrpr (WINDOW *win, int attr, const char *format, ...) va_end(args); wattrset(win, oldattr); + wbkgdset(win, oldattr); return ret; } @@ -482,6 +486,7 @@ int gettxline (WINDOW *win, char *buf, int bufsize, bool multifield, wtimeout(win, -1); oldattr = getbkgd(win) & ~A_CHARTEXT; + wbkgdset(win, A_NORMAL); wattrset(win, attr & ~A_CHARTEXT); curs_set(CURS_ON); @@ -1083,6 +1088,7 @@ int gettxline (WINDOW *win, char *buf, int bufsize, bool multifield, wattron(win, A_BOLD); mvwprintw(win, y, x, "%-*.*s", fieldsize, fieldsize, buf); wattrset(win, oldattr); + wbkgdset(win, oldattr); wrefresh(win); if (modified != NULL) { @@ -1156,6 +1162,7 @@ bool answer_yesno (WINDOW *win) wtimeout(win, -1); oldattr = getbkgd(win) & ~A_CHARTEXT; + wbkgdset(win, A_NORMAL); wattron(win, A_BOLD); curs_set(CURS_ON); @@ -1177,6 +1184,7 @@ bool answer_yesno (WINDOW *win) } wattrset(win, oldattr); + wbkgdset(win, oldattr); wrefresh(win); return (key == 'Y'); } @@ -1186,12 +1194,13 @@ bool answer_yesno (WINDOW *win) Function: wait_for_key - Print a message and wait for any key Arguments: win - Window to use y - Line on which to print message + attr - Window attributes to use for message Returns: (nothing) This function prints a message, then waits for any key to be pressed. */ -void wait_for_key (WINDOW *win, int y) +void wait_for_key (WINDOW *win, int y, int attr) { int key; @@ -1201,7 +1210,7 @@ void wait_for_key (WINDOW *win, int y) wtimeout(win, -1); curs_set(CURS_OFF); - center(win, y, ATTR_WAITFORKEY_STR, "[ Press to continue ] "); + center(win, y, attr, "[ Press to continue ] "); wrefresh(win); key = wgetch(win); diff --git a/src/intf.h b/src/intf.h index 175acd4..b47d073 100644 --- a/src/intf.h +++ b/src/intf.h @@ -124,7 +124,7 @@ enum color_pairs { #define ATTR_INPUT_FIELD ATTR(COLOR_PAIR(WHITE_ON_BLACK), A_BOLD | '_') #define ATTR_KEYCODE_STR ATTR(COLOR_PAIR(YELLOW_ON_BLACK) | A_BOLD, A_REVERSE) #define ATTR_HIGHLIGHT_STR ATTR(COLOR_PAIR(YELLOW_ON_BLUE) | A_BOLD, A_BOLD) -#define ATTR_WAITFORKEY_STR ATTR(COLOR_PAIR(CYAN_ON_BLUE), A_NORMAL) +#define ATTR_WAITNORMAL_STR ATTR(COLOR_PAIR(CYAN_ON_BLUE), A_NORMAL) /************************************************************************ @@ -168,7 +168,7 @@ extern int gettxstring (WINDOW *win, char **bufptr, bool multifield, int y, int x, int fieldsize, int attr, bool *modified); extern bool answer_yesno (WINDOW *win); -extern void wait_for_key (WINDOW *win, int y); +extern void wait_for_key (WINDOW *win, int y, int attr); #endif /* included_INTF_H */