summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2013-11-12 10:40:11 +0100
committerhut <hut@lepus.uberspace.de>2013-11-12 10:40:11 +0100
commit792406e7fcb83d7caf17fbaccff11d4755fa9be9 (patch)
tree015a130d8e2a19edb3e27359e06cfc9b2be63961
parente94916a912655c055f1d45a92c6f178f7742873f (diff)
downloadranger-792406e7fcb83d7caf17fbaccff11d4755fa9be9.tar.gz
doc/tools/print_colors.py: more stable in unfriendly environments
-rwxr-xr-xdoc/tools/print_colors.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/doc/tools/print_colors.py b/doc/tools/print_colors.py
index ce040b33..b3eba749 100755
--- a/doc/tools/print_colors.py
+++ b/doc/tools/print_colors.py
@@ -10,10 +10,18 @@ from curses import *
 @wrapper
 def main(win):
     def print_all_colors(attr):
-        for c in range(0, curses.COLORS):
-            init_pair(c, c, -1)
-            win.addstr(str(c) + ' ', color_pair(c) | attr)
-    use_default_colors()
+        for c in range(-1, curses.COLORS):
+            try:
+                init_pair(c, c, 0)
+            except:
+                pass
+            else:
+                win.addstr(str(c) + ' ', color_pair(c) | attr)
+    start_color()
+    try:
+        use_default_colors()
+    except:
+        pass
     win.addstr("available colors: %d\n\n" % curses.COLORS)
     print_all_colors(0)
     win.addstr("\n\n")