Screen is resizable
Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
parent
ce61532f35
commit
39016f6980
|
@ -21,6 +21,7 @@ class Squinnondation:
|
||||||
bind_port: int
|
bind_port: int
|
||||||
no_emoji: bool
|
no_emoji: bool
|
||||||
no_markdown: bool
|
no_markdown: bool
|
||||||
|
screen: Any
|
||||||
|
|
||||||
def parse_arguments(self) -> None:
|
def parse_arguments(self) -> None:
|
||||||
parser = ArgumentParser(description="MIRC client.")
|
parser = ArgumentParser(description="MIRC client.")
|
||||||
|
@ -53,6 +54,7 @@ class Squinnondation:
|
||||||
|
|
||||||
with TermManager() as term_manager:
|
with TermManager() as term_manager:
|
||||||
screen = term_manager.screen
|
screen = term_manager.screen
|
||||||
|
instance.screen = screen
|
||||||
screen.addstr(0, 0, "Enter your nickname: ")
|
screen.addstr(0, 0, "Enter your nickname: ")
|
||||||
nickname = screen.getstr().decode("UTF-8")
|
nickname = screen.getstr().decode("UTF-8")
|
||||||
|
|
||||||
|
@ -515,6 +517,12 @@ class Squirrel(Hazelnut):
|
||||||
"""
|
"""
|
||||||
Rewrite the history of the messages.
|
Rewrite the history of the messages.
|
||||||
"""
|
"""
|
||||||
|
y, x = self.squinnondation.screen.getmaxyx()
|
||||||
|
if curses.is_term_resized(curses.LINES, curses.COLS):
|
||||||
|
curses.resizeterm(y, x)
|
||||||
|
self.history_pad.resize(curses.LINES - 2, curses.COLS - 1)
|
||||||
|
self.input_pad.resize(1, curses.COLS - 1)
|
||||||
|
|
||||||
self.history_pad.erase()
|
self.history_pad.erase()
|
||||||
for i, msg in enumerate(self.history[max(0, len(self.history) - curses.LINES + 2):]):
|
for i, msg in enumerate(self.history[max(0, len(self.history) - curses.LINES + 2):]):
|
||||||
if not re.match("<.*> .*", msg):
|
if not re.match("<.*> .*", msg):
|
||||||
|
@ -526,7 +534,6 @@ class Squirrel(Hazelnut):
|
||||||
self.history_pad.addstr(i, 0, "<")
|
self.history_pad.addstr(i, 0, "<")
|
||||||
self.history_pad.addstr(i, 1, nickname, curses.A_BOLD | curses.color_pair(color_id + 1))
|
self.history_pad.addstr(i, 1, nickname, curses.A_BOLD | curses.color_pair(color_id + 1))
|
||||||
self.history_pad.addstr(i, 1 + len(nickname), "> ")
|
self.history_pad.addstr(i, 1 + len(nickname), "> ")
|
||||||
attrs = curses.color_pair(0)
|
|
||||||
self.print_markdown(self.history_pad, i, 3 + len(nickname), msg)
|
self.print_markdown(self.history_pad, i, 3 + len(nickname), msg)
|
||||||
self.history_pad.refresh(0, 0, 0, 0, curses.LINES - 2, curses.COLS)
|
self.history_pad.refresh(0, 0, 0, 0, curses.LINES - 2, curses.COLS)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue