mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 03:43:19 +00:00
Fix invalid width count when resizing and terminal width is uneven (#164)
This commit is contained in:
parent
7a9e31231b
commit
f94188a64d
2 changed files with 8 additions and 6 deletions
|
@ -747,8 +747,10 @@ class Controller:
|
||||||
self.view.stdscr.erase()
|
self.view.stdscr.erase()
|
||||||
self.view.stdscr.noutrefresh()
|
self.view.stdscr.noutrefresh()
|
||||||
|
|
||||||
self.view.chats.resize(rows, cols, self.chat_size)
|
chat_width = round(cols * self.chat_size)
|
||||||
self.view.msgs.resize(rows, cols, 1 - self.chat_size)
|
msg_width = cols - chat_width
|
||||||
|
self.view.chats.resize(rows, cols, chat_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()
|
||||||
|
|
||||||
|
|
|
@ -137,9 +137,9 @@ class ChatView:
|
||||||
self._refresh = self.win.refresh
|
self._refresh = self.win.refresh
|
||||||
self.model = model
|
self.model = model
|
||||||
|
|
||||||
def resize(self, rows: int, cols: int, p: float = 0.25) -> None:
|
def resize(self, rows: int, cols: int, width: int) -> None:
|
||||||
self.h = rows - 1
|
self.h = rows - 1
|
||||||
self.w = round(cols * p)
|
self.w = width
|
||||||
self.win.resize(self.h, self.w)
|
self.win.resize(self.h, self.w)
|
||||||
|
|
||||||
def _msg_color(self, is_selected: bool = False) -> int:
|
def _msg_color(self, is_selected: bool = False) -> int:
|
||||||
|
@ -278,9 +278,9 @@ class MsgView:
|
||||||
"messageSendingStatePending": "pending",
|
"messageSendingStatePending": "pending",
|
||||||
}
|
}
|
||||||
|
|
||||||
def resize(self, rows: int, cols: int, p: float = 0.5) -> None:
|
def resize(self, rows: int, cols: int, width: int) -> None:
|
||||||
self.h = rows - 1
|
self.h = rows - 1
|
||||||
self.w = round(cols * p)
|
self.w = width
|
||||||
self.x = cols - self.w
|
self.x = cols - self.w
|
||||||
self.win.resize(self.h, self.w)
|
self.win.resize(self.h, self.w)
|
||||||
self.win.mvwin(0, self.x)
|
self.win.mvwin(0, self.x)
|
||||||
|
|
Loading…
Reference in a new issue