summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-05-03 02:12:05 +0200
committermathieui <mathieui@mathieui.net>2014-05-03 02:12:05 +0200
commitea935ded091571ffec14fc020176c6a03f269efc (patch)
treec6d928e8f6fc451ee81c8b37d435a9e6542c5a60 /src
parentdb7fc6abb22884ee79d0de9df222046c9a7b4f2c (diff)
downloadpoezio-ea935ded091571ffec14fc020176c6a03f269efc.tar.gz
poezio-ea935ded091571ffec14fc020176c6a03f269efc.tar.bz2
poezio-ea935ded091571ffec14fc020176c6a03f269efc.tar.xz
poezio-ea935ded091571ffec14fc020176c6a03f269efc.zip
Highlight the newlines characters in the input instead of plain "|"s
Diffstat (limited to 'src')
-rw-r--r--src/windows.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/windows.py b/src/windows.py
index 5500059a..dd1e167d 100644
--- a/src/windows.py
+++ b/src/windows.py
@@ -62,9 +62,11 @@ class DummyWin(object):
def __bool__(self):
return False
-def find_first_format_char(text):
+def find_first_format_char(text, chars=None):
+ if chars is None:
+ chars = format_chars
pos = -1
- for char in format_chars:
+ for char in chars:
p = text.find(char)
if p == -1:
continue
@@ -1645,11 +1647,17 @@ class Input(Win):
(\x0E to \x19 instead of \x19 + attr). We do not use any }
char in this version
"""
+ chars = format_chars[:]
+ chars.append('\n')
if y is not None and x is not None:
self.move(y, x)
- format_char = find_first_format_char(text)
+ format_char = find_first_format_char(text, chars)
while format_char != -1:
- attr_char = self.text_attributes[format_chars.index(text[format_char])]
+ if text[format_char] == '\n':
+ attr_char = '|'
+ else:
+ attr_char = self.text_attributes[
+ format_chars.index(text[format_char])]
self.addstr(text[:format_char])
self.addstr(attr_char, curses.A_REVERSE)
text = text[format_char+1:]
@@ -1661,7 +1669,7 @@ class Input(Win):
self._win.attron(curses.A_BOLD)
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)
+ format_char = find_first_format_char(text, chars)
self.addstr(text)
def rewrite_text(self):
@@ -1674,7 +1682,7 @@ class Input(Win):
"""
self.adjust_view_pos()
with g_lock:
- text = self.text.replace('\n', '|')
+ text = self.text
self._win.erase()
if self.color:
self._win.attron(to_curses_attr(self.color))