summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/core/handlers.py64
-rw-r--r--poezio/tabs/muctab.py79
-rw-r--r--poezio/tabs/privatetab.py29
-rw-r--r--poezio/windows/bookmark_forms.py25
-rw-r--r--poezio/windows/data_forms.py25
-rw-r--r--poezio/windows/info_bar.py21
-rw-r--r--poezio/windows/info_wins.py77
-rw-r--r--poezio/windows/list.py14
-rw-r--r--poezio/windows/muc.py16
-rw-r--r--poezio/windows/roster_win.py77
-rw-r--r--poezio/windows/text_win.py40
11 files changed, 241 insertions, 226 deletions
diff --git a/poezio/core/handlers.py b/poezio/core/handlers.py
index 0a6e7e50..b55d816b 100644
--- a/poezio/core/handlers.py
+++ b/poezio/core/handlers.py
@@ -1270,71 +1270,40 @@ class HandlerCore:
semi_anon = '173' in status_codes
full_anon = '174' in status_codes
modif = False
+ info_col = {'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)}
if show_unavailable or hide_unavailable or non_priv or logging_off\
or non_anon or semi_anon or full_anon:
tab.add_message(
- '\x19%(info_col)s}Info: A configuration change not privacy-related occurred.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: A configuration change not privacy-related occurred.' % info_col
typ=2)
modif = True
if show_unavailable:
tab.add_message(
- '\x19%(info_col)s}Info: The unavailable members are now shown.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The unavailable members are now shown.' % info_col
typ=2)
elif hide_unavailable:
tab.add_message(
- '\x19%(info_col)s}Info: The unavailable members are now hidden.'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The unavailable members are now hidden.' % info_col
typ=2)
if non_anon:
tab.add_message(
- '\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x191}Warning:\x19%(info_col)s} The room is now not anonymous. (public JID)' % info_col
typ=2)
elif semi_anon:
tab.add_message(
- '\x19%(info_col)s}Info: The room is now semi-anonymous. (moderators-only JID)'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The room is now semi-anonymous. (moderators-only JID)' % info_col
typ=2)
elif full_anon:
tab.add_message(
- '\x19%(info_col)s}Info: The room is now fully anonymous.' %
- {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: The room is now fully anonymous.' % info_col
typ=2)
if logging_on:
tab.add_message(
- '\x191}Warning: \x19%(info_col)s}This room is publicly logged'
- % {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x191}Warning: \x19%(info_col)s}This room is publicly logged' % info_col
typ=2)
elif logging_off:
tab.add_message(
- '\x19%(info_col)s}Info: This room is not logged anymore.' %
- {
- 'info_col': dump_tuple(
- get_theme().COLOR_INFORMATION_TEXT)
- },
+ '\x19%(info_col)s}Info: This room is not logged anymore.' % info_col
typ=2)
if modif:
self.core.refresh_window()
@@ -1352,9 +1321,10 @@ class HandlerCore:
if subject != tab.topic:
# Do not display the message if the subject did not change or if we
# receive an empty topic when joining the room.
+ theme = get_theme()
fmt = {
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
- 'text_col': dump_tuple(get_theme().COLOR_NORMAL_TEXT),
+ 'info_col': dump_tuple(theme.COLOR_INFORMATION_TEXT),
+ 'text_col': dump_tuple(theme.COLOR_NORMAL_TEXT),
'subject': subject,
'user': '',
}
@@ -1448,17 +1418,18 @@ class HandlerCore:
xhtml_text, force=True).rstrip('\x19o').strip()
else:
poezio_colored = str(stanza)
+ char = get_theme().CHAR_XML_OUT
self.core.add_message_to_text_buffer(
self.core.xml_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_OUT)
+ nickname=char)
try:
if self.core.xml_tab.match_stanza(
ElementBase(ET.fromstring(stanza))):
self.core.add_message_to_text_buffer(
self.core.xml_tab.filtered_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_OUT)
+ nickname=char)
except:
log.debug('', exc_info=True)
@@ -1477,16 +1448,17 @@ class HandlerCore:
xhtml_text, force=True).rstrip('\x19o').strip()
else:
poezio_colored = str(stanza)
+ char = get_theme().CHAR_XML_IN
self.core.add_message_to_text_buffer(
self.core.xml_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_IN)
+ nickname=char)
try:
if self.core.xml_tab.match_stanza(stanza):
self.core.add_message_to_text_buffer(
self.core.xml_tab.filtered_buffer,
poezio_colored,
- nickname=get_theme().CHAR_XML_IN)
+ nickname=char)
except:
log.debug('', exc_info=True)
if isinstance(self.core.tabs.current_tab, tabs.XMLTab):
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index d533f817..16f6d4cf 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -157,13 +157,14 @@ class MucTab(ChatTab):
def leave_room(self, message: str):
if self.joined:
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- char_quit = get_theme().CHAR_QUIT
- spec_col = dump_tuple(get_theme().COLOR_QUIT_CHAR)
+ theme = get_theme()
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ char_quit = theme.CHAR_QUIT
+ spec_col = dump_tuple(theme.COLOR_QUIT_CHAR)
if config.get_by_tabname('display_user_color_in_join_part',
self.general_jid):
- color = dump_tuple(get_theme().COLOR_OWN_NICK)
+ color = dump_tuple(theme.COLOR_OWN_NICK)
else:
color = "3"
@@ -301,8 +302,9 @@ class MucTab(ChatTab):
"""
Print the current topic
"""
- info_text = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- norm_text = dump_tuple(get_theme().COLOR_NORMAL_TEXT)
+ theme = get_theme()
+ info_text = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ norm_text = dump_tuple(theme.COLOR_NORMAL_TEXT)
if self.topic_from:
user = self.get_user_by_name(self.topic_from)
if user:
@@ -521,7 +523,8 @@ class MucTab(ChatTab):
if (self.core.tabs.current_tab is self
and self.core.status.show not in ('xa', 'away')):
self.send_chat_state('active')
- new_user.color = get_theme().COLOR_OWN_NICK
+ theme = get_theme()
+ new_user.color = theme.COLOR_OWN_NICK
if config.get_by_tabname('display_user_color_in_join_part',
self.general_jid):
@@ -529,14 +532,14 @@ class MucTab(ChatTab):
else:
color = "3"
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- warn_col = dump_tuple(get_theme().COLOR_WARNING_TEXT)
- spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR)
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ warn_col = dump_tuple(theme.COLOR_WARNING_TEXT)
+ spec_col = dump_tuple(theme.COLOR_JOIN_CHAR)
enable_message = ('\x19%(color_spec)s}%(spec)s\x19%(info_col)s} You '
'(\x19%(nick_col)s}%(nick)s\x19%(info_col)s}) joined'
' the room') % {
'nick': from_nick,
- 'spec': get_theme().CHAR_JOIN,
+ 'spec': theme.CHAR_JOIN,
'color_spec': spec_col,
'nick_col': color,
'info_col': info_col,
@@ -651,9 +654,10 @@ class MucTab(ChatTab):
color = dump_tuple(user.color)
else:
color = 3
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- spec_col = dump_tuple(get_theme().COLOR_JOIN_CHAR)
- char_join = get_theme().CHAR_JOIN
+ theme = get_theme()
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ spec_col = dump_tuple(theme.COLOR_JOIN_CHAR)
+ char_join = theme.CHAR_JOIN
if not jid.full:
msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}%(nick)s'
'\x19%(info_col)s} joined the room') % {
@@ -672,7 +676,7 @@ class MucTab(ChatTab):
'color': color,
'jid': jid.full,
'info_col': info_col,
- 'jid_color': dump_tuple(get_theme().COLOR_MUC_JID),
+ 'jid_color': dump_tuple(theme.COLOR_MUC_JID),
'color_spec': spec_col,
}
self.add_message(msg, typ=2)
@@ -731,8 +735,9 @@ class MucTab(ChatTab):
else:
by = None
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- char_kick = get_theme().CHAR_KICK
+ theme = get_theme()
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ char_kick = theme.CHAR_KICK
if from_nick == self.own_nick: # we are banned
if by:
@@ -807,8 +812,9 @@ class MucTab(ChatTab):
reason = presence.xml.find('{%s}x/{%s}item/{%s}reason' %
(NS_MUC_USER, NS_MUC_USER, NS_MUC_USER))
by = None
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- char_kick = get_theme().CHAR_KICK
+ theme = get_theme()
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ char_kick = theme.CHAR_KICK
if actor_elem is not None:
by = actor_elem.get('nick') or actor_elem.get('jid')
if from_nick == self.own_nick: # we are kicked
@@ -901,8 +907,9 @@ class MucTab(ChatTab):
color = dump_tuple(user.color)
else:
color = 3
- info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
- spec_col = dump_tuple(get_theme().COLOR_QUIT_CHAR)
+ theme = get_theme()
+ info_col = dump_tuple(theme.COLOR_INFORMATION_TEXT)
+ spec_col = dump_tuple(theme.COLOR_QUIT_CHAR)
error_leave_txt = ''
if server_initiated:
@@ -914,18 +921,18 @@ class MucTab(ChatTab):
'room%(error_leave)s') % {
'nick': from_nick,
'color': color,
- 'spec': get_theme().CHAR_QUIT,
+ 'spec': theme.CHAR_QUIT,
'info_col': info_col,
'color_spec': spec_col,
'error_leave': error_leave_txt,
}
else:
- jid_col = dump_tuple(get_theme().COLOR_MUC_JID)
+ jid_col = dump_tuple(theme.COLOR_MUC_JID)
leave_msg = ('\x19%(color_spec)s}%(spec)s \x19%(color)s}'
'%(nick)s\x19%(info_col)s} (\x19%(jid_col)s}'
'%(jid)s\x19%(info_col)s}) has left the '
'room%(error_leave)s') % {
- 'spec': get_theme().CHAR_QUIT,
+ 'spec': theme.CHAR_QUIT,
'nick': from_nick,
'color': color,
'jid': jid.full,
@@ -952,16 +959,17 @@ class MucTab(ChatTab):
color = dump_tuple(user.color)
else:
color = 3
+ info_col = dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
if from_nick == self.own_nick:
msg = '\x19%(color)s}You\x19%(info_col)s} changed: ' % {
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
+ 'info_col': info_col),
'color': color
}
else:
msg = '\x19%(color)s}%(nick)s\x19%(info_col)s} changed: ' % {
'nick': from_nick,
'color': color,
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ 'info_col': info_col)
}
if affiliation != user.affiliation:
msg += 'affiliation: %s, ' % affiliation
@@ -1496,23 +1504,24 @@ class MucTab(ChatTab):
if not self.joined:
return
+ theme = get_theme()
aff = {
- 'owner': get_theme().CHAR_AFFILIATION_OWNER,
- 'admin': get_theme().CHAR_AFFILIATION_ADMIN,
- 'member': get_theme().CHAR_AFFILIATION_MEMBER,
- 'none': get_theme().CHAR_AFFILIATION_NONE,
+ 'owner': theme.CHAR_AFFILIATION_OWNER,
+ 'admin': theme.CHAR_AFFILIATION_ADMIN,
+ 'member': theme.CHAR_AFFILIATION_MEMBER,
+ 'none': theme.CHAR_AFFILIATION_NONE,
}
colors = {}
- colors["visitor"] = dump_tuple(get_theme().COLOR_USER_VISITOR)
- colors["moderator"] = dump_tuple(get_theme().COLOR_USER_MODERATOR)
- colors["participant"] = dump_tuple(get_theme().COLOR_USER_PARTICIPANT)
- color_other = dump_tuple(get_theme().COLOR_USER_NONE)
+ colors["visitor"] = dump_tuple(theme.COLOR_USER_VISITOR)
+ colors["moderator"] = dump_tuple(theme.COLOR_USER_MODERATOR)
+ colors["participant"] = dump_tuple(theme.COLOR_USER_PARTICIPANT)
+ color_other = dump_tuple(theme.COLOR_USER_NONE)
buff = ['Users: %s \n' % len(self.users)]
for user in self.users:
affiliation = aff.get(user.affiliation,
- get_theme().CHAR_AFFILIATION_NONE)
+ theme.CHAR_AFFILIATION_NONE)
color = colors.get(user.role, color_other)
buff.append(
'\x19%s}%s\x19o\x19%s}%s\x19o' %
diff --git a/poezio/tabs/privatetab.py b/poezio/tabs/privatetab.py
index 8f5f4d6f..4811f14e 100644
--- a/poezio/tabs/privatetab.py
+++ b/poezio/tabs/privatetab.py
@@ -345,21 +345,22 @@ class PrivateTab(OneToOneTab):
The user left the associated MUC
"""
self.deactivate()
+ theme = get_theme()
if config.get_by_tabname('display_user_color_in_join_part',
self.general_jid):
color = dump_tuple(user.color)
else:
- color = dump_tuple(get_theme().COLOR_REMOTE_USER)
+ color = dump_tuple(theme.COLOR_REMOTE_USER)
if not status_message:
self.add_message(
'\x19%(quit_col)s}%(spec)s \x19%(nick_col)s}'
'%(nick)s\x19%(info_col)s} has left the room' % {
'nick': user.nick,
- 'spec': get_theme().CHAR_QUIT,
+ 'spec': theme.CHAR_QUIT,
'nick_col': color,
- 'quit_col': dump_tuple(get_theme().COLOR_QUIT_CHAR),
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ 'quit_col': dump_tuple(theme.COLOR_QUIT_CHAR),
+ 'info_col': dump_tuple(theme.COLOR_INFORMATION_TEXT)
},
typ=2)
else:
@@ -369,10 +370,10 @@ class PrivateTab(OneToOneTab):
' (%(status)s)' % {
'status': status_message,
'nick': user.nick,
- 'spec': get_theme().CHAR_QUIT,
+ 'spec': theme.CHAR_QUIT,
'nick_col': color,
- 'quit_col': dump_tuple(get_theme().COLOR_QUIT_CHAR),
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ 'quit_col': dump_tuple(theme.COLOR_QUIT_CHAR),
+ 'info_col': dump_tuple(theme.COLOR_INFORMATION_TEXT)
},
typ=2)
return self.core.tabs.current_tab is self
@@ -385,7 +386,8 @@ class PrivateTab(OneToOneTab):
self.activate()
self.check_features()
tab = self.parent_muc
- color = dump_tuple(get_theme().COLOR_REMOTE_USER)
+ theme = get_theme()
+ color = dump_tuple(theme.COLOR_REMOTE_USER)
if tab and config.get_by_tabname('display_user_color_in_join_part',
self.general_jid):
user = tab.get_user_by_name(nick)
@@ -396,9 +398,9 @@ class PrivateTab(OneToOneTab):
'%(info_col)s} joined the room' % {
'nick': nick,
'color': color,
- 'spec': get_theme().CHAR_JOIN,
- 'join_col': dump_tuple(get_theme().COLOR_JOIN_CHAR),
- 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
+ 'spec': theme.CHAR_JOIN,
+ 'join_col': dump_tuple(theme.COLOR_JOIN_CHAR),
+ 'info_col': dump_tuple(theme.COLOR_INFORMATION_TEXT)
},
typ=2)
return self.core.tabs.current_tab is self
@@ -417,12 +419,13 @@ class PrivateTab(OneToOneTab):
return [(3, safeJID(self.name).resource), (4, self.name)]
def add_error(self, error_message):
- error = '\x19%s}%s\x19o' % (dump_tuple(get_theme().COLOR_CHAR_NACK),
+ theme = get_theme()
+ error = '\x19%s}%s\x19o' % (dump_tuple(theme.COLOR_CHAR_NACK),
error_message)
self.add_message(
error,
highlight=True,
nickname='Error',
- nick_color=get_theme().COLOR_ERROR_MSG,
+ nick_color=theme.COLOR_ERROR_MSG,
typ=2)
self.core.refresh_window()
diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py
index 2940ef04..8b9150d6 100644
--- a/poezio/windows/bookmark_forms.py
+++ b/poezio/windows/bookmark_forms.py
@@ -245,9 +245,10 @@ class BookmarksWin(Win):
return
if self.current_input == 0:
return
+ theme = get_theme()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.current_input -= 1
# Adjust the scroll position if the current_input would be outside
# of the visible area
@@ -256,20 +257,21 @@ class BookmarksWin(Win):
self.refresh()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
def go_to_next_horizontal_input(self) -> None:
if not self.lines:
return
+ theme = get_theme()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.current_horizontal_input += 1
if self.current_horizontal_input > 3:
self.current_horizontal_input = 0
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
def go_to_next_page(self) -> bool:
if not self.lines:
@@ -278,9 +280,10 @@ class BookmarksWin(Win):
if self.current_input == len(self.lines) - 1:
return False
+ theme = get_theme()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
inc = min(self.height, len(self.lines) - self.current_input - 1)
if self.current_input + inc - self.scroll_pos > self.height - 1:
@@ -291,7 +294,7 @@ class BookmarksWin(Win):
self.current_input += inc
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
return True
def go_to_previous_page(self) -> bool:
@@ -301,9 +304,10 @@ class BookmarksWin(Win):
if self.current_input == 0:
return False
+ theme = get_theme()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
dec = min(self.height, self.current_input)
self.current_input -= dec
@@ -314,7 +318,7 @@ class BookmarksWin(Win):
self.refresh()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
return True
def go_to_previous_horizontal_input(self) -> None:
@@ -322,13 +326,14 @@ class BookmarksWin(Win):
return
if self.current_horizontal_input == 0:
return
+ theme = get_theme()
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.current_horizontal_input -= 1
self.lines[self.current_input][
self.current_horizontal_input].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
def on_input(self, key: str) -> None:
if not self.lines:
diff --git a/poezio/windows/data_forms.py b/poezio/windows/data_forms.py
index b8dd8531..3ec44b97 100644
--- a/poezio/windows/data_forms.py
+++ b/poezio/windows/data_forms.py
@@ -438,10 +438,11 @@ class FormWin:
return
if self.current_input == len(self.inputs) - 1:
return
+ theme = get_theme()
self.inputs[self.current_input]['input'].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.inputs[self.current_input]['label'].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.current_input += 1
jump = 0
while self.current_input + jump != len(
@@ -460,19 +461,20 @@ class FormWin:
self.scroll_pos += 1
self.refresh()
self.inputs[self.current_input]['input'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
self.inputs[self.current_input]['label'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
def go_to_previous_input(self):
if not self.inputs:
return
if self.current_input == 0:
return
+ theme = get_theme()
self.inputs[self.current_input]['input'].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.inputs[self.current_input]['label'].set_color(
- get_theme().COLOR_NORMAL_TEXT)
+ theme.COLOR_NORMAL_TEXT)
self.current_input -= 1
jump = 0
while self.current_input - jump > 0 and self.inputs[self.current_input
@@ -489,9 +491,9 @@ class FormWin:
self.refresh()
self.current_input -= jump
self.inputs[self.current_input]['input'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
self.inputs[self.current_input]['label'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ theme.COLOR_SELECTED_ROW)
def on_input(self, key, raw=False):
if not self.inputs:
@@ -521,11 +523,10 @@ class FormWin:
inp['input'].refresh()
inp['label'].refresh()
if self.inputs and self.current_input < self.height - 1:
- self.inputs[self.current_input]['input'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ color = get_theme().COLOR_SELECTED_ROW
+ self.inputs[self.current_input]['input'].set_color(color)
self.inputs[self.current_input]['input'].refresh()
- self.inputs[self.current_input]['label'].set_color(
- get_theme().COLOR_SELECTED_ROW)
+ self.inputs[self.current_input]['label'].set_color(color)
self.inputs[self.current_input]['label'].refresh()
def refresh_current_input(self):
diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py
index 15821c10..ac900103 100644
--- a/poezio/windows/info_bar.py
+++ b/poezio/windows/info_bar.py
@@ -25,8 +25,9 @@ class GlobalInfoBar(Win):
def refresh(self) -> None:
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
+ theme = get_theme()
self.addstr(0, 0, "[",
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
show_names = config.get('show_tab_names')
show_nums = config.get('show_tab_numbers')
@@ -37,7 +38,7 @@ class GlobalInfoBar(Win):
if not tab:
continue
color = tab.color
- if not show_inactive and color is get_theme().COLOR_TAB_NORMAL:
+ if not show_inactive and color is theme.COLOR_TAB_NORMAL:
continue
try:
if show_nums or not show_names:
@@ -51,16 +52,16 @@ class GlobalInfoBar(Win):
else:
self.addstr("%s" % tab.name, to_curses_attr(color))
self.addstr("|",
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
except: # end of line
break
(y, x) = self._win.getyx()
self.addstr(y, x - 1, '] ',
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
(y, x) = self._win.getyx()
remaining_size = self.width - x
self.addnstr(' ' * remaining_size, remaining_size,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
self._refresh()
@@ -76,17 +77,17 @@ class VerticalGlobalInfoBar(Win):
height, width = self._win.getmaxyx()
self._win.erase()
sorted_tabs = [tab for tab in self.core.tabs if tab]
+ theme = get_theme()
if not config.get('show_inactive_tabs'):
sorted_tabs = [
tab for tab in sorted_tabs
- if tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL
+ if tab.vertical_color != theme.COLOR_VERTICAL_TAB_NORMAL
]
nb_tabs = len(sorted_tabs)
use_nicks = config.get('use_tab_nicks')
if nb_tabs >= height:
for y, tab in enumerate(sorted_tabs):
- if tab.vertical_color == get_theme(
- ).COLOR_VERTICAL_TAB_CURRENT:
+ if tab.vertical_color == theme.COLOR_VERTICAL_TAB_CURRENT:
pos = y
break
# center the current tab as much as possible
@@ -102,14 +103,14 @@ class VerticalGlobalInfoBar(Win):
if asc_sort:
y = height - y - 1
self.addstr(y, 0, "%2d" % tab.nb,
- to_curses_attr(get_theme().COLOR_VERTICAL_TAB_NUMBER))
+ to_curses_attr(theme.COLOR_VERTICAL_TAB_NUMBER))
self.addstr('.')
if use_nicks:
self.addnstr("%s" % tab.get_nick(), width - 4,
to_curses_attr(color))
else:
self.addnstr("%s" % tab.name, width - 4, to_curses_attr(color))
- separator = to_curses_attr(get_theme().COLOR_VERTICAL_SEPARATOR)
+ separator = to_curses_attr(theme.COLOR_VERTICAL_SEPARATOR)
self._win.attron(separator)
self._win.vline(0, width - 1, curses.ACS_VLINE, height)
self._win.attroff(separator)
diff --git a/poezio/windows/info_wins.py b/poezio/windows/info_wins.py
index abc0a401..d07cbe20 100644
--- a/poezio/windows/info_wins.py
+++ b/poezio/windows/info_wins.py
@@ -94,9 +94,10 @@ class PrivateInfoWin(InfoWin):
def write_room_name(self, name):
jid = safeJID(name)
room_name, nick = jid.bare, jid.resource
- self.addstr(nick, to_curses_attr(get_theme().COLOR_PRIVATE_NAME))
+ theme = get_theme()
+ self.addstr(nick, to_curses_attr(theme.COLOR_PRIVATE_NAME))
txt = ' from room %s' % room_name
- self.addstr(txt, to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr(txt, to_curses_attr(theme.COLOR_INFORMATION_BAR))
def write_chatstate(self, state):
if state:
@@ -119,15 +120,16 @@ class MucListInfoWin(InfoWin):
def refresh(self, name=None, window=None):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
+ theme = get_theme()
if name:
self.addstr(name,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
else:
self.addstr(self.message,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
if window:
self.print_scroll_position(window)
- self.finish_line(get_theme().COLOR_INFORMATION_BAR)
+ self.finish_line(theme.COLOR_INFORMATION_BAR)
self._refresh()
@@ -176,9 +178,9 @@ class ConversationInfoWin(InfoWin):
Write all information added by plugins by getting the
value returned by the callbacks.
"""
+ color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR)
for plugin in information.values():
- self.addstr(plugin(jid),
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr(plugin(jid), color)
def write_resource_information(self, resource):
"""
@@ -188,38 +190,40 @@ class ConversationInfoWin(InfoWin):
presence = "unavailable"
else:
presence = resource.presence
- color = get_theme().color_show(presence)
+ theme = get_theme()
+ color = theme.color_show(presence)
if not presence:
- presence = get_theme().CHAR_STATUS
- self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ presence = theme.CHAR_STATUS
+ self.addstr('[', to_curses_attr(theme.COLOR_INFORMATION_BAR))
self.addstr(presence, to_curses_attr(color))
if resource and resource.status:
shortened = resource.status[:20] + (resource.status[:20] and '…')
self.addstr(' %s' % shortened,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
+ self.addstr(']', to_curses_attr(theme.COLOR_INFORMATION_BAR))
def write_contact_information(self, contact):
"""
Write the information about the contact
"""
+ color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
if not contact:
- self.addstr("(contact not in roster)",
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr("(contact not in roster)", color)
return
display_name = contact.name
if display_name:
- self.addstr('%s ' % (display_name),
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr('%s ' % (display_name), color)
def write_contact_jid(self, jid):
"""
Just write the jid that we are talking to
"""
- self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ theme = get_theme()
+ color = to_curses_attr(theme.COLOR_INFORMATION_BAR))
+ self.addstr('[', color)
self.addstr(jid.full,
- to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
- self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_CONVERSATION_NAME))
+ self.addstr('] ', color)
def write_chatstate(self, state):
if state:
@@ -236,14 +240,16 @@ class DynamicConversationInfoWin(ConversationInfoWin):
"""
log.debug("write_contact_jid DynamicConversationInfoWin, jid: %s",
jid.resource)
- self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ theme = get_theme()
+ color = to_curses_attr(theme.COLOR_INFORMATION_BAR))
+ self.addstr('[', color)
self.addstr(jid.bare,
- to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
+ to_curses_attr(theme.COLOR_CONVERSATION_NAME))
if jid.resource:
self.addstr(
"/%s" % (jid.resource, ),
- to_curses_attr(get_theme().COLOR_CONVERSATION_RESOURCE))
- self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_CONVERSATION_RESOURCE))
+ self.addstr('] ', color)
class MucInfoWin(InfoWin):
@@ -277,22 +283,26 @@ class MucInfoWin(InfoWin):
Write all information added by plugins by getting the
value returned by the callbacks.
"""
+ color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR)
for plugin in information.values():
- self.addstr(plugin(jid),
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr(plugin(jid), color)
def write_room_name(self, room):
- self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ theme = get_theme()
+ color = to_curses_attr(theme.COLOR_INFORMATION_BAR)
+ self.addstr('[', color)
self.addstr(room.name,
- to_curses_attr(get_theme().COLOR_GROUPCHAT_NAME))
- self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_GROUPCHAT_NAME))
+ self.addstr(']', color)
def write_participants_number(self, room):
- self.addstr('{', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ theme = get_theme()
+ color = to_curses_attr(theme.COLOR_INFORMATION_BAR)
+ self.addstr('{', color)
self.addstr(
str(len(room.users)),
- to_curses_attr(get_theme().COLOR_GROUPCHAT_NAME))
- self.addstr('} ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_GROUPCHAT_NAME))
+ self.addstr('} ', color)
def write_disconnected(self, room):
"""
@@ -386,10 +396,11 @@ class ConfirmStatusWin(Win):
def refresh(self):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
+ theme = get_theme()
if self.critical:
- color = get_theme().COLOR_WARNING_PROMPT
+ color = theme.COLOR_WARNING_PROMPT
else:
- color = get_theme().COLOR_INFORMATION_BAR
+ color = theme.COLOR_INFORMATION_BAR
c_color = to_curses_attr(color)
self.addstr(self.text, c_color)
self.finish_line(color)
diff --git a/poezio/windows/list.py b/poezio/windows/list.py
index f03dcf6a..350255c6 100644
--- a/poezio/windows/list.py
+++ b/poezio/windows/list.py
@@ -94,6 +94,7 @@ class ListWin(Win):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
lines = self.lines[self._starting_pos:self._starting_pos + self.height]
+ color = to_curses_attr(get_theme().COLOR_INFORMATION_BAR)
for y, line in enumerate(lines):
x = 0
for col in self._columns.items():
@@ -106,9 +107,7 @@ class ListWin(Win):
if not txt:
continue
if line is self.lines[self._selected_row]:
- self.addstr(
- y, x, txt[:size],
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ self.addstr(y, x, txt[:size], color)
else:
self.addstr(y, x, txt[:size])
x += size
@@ -189,23 +188,24 @@ class ColumnHeaderWin(Win):
log.debug('Refresh: %s', self.__class__.__name__)
self._win.erase()
x = 0
+ theme = get_theme()
for col in self._columns:
txt = col
if col in self._column_order:
if self._column_order_asc:
- txt += get_theme().CHAR_COLUMN_ASC
+ txt += theme.CHAR_COLUMN_ASC
else:
- txt += get_theme().CHAR_COLUMN_DESC
+ txt += theme.CHAR_COLUMN_DESC
#⇓⇑↑↓⇧⇩▲▼
size = self._columns_sizes[col]
txt += ' ' * (size - len(txt))
if col in self._column_sel:
self.addstr(
0, x, txt,
- to_curses_attr(get_theme().COLOR_COLUMN_HEADER_SEL))
+ to_curses_attr(theme.COLOR_COLUMN_HEADER_SEL))
else:
self.addstr(0, x, txt,
- to_curses_attr(get_theme().COLOR_COLUMN_HEADER))
+ to_curses_attr(theme.COLOR_COLUMN_HEADER))
x += size
self._refresh()
diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py
index 72dc602c..951940e1 100644
--- a/poezio/windows/muc.py
+++ b/poezio/windows/muc.py
@@ -110,15 +110,16 @@ class UserList(Win):
self.addstr(y, 1, symbol, to_curses_attr(color))
def draw_status_chatstate(self, y: int, user: User) -> None:
- show_col = get_theme().color_show(user.show)
+ theme = get_theme()
+ show_col = theme.color_show(user.show)
if user.chatstate == 'composing':
- char = get_theme().CHAR_CHATSTATE_COMPOSING
+ char = theme.CHAR_CHATSTATE_COMPOSING
elif user.chatstate == 'active':
- char = get_theme().CHAR_CHATSTATE_ACTIVE
+ char = theme.CHAR_CHATSTATE_ACTIVE
elif user.chatstate == 'paused':
- char = get_theme().CHAR_CHATSTATE_PAUSED
+ char = theme.CHAR_CHATSTATE_PAUSED
else:
- char = get_theme().CHAR_STATUS
+ char = theme.CHAR_STATUS
self.addstr(y, 0, char, to_curses_attr(show_col))
def resize(self, height: int, width: int, y: int, x: int) -> None:
@@ -138,17 +139,18 @@ class Topic(Win):
def refresh(self, topic: Optional[str] = None) -> None:
log.debug('Refresh: %s', self.__class__.__name__)
+ theme = get_theme()
self._win.erase()
if topic is not None:
msg = topic[:self.width - 1]
else:
msg = self._message[:self.width - 1]
- self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
+ self.addstr(0, 0, msg, to_curses_attr(theme.COLOR_TOPIC_BAR))
_, x = self._win.getyx()
remaining_size = self.width - x
if remaining_size:
self.addnstr(' ' * remaining_size, remaining_size,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
self._refresh()
def set_message(self, message) -> None:
diff --git a/poezio/windows/roster_win.py b/poezio/windows/roster_win.py
index 3c62ea0a..2efdd324 100644
--- a/poezio/windows/roster_win.py
+++ b/poezio/windows/roster_win.py
@@ -195,18 +195,20 @@ class RosterWin(Win):
"""
The header at the top
"""
+ color = get_theme().COLOR_INFORMATION_BAR
self.addstr(
'Roster: %s/%s contacts' % (roster.get_nb_connected_contacts(),
len(roster)),
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- self.finish_line(get_theme().COLOR_INFORMATION_BAR)
+ to_curses_attr(color))
+ self.finish_line(color)
def draw_group(self, y: int, group: RosterGroup, colored: bool) -> None:
"""
Draw a groupname on a line
"""
+ color = to_curses_attr(get_theme().COLOR_SELECTED_ROW)
if colored:
- self._win.attron(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
+ self._win.attron(color)
if group.folded:
self.addstr(y, 0, '[+] ')
else:
@@ -217,7 +219,7 @@ class RosterWin(Win):
self.truncate_name(group.name,
len(contacts) + 4) + contacts)
if colored:
- self._win.attroff(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
+ self._win.attroff(color)
self.finish_line()
def truncate_name(self, name, added):
@@ -263,17 +265,17 @@ class RosterWin(Win):
added += 4
if contact.ask:
- added += len(get_theme().CHAR_ROSTER_ASKED)
+ added += len(theme.CHAR_ROSTER_ASKED)
if show_s2s_errors and contact.error:
- added += len(get_theme().CHAR_ROSTER_ERROR)
+ added += len(theme.CHAR_ROSTER_ERROR)
if contact.tune:
- added += len(get_theme().CHAR_ROSTER_TUNE)
+ added += len(theme.CHAR_ROSTER_TUNE)
if contact.mood:
- added += len(get_theme().CHAR_ROSTER_MOOD)
+ added += len(theme.CHAR_ROSTER_MOOD)
if contact.activity:
- added += len(get_theme().CHAR_ROSTER_ACTIVITY)
+ added += len(theme.CHAR_ROSTER_ACTIVITY)
if contact.gaming:
- added += len(get_theme().CHAR_ROSTER_GAMING)
+ added += len(theme.CHAR_ROSTER_GAMING)
if show_roster_sub in ('all', 'incomplete', 'to', 'from', 'both',
'none'):
added += len(
@@ -291,7 +293,7 @@ class RosterWin(Win):
if colored:
self.addstr(display_name,
- to_curses_attr(get_theme().COLOR_SELECTED_ROW))
+ to_curses_attr(theme.COLOR_SELECTED_ROW))
else:
self.addstr(display_name)
@@ -302,34 +304,35 @@ class RosterWin(Win):
contact.subscription, keep=show_roster_sub),
to_curses_attr(theme.COLOR_ROSTER_SUBSCRIPTION))
if contact.ask:
- self.addstr(get_theme().CHAR_ROSTER_ASKED,
- to_curses_attr(get_theme().COLOR_IMPORTANT_TEXT))
+ self.addstr(theme.CHAR_ROSTER_ASKED,
+ to_curses_attr(theme.COLOR_IMPORTANT_TEXT))
if show_s2s_errors and contact.error:
- self.addstr(get_theme().CHAR_ROSTER_ERROR,
- to_curses_attr(get_theme().COLOR_ROSTER_ERROR))
+ self.addstr(theme.CHAR_ROSTER_ERROR,
+ to_curses_attr(theme.COLOR_ROSTER_ERROR))
if contact.tune:
- self.addstr(get_theme().CHAR_ROSTER_TUNE,
- to_curses_attr(get_theme().COLOR_ROSTER_TUNE))
+ self.addstr(theme.CHAR_ROSTER_TUNE,
+ to_curses_attr(theme.COLOR_ROSTER_TUNE))
if contact.activity:
- self.addstr(get_theme().CHAR_ROSTER_ACTIVITY,
- to_curses_attr(get_theme().COLOR_ROSTER_ACTIVITY))
+ self.addstr(theme.CHAR_ROSTER_ACTIVITY,
+ to_curses_attr(theme.COLOR_ROSTER_ACTIVITY))
if contact.mood:
- self.addstr(get_theme().CHAR_ROSTER_MOOD,
- to_curses_attr(get_theme().COLOR_ROSTER_MOOD))
+ self.addstr(theme.CHAR_ROSTER_MOOD,
+ to_curses_attr(theme.COLOR_ROSTER_MOOD))
if contact.gaming:
- self.addstr(get_theme().CHAR_ROSTER_GAMING,
- to_curses_attr(get_theme().COLOR_ROSTER_GAMING))
+ self.addstr(theme.CHAR_ROSTER_GAMING,
+ to_curses_attr(theme.COLOR_ROSTER_GAMING))
self.finish_line()
def draw_resource_line(self, y: int, resource: Resource, colored: bool) -> None:
"""
Draw a specific resource line
"""
- color = get_theme().color_show(resource.presence)
- self.addstr(y, 4, get_theme().CHAR_STATUS, to_curses_attr(color))
+ theme = get_theme()
+ color = theme.color_show(resource.presence)
+ self.addstr(y, 4, theme.CHAR_STATUS, to_curses_attr(color))
if colored:
self.addstr(y, 8, self.truncate_name(str(resource.jid), 6),
- to_curses_attr(get_theme().COLOR_SELECTED_ROW))
+ to_curses_attr(theme.COLOR_SELECTED_ROW))
else:
self.addstr(y, 8, self.truncate_name(str(resource.jid), 6))
self.finish_line()
@@ -350,6 +353,7 @@ class ContactInfoWin(Win):
"""
draw the contact information
"""
+ theme = get_theme()
resource = contact.get_highest_priority_resource()
if contact:
jid = str(contact.bare_jid)
@@ -365,8 +369,8 @@ class ContactInfoWin(Win):
self.addstr(0, 0, '%s (%s)' % (
jid,
presence,
- ), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- self.finish_line(get_theme().COLOR_INFORMATION_BAR)
+ ), to_curses_attr(theme.COLOR_INFORMATION_BAR))
+ self.finish_line(theme.COLOR_INFORMATION_BAR)
i += 1
self.addstr(i, 0, 'Subscription: %s' % (contact.subscription, ))
self.finish_line()
@@ -374,7 +378,7 @@ class ContactInfoWin(Win):
if contact.ask:
if contact.ask == 'asked':
self.addstr(i, 0, 'Ask: %s' % (contact.ask, ),
- to_curses_attr(get_theme().COLOR_IMPORTANT_TEXT))
+ to_curses_attr(theme.COLOR_IMPORTANT_TEXT))
else:
self.addstr(i, 0, 'Ask: %s' % (contact.ask, ))
self.finish_line()
@@ -386,33 +390,33 @@ class ContactInfoWin(Win):
if contact.error:
self.addstr(i, 0, 'Error: %s' % contact.error,
- to_curses_attr(get_theme().COLOR_ROSTER_ERROR))
+ to_curses_attr(theme.COLOR_ROSTER_ERROR))
self.finish_line()
i += 1
if contact.tune:
self.addstr(i, 0,
'Tune: %s' % common.format_tune_string(contact.tune),
- to_curses_attr(get_theme().COLOR_NORMAL_TEXT))
+ to_curses_attr(theme.COLOR_NORMAL_TEXT))
self.finish_line()
i += 1
if contact.mood:
self.addstr(i, 0, 'Mood: %s' % contact.mood,
- to_curses_attr(get_theme().COLOR_NORMAL_TEXT))
+ to_curses_attr(theme.COLOR_NORMAL_TEXT))
self.finish_line()
i += 1
if contact.activity:
self.addstr(i, 0, 'Activity: %s' % contact.activity,
- to_curses_attr(get_theme().COLOR_NORMAL_TEXT))
+ to_curses_attr(theme.COLOR_NORMAL_TEXT))
self.finish_line()
i += 1
if contact.gaming:
self.addstr(
i, 0, 'Game: %s' % common.format_gaming_string(contact.gaming),
- to_curses_attr(get_theme().COLOR_NORMAL_TEXT))
+ to_curses_attr(theme.COLOR_NORMAL_TEXT))
self.finish_line()
i += 1
@@ -420,9 +424,10 @@ class ContactInfoWin(Win):
"""
draw the group information
"""
+ theme = get_theme()
self.addstr(0, 0, group.name,
- to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
- self.finish_line(get_theme().COLOR_INFORMATION_BAR)
+ to_curses_attr(theme.COLOR_INFORMATION_BAR))
+ self.finish_line(theme.COLOR_INFORMATION_BAR)
def refresh(self, selected_row: Row) -> None:
log.debug('Refresh: %s', self.__class__.__name__)
diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py
index d0669b26..1de905ea 100644
--- a/poezio/windows/text_win.py
+++ b/poezio/windows/text_win.py
@@ -350,9 +350,10 @@ class TextWin(BaseTextWin):
txt = message.txt
if not txt:
return []
+ theme = get_theme()
if len(message.str_time) > 8:
default_color = (
- FORMAT_CHAR + dump_tuple(get_theme().COLOR_LOG_MSG) + '}') # type: Optional[str]
+ FORMAT_CHAR + dump_tuple(theme.COLOR_LOG_MSG) + '}') # type: Optional[str]
else:
default_color = None
ret = [] # type: List[Union[None, Line]]
@@ -360,9 +361,9 @@ class TextWin(BaseTextWin):
offset = 0
if message.ack:
if message.ack > 0:
- offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1
+ offset += poopt.wcswidth(theme.CHAR_ACK_RECEIVED) + 1
else:
- offset += poopt.wcswidth(get_theme().CHAR_NACK) + 1
+ offset += poopt.wcswidth(theme.CHAR_NACK) + 1
if nick:
offset += poopt.wcswidth(nick) + 2 # + nick + '> ' length
if message.revisions > 0:
@@ -372,9 +373,9 @@ class TextWin(BaseTextWin):
if timestamp:
if message.str_time:
offset += 1 + len(message.str_time)
- if get_theme().CHAR_TIME_LEFT and message.str_time:
+ if theme.CHAR_TIME_LEFT and message.str_time:
offset += 1
- if get_theme().CHAR_TIME_RIGHT and message.str_time:
+ if theme.CHAR_TIME_RIGHT and message.str_time:
offset += 1
lines = poopt.cut_text(txt, self.width - offset - 1)
prepend = default_color if default_color else ''
@@ -439,10 +440,11 @@ class TextWin(BaseTextWin):
nick = truncate_nick(msg.nickname, nick_size)
offset += poopt.wcswidth(nick)
if msg.ack:
+ theme = get_theme()
if msg.ack > 0:
- offset += poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1
+ offset += poopt.wcswidth(theme.CHAR_ACK_RECEIVED) + 1
else:
- offset += poopt.wcswidth(get_theme().CHAR_NACK) + 1
+ offset += poopt.wcswidth(theme.CHAR_NACK) + 1
if msg.me:
offset += 3
else:
@@ -497,25 +499,28 @@ class TextWin(BaseTextWin):
return 0
def write_line_separator(self, y) -> None:
- char = get_theme().CHAR_NEW_TEXT_SEPARATOR
+ theme = get_theme()
+ char = theme.CHAR_NEW_TEXT_SEPARATOR
self.addnstr(y, 0, char * (self.width // len(char) - 1), self.width,
- to_curses_attr(get_theme().COLOR_NEW_TEXT_SEPARATOR))
+ to_curses_attr(theme.COLOR_NEW_TEXT_SEPARATOR))
def write_ack(self) -> int:
- color = get_theme().COLOR_CHAR_ACK
+ theme = get_theme()
+ color = theme.COLOR_CHAR_ACK
self._win.attron(to_curses_attr(color))
- self.addstr(get_theme().CHAR_ACK_RECEIVED)
+ self.addstr(theme.CHAR_ACK_RECEIVED)
self._win.attroff(to_curses_attr(color))
self.addstr(' ')
- return poopt.wcswidth(get_theme().CHAR_ACK_RECEIVED) + 1
+ return poopt.wcswidth(theme.CHAR_ACK_RECEIVED) + 1
def write_nack(self) -> int:
- color = get_theme().COLOR_CHAR_NACK
+ theme = get_theme()
+ color = theme.COLOR_CHAR_NACK
self._win.attron(to_curses_attr(color))
- self.addstr(get_theme().CHAR_NACK)
+ self.addstr(theme.CHAR_NACK)
self._win.attroff(to_curses_attr(color))
self.addstr(' ')
- return poopt.wcswidth(get_theme().CHAR_NACK) + 1
+ return poopt.wcswidth(theme.CHAR_NACK) + 1
def write_nickname(self, nickname, color, highlight=False) -> None:
"""
@@ -626,9 +631,10 @@ class XMLTextWin(BaseTextWin):
offset += poopt.wcswidth(nick) + 1 # + nick + ' ' length
if message.str_time:
offset += 1 + len(message.str_time)
- if get_theme().CHAR_TIME_LEFT and message.str_time:
+ theme = get_theme()
+ if theme.CHAR_TIME_LEFT and message.str_time:
offset += 1
- if get_theme().CHAR_TIME_RIGHT and message.str_time:
+ if theme.CHAR_TIME_RIGHT and message.str_time:
offset += 1
lines = poopt.cut_text(txt, self.width - offset - 1)
prepend = default_color if default_color else ''