about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSebastian Gniazdowski <sgniazdowski@gmail.com>2016-04-29 13:34:19 +0200
committerPeter Stephenson <pws@zsh.org>2016-04-29 14:01:06 +0100
commitfea013b8e8cc3b2d8e7ca59c1f32b27cdf376155 (patch)
tree6c5c031a8652251a6fbbb321fc0cf7d38aec91ac
parent7fc0c2d57db1c0ee71f66ff73ab5655294a245c0 (diff)
downloadzsh-fea013b8e8cc3b2d8e7ca59c1f32b27cdf376155.tar.gz
zsh-fea013b8e8cc3b2d8e7ca59c1f32b27cdf376155.tar.xz
zsh-fea013b8e8cc3b2d8e7ca59c1f32b27cdf376155.zip
38356: allow integers as curses colours
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/mod_curses.yo6
-rw-r--r--Src/Modules/curses.c16
3 files changed, 23 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9577b14d3..29d2c386b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2016-04-29  Peter Stephenson  <p.stephenson@samsung.com>
 
-	* Sebastian: 39354: Src/Modules/curses.c: alter internal return
+	* Sebastian: 38356: Src/Modules/curses.c, Doc/Zsh/mod_curses.yo:
+	allow integers as colours in curses.
+
+	* Sebastian: 38354: Src/Modules/curses.c: alter internal return
 	code so as not to mask curses error code.
 
 2016-04-26  Barton E. Schaefer  <schaefer@zsh.org>
diff --git a/Doc/Zsh/mod_curses.yo b/Doc/Zsh/mod_curses.yo
index 8104572a6..72dc4094a 100644
--- a/Doc/Zsh/mod_curses.yo
+++ b/Doc/Zsh/mod_curses.yo
@@ -111,7 +111,11 @@ Each var(fg_col)tt(/)var(bg_col) attribute (to be read as
 for character output.  The color tt(default) is sometimes available
 (in particular if the library is ncurses), specifying the foreground
 or background color with which the terminal started.  The color pair
-tt(default/default) is always available.
+tt(default/default) is always available. To use more than the 8 named
+colors (red, green, etc.) construct the var(fg_col)tt(/)var(bg_col)
+pairs where var(fg_col) and var(bg_col) are decimal integers, e.g
+tt(128/200).  The maximum color value is 254 if the terminal supports
+256 colors.
 
 tt(bg) overrides the color and other attributes of all characters in the
 window.  Its usual use is to set the background initially, but it will
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index 7fff858f4..63c6748f5 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -350,8 +350,20 @@ zcurses_colorget(const char *nam, char *colorpair)
 	}
 
 	*bg = '\0';        
-	f = zcurses_color(cp);
-	b = zcurses_color(bg+1);
+
+        // cp/bg can be {number}/{number} or {name}/{name}
+
+        if( cp[0] >= '0' && cp[0] <= '9' ) {
+            f = atoi(cp);
+        } else {
+            f = zcurses_color(cp);
+        }
+
+        if( (bg+1)[0] >= '0' && (bg+1)[0] <= '9' ) {
+            b = atoi(bg+1);
+        } else {
+            b = zcurses_color(bg+1);
+        }
 
 	if (f==-2 || b==-2) {
 	    if (f == -2)