From de22b2ee98a2983fbb161c8cf35108fdcec49da8 Mon Sep 17 00:00:00 2001 From: Madhur Garg Date: Thu, 4 Jul 2019 13:25:39 +0530 Subject: Added 'top' parameter in add_message function to add messages on the top. --- poezio/text_buffer.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'poezio/text_buffer.py') diff --git a/poezio/text_buffer.py b/poezio/text_buffer.py index bf0ac966..64bc17f6 100644 --- a/poezio/text_buffer.py +++ b/poezio/text_buffer.py @@ -139,6 +139,7 @@ class TextBuffer: history: bool = False, user: Optional[str] = None, highlight: bool = False, + top: Optional[bool] = False, identifier: Optional[str] = None, str_time: Optional[str] = None, jid: Optional[str] = None, @@ -168,16 +169,27 @@ class TextBuffer: nick_size = config.get('max_nick_length') for window in self._windows: # make the associated windows # build the lines from the new message - nb = window.build_new_message( + if top == True: + nb = window.build_message_at_the_top( msg, history=history, - highlight=highlight, timestamp=show_timestamps, nick_size=nick_size) - if ret_val == 0: - ret_val = nb - if window.pos != 0: - window.scroll_up(nb) + if ret_val == 0: + ret_val = nb + if window.pos != 0: + window.scroll_up(nb) + else: + nb = window.build_new_message( + msg, + history=history, + highlight=highlight, + timestamp=show_timestamps, + nick_size=nick_size) + if ret_val == 0: + ret_val = nb + if window.pos != 0: + window.scroll_up(nb) return min(ret_val, 1) -- cgit v1.2.3