summaryrefslogtreecommitdiff
path: root/poezio/windows
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-07-04 13:26:48 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commitce21831c978ac946854957b7a8f822330a672a7b (patch)
treea27c34e13bd8e002ded1ae6cfa030a86c51f97da /poezio/windows
parentde22b2ee98a2983fbb161c8cf35108fdcec49da8 (diff)
downloadpoezio-ce21831c978ac946854957b7a8f822330a672a7b.tar.gz
poezio-ce21831c978ac946854957b7a8f822330a672a7b.tar.bz2
poezio-ce21831c978ac946854957b7a8f822330a672a7b.tar.xz
poezio-ce21831c978ac946854957b7a8f822330a672a7b.zip
Added function to build messages and add them on the top
Diffstat (limited to 'poezio/windows')
-rw-r--r--poezio/windows/text_win.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py
index 96161d51..27795261 100644
--- a/poezio/windows/text_win.py
+++ b/poezio/windows/text_win.py
@@ -340,6 +340,25 @@ class TextWin(BaseTextWin):
self.built_lines.pop(0)
return len(lines)
+ def build_message_at_the_top(self,
+ message: Message,
+ history=None,
+ timestamp: bool = False,
+ nick_size: int = 10) -> int:
+ """
+ Take one message, build it and add it to the top of the list.
+ Return the number of lines that are built for the given
+ message.
+ """
+ lines = self.build_message(
+ message, timestamp=timestamp, nick_size=nick_size)
+ lines.reverse()
+ for line in lines:
+ self.built_lines.insert(0, line)
+ if not lines or not lines[0]:
+ return 0
+ return len(lines)
+
def build_message(self, message: Optional[Message], timestamp: bool = False, nick_size: int = 10) -> List[Union[None, Line]]:
"""
Build a list of lines from a message, without adding it