From ecc2fd769331d1285997e3b644df329d36c840d9 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sun, 17 Apr 2016 20:31:27 +0300 Subject: screen: Add helpers to easy use color by name Added macros which allow easy specify color pair like: INIT_COLOR(YELLOW, BLACK); COLOR(YELLOW, BLACK); COLOR_ON(YELLOW, BLACK); by calculating pair id via generic formula. Added shorter color names via new enum. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- screen.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'screen.h') diff --git a/screen.h b/screen.h index 7a647be..f5a15d4 100644 --- a/screen.h +++ b/screen.h @@ -3,6 +3,23 @@ #include +enum colors { + BLACK = COLOR_BLACK, + RED = COLOR_RED, + GREEN = COLOR_GREEN, + YELLOW = COLOR_YELLOW, + BLUE = COLOR_BLUE, + MAGENTA = COLOR_MAGENTA, + CYAN = COLOR_CYAN, + WHITE = COLOR_WHITE, +}; + +#define COLOR_MASK(fg, bg) ((fg) + (bg) * (COLOR_WHITE + 1)) +#define COLOR(fg, bg) COLOR_PAIR(COLOR_MASK((fg), (bg))) +#define INIT_COLOR(fg, bg) init_pair(COLOR_MASK((fg), (bg)), (fg), (bg)) +#define COLOR_ON(fg, bg) attron(COLOR(fg, bg)) +#define COLOR_OFF(fg, bg) attroff(COLOR(fg, bg)) + extern WINDOW *screen_init(bool israw); extern void screen_end(void); -- cgit v1.2.3-54-g00ecf