summaryrefslogtreecommitdiff
path: root/poezio/windows
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-08-21 17:06:54 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-08-22 00:54:25 +0530
commit254b8953c4a63416a7d49088990bbd2768ca4ec6 (patch)
tree29db899f7e7fb87f1216d4b9a0cd41f22a653ed9 /poezio/windows
parentaae00af2811e5d1229de1727717745e0dc242eab (diff)
downloadpoezio-254b8953c4a63416a7d49088990bbd2768ca4ec6.tar.gz
poezio-254b8953c4a63416a7d49088990bbd2768ca4ec6.tar.bz2
poezio-254b8953c4a63416a7d49088990bbd2768ca4ec6.tar.xz
poezio-254b8953c4a63416a7d49088990bbd2768ca4ec6.zip
Removed repetitive code.
Diffstat (limited to 'poezio/windows')
-rw-r--r--poezio/windows/text_win.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py
index 44a70953..8a55338a 100644
--- a/poezio/windows/text_win.py
+++ b/poezio/windows/text_win.py
@@ -316,6 +316,7 @@ class TextWin(BaseTextWin):
clean: bool = True,
highlight: bool = False,
timestamp: bool = False,
+ top: Optional[bool] = False,
nick_size: int = 10) -> int:
"""
Take one message, build it and add it to the list
@@ -324,10 +325,15 @@ class TextWin(BaseTextWin):
"""
lines = self.build_message(
message, timestamp=timestamp, nick_size=nick_size)
- if self.lock:
- self.lock_buffer.extend(lines)
+ if top:
+ lines.reverse()
+ for line in lines:
+ self.built_lines.insert(0, line)
else:
- self.built_lines.extend(lines)
+ if self.lock:
+ self.lock_buffer.extend(lines)
+ else:
+ self.built_lines.extend(lines)
if not lines or not lines[0]:
return 0
if highlight:
@@ -340,25 +346,6 @@ 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