Fix invalid width count when resizing and terminal width is uneven (#164)

This commit is contained in:
Nameless 2020-07-24 10:12:42 +08:00 committed by GitHub
parent 7a9e31231b
commit f94188a64d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -747,8 +747,10 @@ class Controller:
self.view.stdscr.erase()
self.view.stdscr.noutrefresh()
self.view.chats.resize(rows, cols, self.chat_size)
self.view.msgs.resize(rows, cols, 1 - self.chat_size)
chat_width = round(cols * 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.render()

View file

@ -137,9 +137,9 @@ class ChatView:
self._refresh = self.win.refresh
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.w = round(cols * p)
self.w = width
self.win.resize(self.h, self.w)
def _msg_color(self, is_selected: bool = False) -> int:
@ -278,9 +278,9 @@ class MsgView:
"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.w = round(cols * p)
self.w = width
self.x = cols - self.w
self.win.resize(self.h, self.w)
self.win.mvwin(0, self.x)