From 95bf9f59f8a9a37148bdc0787db378d62c7cd032 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Thu, 19 Oct 2023 07:19:00 -0600 Subject: ui: refactor style handling The old style handling had a lot edge cases where one of the colours or the attribute wouldn't get applied correctly. This commit adds a new style_set() method to the Ui which should be called instead of manually touching a cell's style. This also means that the Cell struct can be made opaque since all the handling is now done inside the ui-terminal files. With this it is now viable to combine the light and dark 16 colour themes into a single base-16 theme. This theme works very well with the Linux virtual console and will now be the default theme regardless of if the terminal supports 256 colours or not. This should address the common complaints about vis not respecting the users default terminal colours. fixes #1151: Theming is sometimes partially applied or ignored see #1103: terminal no longer has transparency/opacity see #1040: Transparent background and setting options by default --- ui.h | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'ui.h') diff --git a/ui.h b/ui.h index ce98af1..76bdcce 100644 --- a/ui.h +++ b/ui.h @@ -54,23 +54,12 @@ enum UiStyle { #if CONFIG_CURSES typedef uint64_t CellAttr; typedef short CellColor; - -static inline bool cell_color_equal(CellColor c1, CellColor c2) { - return c1 == c2; -} #else typedef uint8_t CellAttr; typedef struct { uint8_t r, g, b; uint8_t index; } CellColor; - -static inline bool cell_color_equal(CellColor c1, CellColor c2) { - if (c1.index != (uint8_t)-1 || c2.index != (uint8_t)-1) - return c1.index == c2.index; - return c1.r == c2.r && c1.g == c2.g && c1.b == c2.b; -} - #endif typedef struct { @@ -107,7 +96,7 @@ struct Ui { }; struct UiWin { - CellStyle (*style_get)(UiWin*, enum UiStyle); + void (*style_set)(UiWin*, Cell*, enum UiStyle); void (*status)(UiWin*, const char *txt); void (*options_set)(UiWin*, enum UiOption); enum UiOption (*options_get)(UiWin*); @@ -116,7 +105,6 @@ struct UiWin { int (*window_height)(UiWin*); }; -bool is_default_color(CellColor c); enum UiLayout ui_layout_get(Ui *ui); #endif -- cgit v1.2.3