From 88a45b1e2e9561e172abf77f392ecb6e490ccd49 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 3 Sep 2023 19:48:18 +1000 Subject: [PATCH] ncurses: fix setting of default attrs on Draw:clear If no attrs are given for Draw:clear, we use background from parent. This wasn't implemented properly. If the pane receiving the text was the same as the pane that was cleared, the text got the background of a different pane. That should only happen on clear, not when drawing text. Signed-off-by: NeilBrown --- display-ncurses.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/display-ncurses.c b/display-ncurses.c index e6aae170..90c7e8f7 100644 --- a/display-ncurses.c +++ b/display-ncurses.c @@ -798,7 +798,7 @@ static int to_pair(struct display_data *dd safe, int fg, int bg) } static int cvt_attrs(struct pane *p safe, struct pane *home safe, - const char *attrs, int *pairp safe, bool use_parent) + const char *attrs, int *pairp safe) { struct display_data *dd = home->data; int attr = 0; @@ -809,10 +809,9 @@ static int cvt_attrs(struct pane *p safe, struct pane *home safe, int bg = COLOR_WHITE+8; set_screen(home); - do { + while (p->parent != p &&(pan = pane_panel(p, NULL)) == NULL) p = p->parent; - } while (p->parent != p &&(pan = pane_panel(p, NULL)) == NULL); - if (pan && use_parent) { + if (pan) { /* Get 'default colours for this pane - set at clear */ int at = getbkgd(panel_window(pan)); int pair = PAIR_NUMBER(at); @@ -920,7 +919,8 @@ DEF_CMD(nc_clear) struct display_data *dd = p->data; cchar_t cc = {}; int pair = 0; - int attr = cvt_attrs(ci->focus, p, ci->str, &pair, ci->str == NULL); + /* default come from parent when clearing pane */ + int attr = cvt_attrs(ci->focus->parent, p, ci->str, &pair); PANEL *panel; WINDOW *win; int w, h; @@ -976,7 +976,7 @@ DEF_CMD(nc_draw_text) { struct pane *p = ci->home; int pair = 0; - int attr = cvt_attrs(ci->focus, p, ci->str2, &pair, True); + int attr = cvt_attrs(ci->focus, p, ci->str2, &pair); int cursor_offset = ci->num; short x = ci->x, y = ci->y; const char *str = ci->str; -- 2.39.5