From 1995a6a7b0ffc833e1267d3709f810a2922c2d97 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Mon, 11 Jul 2011 08:01:18 +1000 Subject: [PATCH] Remove the superfluous argument attr_end from attrpr() Instead of using attr_end, simply restore the old window attributes after printing the string. --- src/intf.c | 25 +++++++++++++------------ src/intf.h | 5 ++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/intf.c b/src/intf.c index 1f2f5cb..4739f86 100644 --- a/src/intf.c +++ b/src/intf.c @@ -351,31 +351,32 @@ int center (WINDOW *win, int y, const bool clrline, const char *format, ...) /*----------------------------------------------------------------------- - Function: attrpr - Print a string with special attributes - Arguments: win - Window to use - attr_start - Attribute to set at the start of wprintw() - attr_end - Attribute to set at the end of wprintw() - format - printf()-like format string - ... - printf()-like arguments - Returns: int - Return code from wprintw() + Function: attrpr - Print a string with special attributes + Arguments: win - Window to use + attr - Attribute to use for the string + format - printf()-like format string + ... - printf()-like arguments + Returns: int - Return code from wprintw() - This function sets the window attribute to attr_start, then prints the - given string (using wprintw()), then sets the attribute to attr_end. + This function sets the window attributes to attr, then prints the given + string (using wprintw()), then restores the previous window attributes. */ -int attrpr (WINDOW *win, int attr_start, int attr_end, const char *format, ...) +int attrpr (WINDOW *win, int attr, const char *format, ...) { va_list args; + int oldattr; int ret; - wattrset(win, attr_start); + oldattr = getbkgd(win) & ~A_CHARTEXT; + wattrset(win, attr); va_start(args, format); ret = vwprintw(win, format, args); va_end(args); - wattrset(win, attr_end); + wattrset(win, oldattr); return ret; } diff --git a/src/intf.h b/src/intf.h index b1f7b93..db34d4a 100644 --- a/src/intf.h +++ b/src/intf.h @@ -117,9 +117,8 @@ extern int center (WINDOW *win, int y, const bool clrline, const char *format, ...) __attribute__((format (printf, 4, 5))); -extern int attrpr (WINDOW *win, int attr_start, int attr_end, - const char *format, ...) - __attribute__((format (printf, 4, 5))); +extern int attrpr (WINDOW *win, int attr, const char *format, ...) + __attribute__((format (printf, 3, 4))); // Input routines