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 --- view.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'view.c') diff --git a/view.c b/view.c index 4ae4b87..df7906b 100644 --- a/view.c +++ b/view.c @@ -170,7 +170,7 @@ static void view_clear(View *view) { view->wrapcol = 0; view->prevch_breakat = false; if (view->ui) - view->cell_blank.style = view->ui->style_get(view->ui, UI_STYLE_DEFAULT); + view->ui->style_set(view->ui, &view->cell_blank, UI_STYLE_DEFAULT); } Filerange view_viewport_get(View *view) { @@ -1405,11 +1405,10 @@ bool view_style_define(View *view, enum UiStyle id, const char *style) { return view->ui->style_define(view->ui, id, style); } -void view_style(View *view, enum UiStyle style_id, size_t start, size_t end) { +void view_style(View *view, enum UiStyle style, size_t start, size_t end) { if (end < view->start || start > view->end) return; - CellStyle style = view->ui->style_get(view->ui, style_id); size_t pos = view->start; Line *line = view->topline; @@ -1435,7 +1434,7 @@ void view_style(View *view, enum UiStyle style_id, size_t start, size_t end) { do { while (pos <= end && col < width) { pos += line->cells[col].len; - line->cells[col++].style = style; + view->ui->style_set(view->ui, &line->cells[col++], style); } col = 0; } while (pos <= end && (line = line->next)); -- cgit v1.2.3