aboutsummaryrefslogtreecommitdiff
path: root/ui-terminal-vt100.c
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2023-10-19 07:19:00 -0600
committerRandy Palamar <randy@rnpnr.xyz>2024-03-25 21:09:42 -0600
commit95bf9f59f8a9a37148bdc0787db378d62c7cd032 (patch)
tree01c8c6e8f51260cef7fa048d0f7472ab93a4a327 /ui-terminal-vt100.c
parent49442e5178296a58f8ca2e267a93b89c5cca8e5b (diff)
downloadvis-95bf9f59f8a9a37148bdc0787db378d62c7cd032.tar.gz
vis-95bf9f59f8a9a37148bdc0787db378d62c7cd032.tar.xz
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
Diffstat (limited to 'ui-terminal-vt100.c')
-rw-r--r--ui-terminal-vt100.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/ui-terminal-vt100.c b/ui-terminal-vt100.c
index 3c785b8..565313f 100644
--- a/ui-terminal-vt100.c
+++ b/ui-terminal-vt100.c
@@ -75,7 +75,13 @@ typedef struct {
UiTerm uiterm;
Buffer buf;
} UiVt100;
-
+
+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;
+}
+
static CellColor color_rgb(UiTerm *ui, uint8_t r, uint8_t g, uint8_t b) {
return (CellColor){ .r = r, .g = g, .b = b, .index = (uint8_t)-1 };
}
@@ -219,6 +225,14 @@ static void ui_vt100_free(UiTerm *tui) {
buffer_release(&vtui->buf);
}
-bool is_default_color(CellColor c) {
+static bool is_default_color(CellColor c) {
return c.index == ((CellColor) CELL_COLOR_DEFAULT).index;
}
+
+static bool is_default_fg(CellColor c) {
+ return is_default_color(c);
+}
+
+static bool is_default_bg(CellColor c) {
+ return is_default_color(c);
+}