summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-07-04 13:25:39 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commitde22b2ee98a2983fbb161c8cf35108fdcec49da8 (patch)
treeb4e85864b5566779f36e84147f4060e66e646969
parent971c41eac63d2bc298970b1194c0788352a8fd28 (diff)
downloadpoezio-de22b2ee98a2983fbb161c8cf35108fdcec49da8.tar.gz
poezio-de22b2ee98a2983fbb161c8cf35108fdcec49da8.tar.bz2
poezio-de22b2ee98a2983fbb161c8cf35108fdcec49da8.tar.xz
poezio-de22b2ee98a2983fbb161c8cf35108fdcec49da8.zip
Added 'top' parameter in add_message function to add messages on the top.
-rw-r--r--poezio/text_buffer.py24
1 files changed, 18 insertions, 6 deletions
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)