From d51bf688bae4a682ff84aeb710d638f0987a742a Mon Sep 17 00:00:00 2001 From: bi4k8 Date: Sun, 5 Feb 2023 02:56:13 +0000 Subject: [PATCH] ncurses: call init_pair immediately before using colors this allows using color0, etc. in ncurses; the nearest available ncurses color will be used --- src/core.cc | 1 - src/display-ncurses.cc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.cc b/src/core.cc index 6ab0839c..ebf39573 100644 --- a/src/core.cc +++ b/src/core.cc @@ -761,7 +761,6 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state); obj->data.l = c.to_argb32(); set_current_text_color(c); - init_pair(c.to_ncurses(), c.to_ncurses(), COLOR_BLACK); } #endif /* BUILD_NCURSES */ obj->callbacks.print = &new_fg; diff --git a/src/display-ncurses.cc b/src/display-ncurses.cc index f82279a1..42516e25 100644 --- a/src/display-ncurses.cc +++ b/src/display-ncurses.cc @@ -81,6 +81,7 @@ bool display_output_ncurses::initialize() { bool display_output_ncurses::shutdown() { return false; } void display_output_ncurses::set_foreground_color(Colour c) { + init_pair(c.to_ncurses(), c.to_ncurses(), COLOR_BLACK); attron(COLOR_PAIR(c.to_ncurses())); }