mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
Fix hang when opened external app and resizing terminal (#167)
This commit is contained in:
parent
44935ba908
commit
859de4a6d3
3 changed files with 12 additions and 4 deletions
|
@ -1,4 +1,3 @@
|
||||||
import curses
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -757,8 +756,7 @@ class Controller:
|
||||||
log.exception("Error happend in key handle loop")
|
log.exception("Error happend in key handle loop")
|
||||||
|
|
||||||
def resize_handler(self, signum: int, frame: Any) -> None:
|
def resize_handler(self, signum: int, frame: Any) -> None:
|
||||||
curses.endwin()
|
self.view.resize_handler()
|
||||||
self.view.stdscr.refresh()
|
|
||||||
self.resize()
|
self.resize()
|
||||||
|
|
||||||
def resize(self) -> None:
|
def resize(self) -> None:
|
||||||
|
@ -777,7 +775,7 @@ class Controller:
|
||||||
self.view.chats.resize(rows, cols, chat_width)
|
self.view.chats.resize(rows, cols, chat_width)
|
||||||
self.view.msgs.resize(rows, cols, msg_width)
|
self.view.msgs.resize(rows, cols, msg_width)
|
||||||
self.view.status.resize(rows, cols)
|
self.view.status.resize(rows, cols)
|
||||||
self.render()
|
self._render()
|
||||||
|
|
||||||
def draw(self) -> None:
|
def draw(self) -> None:
|
||||||
while self.is_running:
|
while self.is_running:
|
||||||
|
|
|
@ -236,6 +236,7 @@ class suspend:
|
||||||
def __enter__(self) -> "suspend":
|
def __enter__(self) -> "suspend":
|
||||||
for view in (self.view.chats, self.view.msgs, self.view.status):
|
for view in (self.view.chats, self.view.msgs, self.view.status):
|
||||||
view._refresh = view.win.noutrefresh
|
view._refresh = view.win.noutrefresh
|
||||||
|
self.view.resize_handler = self.view.resize_mock
|
||||||
curses.echo()
|
curses.echo()
|
||||||
curses.nocbreak()
|
curses.nocbreak()
|
||||||
self.view.stdscr.keypad(False)
|
self.view.stdscr.keypad(False)
|
||||||
|
@ -251,6 +252,7 @@ class suspend:
|
||||||
) -> None:
|
) -> None:
|
||||||
for view in (self.view.chats, self.view.msgs, self.view.status):
|
for view in (self.view.chats, self.view.msgs, self.view.status):
|
||||||
view._refresh = view.win.refresh
|
view._refresh = view.win.refresh
|
||||||
|
self.view.resize_handler = self.view.resize
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
curses.cbreak()
|
curses.cbreak()
|
||||||
self.view.stdscr.keypad(True)
|
self.view.stdscr.keypad(True)
|
||||||
|
|
|
@ -57,6 +57,14 @@ class View:
|
||||||
self.msgs = msg_view
|
self.msgs = msg_view
|
||||||
self.status = status_view
|
self.status = status_view
|
||||||
self.max_read = 2048
|
self.max_read = 2048
|
||||||
|
self.resize_handler = self.resize
|
||||||
|
|
||||||
|
def resize_mock(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def resize(self) -> None:
|
||||||
|
curses.endwin()
|
||||||
|
self.stdscr.refresh()
|
||||||
|
|
||||||
def get_keys(self) -> Tuple[int, str]:
|
def get_keys(self) -> Tuple[int, str]:
|
||||||
keys = repeat_factor = ""
|
keys = repeat_factor = ""
|
||||||
|
|
Loading…
Reference in a new issue