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:
parent
dd72deb546
commit
17e31565e2
@ -174,6 +174,7 @@ class Choose(Handler):
|
|||||||
self.print(end='\r\n'*y)
|
self.print(end='\r\n'*y)
|
||||||
if self.cli_opts.message:
|
if self.cli_opts.message:
|
||||||
y += self.draw_long_text(self.cli_opts.message)
|
y += self.draw_long_text(self.cli_opts.message)
|
||||||
|
if self.screen_size.rows > 2:
|
||||||
self.print()
|
self.print()
|
||||||
y += 1
|
y += 1
|
||||||
if self.cli_opts.type == 'yesno':
|
if self.cli_opts.type == 'yesno':
|
||||||
@ -187,11 +188,11 @@ class Choose(Handler):
|
|||||||
current_ranges: Dict[str, int] = {}
|
current_ranges: Dict[str, int] = {}
|
||||||
width = self.screen_size.cols - 2
|
width = self.screen_size.cols - 2
|
||||||
|
|
||||||
def commit_line() -> None:
|
def commit_line(end: str = '\r\n') -> None:
|
||||||
nonlocal current_line, y
|
nonlocal current_line, y
|
||||||
extra = (width - wcswidth(current_line)) // 2
|
extra = (width - wcswidth(current_line)) // 2
|
||||||
x = extra + 1
|
x = extra + 1
|
||||||
self.print(' ' * x + current_line)
|
self.print(' ' * x + current_line, end=end)
|
||||||
for letter, sz in current_ranges.items():
|
for letter, sz in current_ranges.items():
|
||||||
self.clickable_ranges[letter] = Range(x, x + sz - 3, y)
|
self.clickable_ranges[letter] = Range(x, x + sz - 3, y)
|
||||||
x += sz
|
x += sz
|
||||||
@ -210,7 +211,7 @@ class Choose(Handler):
|
|||||||
current_line += text
|
current_line += text
|
||||||
current_ranges[letter] = sz
|
current_ranges[letter] = sz
|
||||||
if current_line:
|
if current_line:
|
||||||
commit_line()
|
commit_line(end='')
|
||||||
|
|
||||||
def draw_yesno(self, y: int) -> None:
|
def draw_yesno(self, y: int) -> None:
|
||||||
sep = ' ' * 3
|
sep = ' ' * 3
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user