diff options
author | mathieui <mathieui@mathieui.net> | 2011-11-07 21:08:30 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2011-11-07 21:08:30 +0100 |
commit | 0bfabab8344ec19f8f612fd27e7db7bee1dd9d1d (patch) | |
tree | 8e6eb05109fc7b76e66e983779be0ebe752a4488 /src/windows.py | |
parent | f4201bf7549e6c62d4475f6bc0a3e87130eb0b43 (diff) | |
parent | 305e5ed40d129843a774f14990cf6f46d8c6e1a8 (diff) | |
download | poezio-0bfabab8344ec19f8f612fd27e7db7bee1dd9d1d.tar.gz poezio-0bfabab8344ec19f8f612fd27e7db7bee1dd9d1d.tar.bz2 poezio-0bfabab8344ec19f8f612fd27e7db7bee1dd9d1d.tar.xz poezio-0bfabab8344ec19f8f612fd27e7db7bee1dd9d1d.zip |
Merge branch 'plugins' of https://git.louiz.org/poezio into plugins
Diffstat (limited to 'src/windows.py')
-rw-r--r-- | src/windows.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/windows.py b/src/windows.py index 42c9bfa0..1ff8f858 100644 --- a/src/windows.py +++ b/src/windows.py @@ -24,7 +24,7 @@ import curses import string from config import config -from threading import Lock +from threading import RLock from contact import Contact, Resource from roster import RosterGroup, roster @@ -46,7 +46,7 @@ allowed_color_digits = ('0', '1', '2', '3', '4', '5', '6', '7') # first is a bool telling if this is the first line of the message. Line = collections.namedtuple('Line', 'msg start_pos end_pos') -g_lock = Lock() +g_lock = RLock() LINES_NB_LIMIT = 4096 @@ -79,7 +79,8 @@ class Win(object): """ Override if something has to be done on resize """ - self._resize(height, width, y, x) + with g_lock: + self._resize(height, width, y, x) def _refresh(self): self._win.noutrefresh() @@ -137,7 +138,8 @@ class Win(object): self._win.attron(curses.A_BOLD) if attr_char in string.digits and attr_char != '': color_str = text[next_attr_char+1:text.find('}', next_attr_char)] - self._win.attron(to_curses_attr((int(color_str), -1))) + if color_str: + self._win.attron(to_curses_attr((int(color_str), -1))) text = text[next_attr_char+len(color_str)+2:] else: text = text[next_attr_char+2:] @@ -255,10 +257,11 @@ class UserList(Win): self._refresh() def resize(self, height, width, y, x): - self._resize(height, width, y, x) - self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) - self._win.vline(0, 0, curses.ACS_VLINE, self.height) - self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) + with g_lock: + self._resize(height, width, y, x) + self._win.attron(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) + self._win.vline(0, 0, curses.ACS_VLINE, self.height) + self._win.attroff(to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)) class Topic(Win): def __init__(self): @@ -674,9 +677,10 @@ class TextWin(Win): self.addstr(' ') def resize(self, height, width, y, x, room=None): - self._resize(height, width, y, x) - if room: - self.rebuild_everything(room) + with g_lock: + self._resize(height, width, y, x) + if room: + self.rebuild_everything(room) def rebuild_everything(self, room): self.built_lines = [] |