Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] Fix "default" color in zsh/curses



Hello,
a curses documentation tells:

"The first function, use_default_colors() tells the curses library to
assign terminal default foreground/background colors to color number
-1. So init_pair(x,COLOR_RED,-1) will initialize pair x as red on
default background and init_pair(x,-1,COLOR_BLUE) will initialize pair
x as default foreground on blue."

curses.c correctly has:

#ifdef HAVE_USE_DEFAULT_COLORS
    {"default", -1},
#endif

However, following function uses -1 as error code:

static short
zcurses_color(const char *color)
{
    struct zcurses_namenumberpair *zc;

    for(zc=(struct zcurses_namenumberpair *)zcurses_colors;zc->name;zc++)
        if (!strcmp(color, zc->name)) {
            return (short)zc->number;
        }

    return (short)-1;
}

The line "return (short)zc->number;" will return -1 for "default"
color and this will result in error message. All the patch does is
making -2 to be error code, so that -1 can be passed on to
curses/ncurses.

Best regards,
Sebastian Gniazdowski

Attachment: default_zcurses_fix.patch
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author