From e37c43b78dda57208ea5798fb422cca45aed3a77 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 21 Dec 2020 16:04:14 +0100 Subject: [PATCH] Scroll horizontally on the input line for long messages Signed-off-by: Yohann D'ANELLO --- squinnondation/hazel.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/squinnondation/hazel.py b/squinnondation/hazel.py index a6d09c6..27dea5f 100644 --- a/squinnondation/hazel.py +++ b/squinnondation/hazel.py @@ -110,7 +110,8 @@ class Squirrel(Hazelnut): if not self.squinnondation.no_emoji: self.refresh_emoji_pad() try: - key = self.squinnondation.screen.getkey(curses.LINES - 1, 3 + len(self.nickname) + self.input_index) + key = self.squinnondation.screen.getkey(curses.LINES - 1, + min(3 + len(self.nickname) + self.input_index, curses.COLS - 4)) except curses.error: continue @@ -383,9 +384,10 @@ class Squirrel(Hazelnut): self.input_pad.addstr(0, 1, self.nickname, curses.A_BOLD | curses.color_pair(color_id + 1)) self.input_pad.addstr(0, 1 + len(self.nickname), "> ") msg = self.input_buffer - if len(msg) + len(self.nickname) + 3 >= curses.COLS: - msg = "" - self.input_pad.addstr(0, 3 + len(self.nickname), self.input_buffer) + if self.input_index >= curses.COLS - len(self.nickname) - 7: + msg = msg[self.input_index - (curses.COLS - len(self.nickname) - 7):self.input_index] + msg = msg[:curses.COLS - len(self.nickname) - 7] + self.input_pad.addstr(0, 3 + len(self.nickname), msg) if not self.squinnondation.no_emoji: self.input_pad.addstr(0, self.input_pad.getmaxyx()[1] - 3, "😀") self.input_pad.refresh(0, 0, curses.LINES - 1, 0, curses.LINES - 1, curses.COLS - 1)