summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-11-12 16:46:28 +0000
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2017-11-12 16:46:28 +0000
commita278ee2a8c47da118d774ca8efdf3e1a29d2206f (patch)
tree365abd95402e17391096f92faa3e8a0451297b5c
parent9a89ba18e69d617fe01c3bde8761b80e90a726b5 (diff)
downloadpoezio-a278ee2a8c47da118d774ca8efdf3e1a29d2206f.tar.gz
poezio-a278ee2a8c47da118d774ca8efdf3e1a29d2206f.tar.bz2
poezio-a278ee2a8c47da118d774ca8efdf3e1a29d2206f.tar.xz
poezio-a278ee2a8c47da118d774ca8efdf3e1a29d2206f.zip
Replace italics with reversed when the curses module is too old to support it.
-rwxr-xr-xpoezio/theming.py4
-rw-r--r--poezio/windows/base_wins.py8
-rw-r--r--poezio/windows/inputs.py6
3 files changed, 9 insertions, 9 deletions
diff --git a/poezio/theming.py b/poezio/theming.py
index af1c7839..b5c9d516 100755
--- a/poezio/theming.py
+++ b/poezio/theming.py
@@ -466,8 +466,8 @@ def to_curses_attr(color_tuple):
curses_pair = curses_pair | curses.A_BOLD
if 'u' in additional_val:
curses_pair = curses_pair | curses.A_UNDERLINE
- if 'i' in additional_val and hasattr(curses, 'A_ITALIC'):
- curses_pair = curses_pair | curses.A_ITALIC
+ if 'i' in additional_val:
+ curses_pair = curses_pair | (curses.A_ITALIC if hasattr(curses, 'A_ITALIC') else curses.A_REVERSE)
if 'a' in additional_val:
curses_pair = curses_pair | curses.A_BLINK
return curses_pair
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py
index f3970ff5..8163dad5 100644
--- a/poezio/windows/base_wins.py
+++ b/poezio/windows/base_wins.py
@@ -101,7 +101,7 @@ class Win(object):
if y is not None and x is not None:
self.move(y, x)
next_attr_char = text.find(FORMAT_CHAR)
- has_italic = hasattr(curses, 'A_ITALIC')
+ attr_italic = curses.A_ITALIC if hasattr(curses, 'A_ITALIC') else curses.A_REVERSE
while next_attr_char != -1 and text:
if next_attr_char + 1 < len(text):
attr_char = text[next_attr_char + 1].lower()
@@ -115,8 +115,8 @@ class Win(object):
self._win.attron(curses.A_UNDERLINE)
elif attr_char == 'b':
self._win.attron(curses.A_BOLD)
- elif attr_char == 'i' and has_italic:
- self._win.attron(curses.A_ITALIC)
+ elif attr_char == 'i':
+ self._win.attron(attr_italic)
if (attr_char in string.digits
or attr_char == '-') and attr_char != '':
color_str = text[next_attr_char + 1:text.find(
@@ -132,7 +132,7 @@ class Win(object):
elif char == 'b':
self._win.attron(curses.A_BOLD)
elif char == 'i' and has_italic:
- self._win.attron(curses.A_ITALIC)
+ self._win.attron(attr_italic)
else:
# this will reset previous bold/uderline sequences if any was used
self._win.attroff(curses.A_UNDERLINE)
diff --git a/poezio/windows/inputs.py b/poezio/windows/inputs.py
index 0ccd179e..d2ea5fbb 100644
--- a/poezio/windows/inputs.py
+++ b/poezio/windows/inputs.py
@@ -485,7 +485,7 @@ class Input(Win):
if y is not None and x is not None:
self.move(y, x)
format_char = find_first_format_char(text, chars)
- has_italic = hasattr(curses, 'A_ITALIC')
+ attr_italic = curses.A_ITALIC if hasattr(curses, 'A_ITALIC') else curses.A_REVERSE
while format_char != -1:
if text[format_char] == '\n':
attr_char = '|'
@@ -501,8 +501,8 @@ class Input(Win):
self._win.attron(curses.A_UNDERLINE)
elif attr_char == 'b':
self._win.attron(curses.A_BOLD)
- elif attr_char == 'i' and has_italic:
- self._win.attron(curses.A_ITALIC)
+ elif attr_char == 'i':
+ self._win.attron(attr_italic)
elif attr_char in string.digits and attr_char != '':
self._win.attron(to_curses_attr((int(attr_char), -1)))
format_char = find_first_format_char(text, chars)