summaryrefslogtreecommitdiff
path: root/poezio/windows/muc.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
committermathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
commitd55cc5872503567775f0d7a7731d6f489bf2299b (patch)
tree725f9e7b8144d36054447b3c82edfb45bda8df1d /poezio/windows/muc.py
parent92496db823db34f7f7fb1ab31eaef093a707c3e8 (diff)
downloadpoezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.gz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.bz2
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.xz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.zip
yapf -ir
Diffstat (limited to 'poezio/windows/muc.py')
-rw-r--r--poezio/windows/muc.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py
index 553a2cfa..4251c279 100644
--- a/poezio/windows/muc.py
+++ b/poezio/windows/muc.py
@@ -13,12 +13,15 @@ from poezio import poopt
from poezio.config import config
from poezio.theming import to_curses_attr, get_theme
+
def userlist_to_cache(userlist):
result = []
for user in userlist:
- result.append((user.nick, user.status, user.chatstate, user.affiliation, user.role))
+ result.append((user.nick, user.status, user.chatstate,
+ user.affiliation, user.role))
return result
+
class UserList(Win):
def __init__(self):
Win.__init__(self)
@@ -26,23 +29,23 @@ class UserList(Win):
self.cache = []
def scroll_up(self):
- self.pos += self.height-1
+ self.pos += self.height - 1
return True
def scroll_down(self):
pos = self.pos
- self.pos -= self.height-1
+ self.pos -= self.height - 1
if self.pos < 0:
self.pos = 0
return self.pos != pos
def draw_plus(self, y):
- self.addstr(y, self.width-2, '++', to_curses_attr(get_theme().COLOR_MORE_INDICATOR))
-
+ self.addstr(y, self.width - 2, '++',
+ to_curses_attr(get_theme().COLOR_MORE_INDICATOR))
def refresh_if_changed(self, users):
old = self.cache
- new = userlist_to_cache(users[self.pos:self.pos+self.height])
+ new = userlist_to_cache(users[self.pos:self.pos + self.height])
if len(old) != len(new):
self.cache = new
self.refresh(users)
@@ -56,7 +59,7 @@ class UserList(Win):
def refresh(self, users):
log.debug('Refresh: %s', self.__class__.__name__)
if config.get('hide_user_list'):
- return # do not refresh if this win is hidden.
+ return # do not refresh if this win is hidden.
if len(users) < self.height:
self.pos = 0
elif self.pos >= len(users) - self.height and self.pos != 0:
@@ -69,12 +72,12 @@ class UserList(Win):
else:
y = 0
- for user in users[self.pos:self.pos+self.height]:
+ for user in users[self.pos:self.pos + self.height]:
self.draw_role_affiliation(y, user)
self.draw_status_chatstate(y, user)
self.addstr(y, 2,
- poopt.cut_by_columns(user.nick, self.width - 2),
- to_curses_attr(user.color))
+ poopt.cut_by_columns(user.nick, self.width - 2),
+ to_curses_attr(user.color))
if asc_sort:
y -= 1
else:
@@ -84,14 +87,14 @@ class UserList(Win):
# draw indicators of position in the list
if self.pos > 0:
if asc_sort:
- self.draw_plus(self.height-1)
+ self.draw_plus(self.height - 1)
else:
self.draw_plus(0)
if self.pos + self.height < len(users):
if asc_sort:
self.draw_plus(0)
else:
- self.draw_plus(self.height-1)
+ self.draw_plus(self.height - 1)
self._refresh()
def draw_role_affiliation(self, y, user):
@@ -119,6 +122,7 @@ class UserList(Win):
self._win.vline(0, 0, curses.ACS_VLINE, self.height)
self._win.attroff(separator)
+
class Topic(Win):
def __init__(self):
Win.__init__(self)
@@ -128,17 +132,16 @@ class Topic(Win):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
if topic:
- msg = topic[:self.width-1]
+ msg = topic[:self.width - 1]
else:
- msg = self._message[:self.width-1]
+ msg = self._message[:self.width - 1]
self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
_, x = self._win.getyx()
remaining_size = self.width - x
if remaining_size:
- self.addnstr(' '*remaining_size, remaining_size,
+ self.addnstr(' ' * remaining_size, remaining_size,
to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
self._refresh()
def set_message(self, message):
self._message = message
-