diff options
| author | Randy Palamar <randy@rnpnr.xyz> | 2025-01-08 20:13:53 -0700 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-08 20:23:51 -0700 |
| commit | 72c26fc09af79ce217575a9b0f0d5058c336d5d7 (patch) | |
| tree | 8979c4c5188174b71ef7ef57e93670dee0244cf4 /view.c | |
| parent | d5db964a4cd5ed2bce5e8724b800f6cb425df258 (diff) | |
| download | vis-72c26fc09af79ce217575a9b0f0d5058c336d5d7.tar.gz vis-72c26fc09af79ce217575a9b0f0d5058c336d5d7.tar.xz | |
ui: pass window id when setting style
There are a couple times when we want to set a style without an
active window. In those cases we just want to use base UI_STYLE_*s
and (Win *) is not needed.
This fixes a crash when trying to do a vis:info() from lua during
an initial file open event.
Note that this code is due for a serious refactor, ui styles
should be stored in Ui and window specific styles should be stored
in Win. Then we won't need any of this difficult to follow
indexing into the styles array based on window id and we will
never have to realloc when a new window opens. Just another thing
to add to my list.
Diffstat (limited to 'view.c')
| -rw-r--r-- | view.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -205,7 +205,7 @@ static void view_clear(View *view) { /* FIXME: awful garbage that only exists because every * struct in this program is an interdependent hellscape */ Win *win = (Win *)((char *)view - offsetof(Win, view)); - ui_window_style_set(win, &cell_blank, UI_STYLE_DEFAULT); + ui_window_style_set(&win->vis->ui, win->id, &cell_blank, UI_STYLE_DEFAULT); } static int view_max_text_width(const View *view) { @@ -1365,7 +1365,7 @@ void win_style(Win *win, enum UiStyle style, size_t start, size_t end) { do { while (pos <= end && col < width) { pos += line->cells[col].len; - ui_window_style_set(win, &line->cells[col++], style); + ui_window_style_set(&win->vis->ui, win->id, &line->cells[col++], style); } col = 0; } while (pos <= end && (line = line->next)); |
