diff options
author | mathieui <mathieui@mathieui.net> | 2019-09-29 18:12:48 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-05-09 19:46:17 +0200 |
commit | a5e92800477f6195a6b2e8c6e64a56859117d5b8 (patch) | |
tree | f53550024091a12deeee88c0d9897d0aeba9f4bf /poezio/core/core.py | |
parent | fefbb0b08887b761ad7a1cf95cf6b9f5f30013a6 (diff) | |
download | poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.gz poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.bz2 poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.xz poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.zip |
Pass a message to add_message instead of messed up kwargs everywhere
Changes LOTS of things
Diffstat (limited to 'poezio/core/core.py')
-rw-r--r-- | poezio/core/core.py | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index 2b8252b1..8f25d551 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -53,8 +53,15 @@ from poezio.core.completions import CompletionCore from poezio.core.tabs import Tabs from poezio.core.commands import CommandCore from poezio.core.handlers import HandlerCore -from poezio.core.structs import POSSIBLE_SHOW, DEPRECATED_ERRORS, \ - ERROR_AND_STATUS_CODES, Command, Status +from poezio.core.structs import ( + Command, + Status, + DEPRECATED_ERRORS, + ERROR_AND_STATUS_CODES, + POSSIBLE_SHOW, +) + +from poezio.ui.types import Message, InfoMessage log = logging.getLogger(__name__) @@ -1317,7 +1324,7 @@ class Core: """ tab = self.tabs.by_name_and_class(jid, tabs.ConversationTab) if tab is not None: - tab.add_message(msg, typ=2) + tab.add_message(InfoMessage(msg), typ=2) if self.tabs.current_tab is tab: self.refresh_window() @@ -1349,9 +1356,11 @@ class Core: colors = get_theme().INFO_COLORS color = colors.get(typ.lower(), colors.get('default', None)) nb_lines = self.information_buffer.add_message( - txt=msg, - nickname=typ, - nick_color=color + Message( + txt=msg, + nickname=typ, + nick_color=color + ) ) popup_on = config.get('information_buffer_popup_on').split() if isinstance(self.tabs.current_tab, tabs.RosterInfoTab): @@ -1582,17 +1591,6 @@ class Core: self.tab_win.resize(1, tabs.Tab.width, tabs.Tab.height - 2, 0) self.left_tab_win = None - def add_message_to_text_buffer(self, buff, txt, nickname=None): - """ - Add the message to the room if possible, else, add it to the Info window - (in the Info tab of the info window in the RosterTab) - """ - if not buff: - self.information('Trying to add a message in no room: %s' % txt, - 'Error') - return - buff.add_message(txt, nickname=nickname) - def full_screen_redraw(self): """ Completely erase and redraw the screen @@ -2064,15 +2062,18 @@ class Core: return error_message = self.get_error_message(error) tab.add_message( - error_message, - highlight=True, - nickname='Error', - nick_color=get_theme().COLOR_ERROR_MSG, - typ=2) + Message( + error_message, + highlight=True, + nickname='Error', + nick_color=get_theme().COLOR_ERROR_MSG, + ), + typ=2, + ) code = error['error']['code'] if code == '401': msg = 'To provide a password in order to join the room, type "/join / password" (replace "password" by the real password)' - tab.add_message(msg, typ=2) + tab.add_message(InfoMessage(msg), typ=2) if code == '409': if config.get('alternative_nickname') != '': if not tab.joined: @@ -2081,8 +2082,12 @@ class Core: else: if not tab.joined: tab.add_message( - 'You can join the room with an other nick, by typing "/join /other_nick"', - typ=2) + InfoMessage( + 'You can join the room with another nick, ' + 'by typing "/join /other_nick"' + ), + typ=2, + ) self.refresh_window() |