* [PATCH] Fix "default" color in zsh/curses
@ 2016-04-28 20:24 Sebastian Gniazdowski
0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2016-04-28 20:24 UTC (permalink / raw)
To: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
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 #2: default_zcurses_fix.patch --]
[-- Type: application/octet-stream, Size: 707 bytes --]
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index a04841a..7fff858 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -324,7 +324,7 @@ zcurses_color(const char *color)
return (short)zc->number;
}
- return (short)-1;
+ return (short)-2;
}
static Colorpairnode
@@ -353,10 +353,10 @@ zcurses_colorget(const char *nam, char *colorpair)
f = zcurses_color(cp);
b = zcurses_color(bg+1);
- if (f==-1 || b==-1) {
- if (f == -1)
+ if (f==-2 || b==-2) {
+ if (f == -2)
zwarnnam(nam, "foreground color `%s' not known", cp);
- if (b == -1)
+ if (b == -2)
zwarnnam(nam, "background color `%s' not known", bg+1);
*bg = '/';
zsfree(cp);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-28 20:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-28 20:24 [PATCH] Fix "default" color in zsh/curses Sebastian Gniazdowski
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).