style.c (930B)
1#include "style.h" 2 3#include <string.h> 4 5static int style_attrs[STYLE_COUNT]; 6 7void 8style_init(void) 9{ 10 memset(style_attrs, 0, sizeof(style_attrs)); 11 style_add(STYLE_DEFAULT, COLOR_WHITE, COLOR_BLACK, 0); 12 style_add(STYLE_TITLE, COLOR_WHITE, COLOR_BLUE, A_BOLD); 13 style_add(STYLE_PANE_SEP, COLOR_BLUE, COLOR_BLACK, 0); 14 style_add(STYLE_ITEM_SEL, COLOR_YELLOW, COLOR_BLACK, A_BOLD); 15 style_add(STYLE_ITEM_HOVER, COLOR_WHITE, COLOR_BLUE, 0); 16 style_add(STYLE_ITEM_HOVER_SEL, COLOR_YELLOW, COLOR_BLUE, A_BOLD); 17 style_add(STYLE_ERROR, COLOR_RED, COLOR_BLACK, 0); 18 style_add(STYLE_PREV, COLOR_WHITE, COLOR_BLACK, A_DIM); 19} 20 21void 22style_add(int style, int fg, int bg, int attr) 23{ 24 style_attrs[style] = attr; 25 init_pair(style, fg, bg); 26} 27 28void 29style_on(WINDOW *win, int style) 30{ 31 ATTR_ON(win, COLOR_PAIR(style) | style_attrs[style]); 32} 33 34void 35style_off(WINDOW *win, int style) 36{ 37 ATTR_OFF(win, COLOR_PAIR(style) | style_attrs[style]); 38} 39