1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-05-28 05:00:45 +00:00

ncurses color fixes (#1482)

* specials: avoid duplicating color specials when both ncurses and a graphical output are enabled

* ncurses: fix black

we previously used the ncurses color as the id for its color pair, but this scheme needs to be shifted by one to avoid using the invalid 0 color-pair id for black (color id 0)

---------

Co-authored-by: bi4k8 <bi4k8@github>
This commit is contained in:
bi4k8 2023-03-31 16:52:59 +00:00 committed by GitHub
parent 4a40eef51a
commit 3b1c9a7cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -748,20 +748,18 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
obj->callbacks.graphval = &diskiographval_write;
#endif /* BUILD_GUI */
END OBJ(color, nullptr)
if (false
#ifdef BUILD_GUI
if (out_to_gui(*state)) {
Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state);
obj->data.l = c.to_argb32();
set_current_text_color(c);
}
|| out_to_gui(*state)
#endif /* BUILD_GUI */
#ifdef BUILD_NCURSES
if (out_to_ncurses.get(*state)) {
|| out_to_ncurses.get(*state)
#endif /* BUILD_NCURSES */
) {
Colour c = arg != nullptr ? parse_color(arg) : default_color.get(*state);
obj->data.l = c.to_argb32();
set_current_text_color(c);
}
#endif /* BUILD_NCURSES */
obj->callbacks.print = &new_fg;
#ifdef BUILD_GUI
END OBJ(color0, nullptr) Colour c = color[0].get(*state);

View File

@ -128,8 +128,8 @@ bool display_output_ncurses::shutdown() { return false; }
void display_output_ncurses::set_foreground_color(Colour c) {
int nccolor = to_ncurses(c);
init_pair(nccolor, nccolor, COLOR_BLACK);
attron(COLOR_PAIR(nccolor));
init_pair(nccolor+1, nccolor, COLOR_BLACK);
attron(COLOR_PAIR(nccolor+1));
}
void display_output_ncurses::begin_draw_text() {

View File

@ -666,14 +666,16 @@ void new_stippled_hr(struct text_object *obj, char *p,
#endif /* BUILD_GUI */
void new_fg(struct text_object *obj, char *p, unsigned int p_max_size) {
if (false
#ifdef BUILD_GUI
if (display_output() && display_output()->graphical()) {
new_special(p, FG)->arg = obj->data.l;
}
|| (display_output() && display_output()->graphical())
#endif /* BUILD_GUI */
#ifdef BUILD_NCURSES
if (out_to_ncurses.get(*state)) { new_special(p, FG)->arg = obj->data.l; }
|| out_to_ncurses.get(*state)
#endif /* BUILD_NCURSES */
) {
new_special(p, FG)->arg = obj->data.l;
}
UNUSED(obj);
UNUSED(p);
UNUSED(p_max_size);