Scroll horizontally on the input line for long messages

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2020-12-21 16:04:14 +01:00
parent dd4f839fad
commit e37c43b78d
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 4 deletions

View File

@ -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)