1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-21 16:14:14 -04:00

Modify the wait_for_key() routine to take a window attribute parameter

This commit is contained in:
John Zaitseff 2011-07-11 17:57:52 +10:00
parent 86b88e8929
commit 89c3512a1b
3 changed files with 14 additions and 5 deletions

View File

@ -368,7 +368,7 @@ void init_game (void)
center(curwin, 3, ATTR_HIGHLIGHT_STR, "%1.46s", center(curwin, 3, ATTR_HIGHLIGHT_STR, "%1.46s",
player[first_player].name); player[first_player].name);
wait_for_key(curwin, 5); wait_for_key(curwin, 5, ATTR_WAITNORMAL_STR);
deltxwin(); deltxwin();
txrefresh(); txrefresh();
} }

View File

@ -327,6 +327,7 @@ int center (WINDOW *win, int y, int attr, const char *format, ...)
} }
oldattr = getbkgd(win) & ~A_CHARTEXT; oldattr = getbkgd(win) & ~A_CHARTEXT;
wbkgdset(win, A_NORMAL);
wattrset(win, attr); wattrset(win, attr);
va_start(args, format); 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); ret = mvwprintw(win, y, fill > 0 ? fill : 0, "%s", buf);
wattrset(win, oldattr); wattrset(win, oldattr);
wbkgdset(win, oldattr);
free(buf); free(buf);
return ret; return ret;
@ -368,6 +370,7 @@ int attrpr (WINDOW *win, int attr, const char *format, ...)
oldattr = getbkgd(win) & ~A_CHARTEXT; oldattr = getbkgd(win) & ~A_CHARTEXT;
wbkgdset(win, A_NORMAL);
wattrset(win, attr); wattrset(win, attr);
va_start(args, format); va_start(args, format);
@ -375,6 +378,7 @@ int attrpr (WINDOW *win, int attr, const char *format, ...)
va_end(args); va_end(args);
wattrset(win, oldattr); wattrset(win, oldattr);
wbkgdset(win, oldattr);
return ret; return ret;
} }
@ -482,6 +486,7 @@ int gettxline (WINDOW *win, char *buf, int bufsize, bool multifield,
wtimeout(win, -1); wtimeout(win, -1);
oldattr = getbkgd(win) & ~A_CHARTEXT; oldattr = getbkgd(win) & ~A_CHARTEXT;
wbkgdset(win, A_NORMAL);
wattrset(win, attr & ~A_CHARTEXT); wattrset(win, attr & ~A_CHARTEXT);
curs_set(CURS_ON); curs_set(CURS_ON);
@ -1083,6 +1088,7 @@ int gettxline (WINDOW *win, char *buf, int bufsize, bool multifield,
wattron(win, A_BOLD); wattron(win, A_BOLD);
mvwprintw(win, y, x, "%-*.*s", fieldsize, fieldsize, buf); mvwprintw(win, y, x, "%-*.*s", fieldsize, fieldsize, buf);
wattrset(win, oldattr); wattrset(win, oldattr);
wbkgdset(win, oldattr);
wrefresh(win); wrefresh(win);
if (modified != NULL) { if (modified != NULL) {
@ -1156,6 +1162,7 @@ bool answer_yesno (WINDOW *win)
wtimeout(win, -1); wtimeout(win, -1);
oldattr = getbkgd(win) & ~A_CHARTEXT; oldattr = getbkgd(win) & ~A_CHARTEXT;
wbkgdset(win, A_NORMAL);
wattron(win, A_BOLD); wattron(win, A_BOLD);
curs_set(CURS_ON); curs_set(CURS_ON);
@ -1177,6 +1184,7 @@ bool answer_yesno (WINDOW *win)
} }
wattrset(win, oldattr); wattrset(win, oldattr);
wbkgdset(win, oldattr);
wrefresh(win); wrefresh(win);
return (key == 'Y'); return (key == 'Y');
} }
@ -1186,12 +1194,13 @@ bool answer_yesno (WINDOW *win)
Function: wait_for_key - Print a message and wait for any key Function: wait_for_key - Print a message and wait for any key
Arguments: win - Window to use Arguments: win - Window to use
y - Line on which to print message y - Line on which to print message
attr - Window attributes to use for message
Returns: (nothing) Returns: (nothing)
This function prints a message, then waits for any key to be pressed. 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; int key;
@ -1201,7 +1210,7 @@ void wait_for_key (WINDOW *win, int y)
wtimeout(win, -1); wtimeout(win, -1);
curs_set(CURS_OFF); curs_set(CURS_OFF);
center(win, y, ATTR_WAITFORKEY_STR, "[ Press <SPACE> to continue ] "); center(win, y, attr, "[ Press <SPACE> to continue ] ");
wrefresh(win); wrefresh(win);
key = wgetch(win); key = wgetch(win);

View File

@ -124,7 +124,7 @@ enum color_pairs {
#define ATTR_INPUT_FIELD ATTR(COLOR_PAIR(WHITE_ON_BLACK), A_BOLD | '_') #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_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_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); int y, int x, int fieldsize, int attr, bool *modified);
extern bool answer_yesno (WINDOW *win); 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 */ #endif /* included_INTF_H */