summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2012-05-13 19:01:27 +0200
committermathieui <mathieui@mathieui.net>2012-05-13 19:01:27 +0200
commitecc40fdc5efc873f87ff10f313f3045dbdf70363 (patch)
tree5b97cb72799a6eb4c5dc8bc7af5c3c56d3b2daf8
parent4d7c01f8d0a544849c060cdc9df23cfc2fbc29ac (diff)
downloadpoezio-ecc40fdc5efc873f87ff10f313f3045dbdf70363.tar.gz
poezio-ecc40fdc5efc873f87ff10f313f3045dbdf70363.tar.bz2
poezio-ecc40fdc5efc873f87ff10f313f3045dbdf70363.tar.xz
poezio-ecc40fdc5efc873f87ff10f313f3045dbdf70363.zip
Catch a possible exception when trying to retrieve the rgb value in curses
Fixes #2354
-rw-r--r--src/xhtml.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/xhtml.py b/src/xhtml.py
index cf7a5fc0..38ec690c 100644
--- a/src/xhtml.py
+++ b/src/xhtml.py
@@ -206,7 +206,10 @@ def ncurses_color_to_html(color):
html color.
"""
if color <= 15:
- (r, g, b) = curses.color_content(color)
+ try:
+ (r, g, b) = curses.color_content(color)
+ except: # fallback in faulty terminals (e.g. xterm)
+ (r, g, b) = curses.color_content(color%8)
r = r / 1000 * 6 - 0.01
g = g / 1000 * 6 - 0.01
b = b / 1000 * 6 - 0.01