Get it working even with 2 row windows assuming they are wide enough to fit the title on a single line

This commit is contained in:
Kovid Goyal 2022-01-21 21:46:27 +05:30
parent dd72deb546
commit 17e31565e2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -174,8 +174,9 @@ def draw_screen(self) -> None:
self.print(end='\r\n'*y)
if self.cli_opts.message:
y += self.draw_long_text(self.cli_opts.message)
self.print()
y += 1
if self.screen_size.rows > 2:
self.print()
y += 1
if self.cli_opts.type == 'yesno':
self.draw_yesno(y)
else:
@ -187,11 +188,11 @@ def draw_choice(self, y: int) -> None:
current_ranges: Dict[str, int] = {}
width = self.screen_size.cols - 2
def commit_line() -> None:
def commit_line(end: str = '\r\n') -> None:
nonlocal current_line, y
extra = (width - wcswidth(current_line)) // 2
x = extra + 1
self.print(' ' * x + current_line)
self.print(' ' * x + current_line, end=end)
for letter, sz in current_ranges.items():
self.clickable_ranges[letter] = Range(x, x + sz - 3, y)
x += sz
@ -210,7 +211,7 @@ def commit_line() -> None:
current_line += text
current_ranges[letter] = sz
if current_line:
commit_line()
commit_line(end='')
def draw_yesno(self, y: int) -> None:
sep = ' ' * 3