From 72de33c4f15144e7c597fad850510dd7da88a0f2 Mon Sep 17 00:00:00 2001 From: Louis Burda Date: Mon, 14 Feb 2022 00:28:11 +0100 Subject: Refactored main.c into many files --- src/style.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/style.c (limited to 'src/style.c') diff --git a/src/style.c b/src/style.c new file mode 100644 index 0000000..3e7370f --- /dev/null +++ b/src/style.c @@ -0,0 +1,39 @@ +#include "style.h" + +#include + +static int style_attrs[STYLE_COUNT]; + +void +style_init(void) +{ + memset(style_attrs, 0, sizeof(style_attrs)); + style_add(STYLE_DEFAULT, COLOR_WHITE, COLOR_BLACK, 0); + style_add(STYLE_TITLE, COLOR_WHITE, COLOR_BLUE, A_BOLD); + style_add(STYLE_PANE_SEP, COLOR_BLUE, COLOR_BLACK, 0); + style_add(STYLE_ITEM_SEL, COLOR_YELLOW, COLOR_BLACK, A_BOLD); + style_add(STYLE_ITEM_HOVER, COLOR_WHITE, COLOR_BLUE, 0); + style_add(STYLE_ITEM_HOVER_SEL, COLOR_YELLOW, COLOR_BLUE, A_BOLD); + style_add(STYLE_ERROR, COLOR_RED, COLOR_BLACK, 0); + style_add(STYLE_PREV, COLOR_WHITE, COLOR_BLACK, A_DIM); +} + +void +style_add(int style, int fg, int bg, int attr) +{ + style_attrs[style] = attr; + init_pair(style, fg, bg); +} + +void +style_on(WINDOW *win, int style) +{ + ATTR_ON(win, COLOR_PAIR(style) | style_attrs[style]); +} + +void +style_off(WINDOW *win, int style) +{ + ATTR_OFF(win, COLOR_PAIR(style) | style_attrs[style]); +} + -- cgit v1.2.3-71-gd317