diff options
| author | historia <historiavg@proton.me> | 2026-08-28 19:01:16 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-28 19:01:16 -0400 |
| commit | 83d0b7a5b2f669a1d3a9a0bea9c74b00e0b4c07b (patch) | |
| tree | 23c6809c02c19a2652717ade04a4312bae36db06 /app/ui/tui.py | |
| parent | 03ed68bafec56ef8bb690440d796c1a742042907 (diff) | |
| download | tts-audiobook-generator-83d0b7a5b2f669a1d3a9a0bea9c74b00e0b4c07b.tar.gz | |
fix: no .wav directory error formatting
Diffstat (limited to 'app/ui/tui.py')
| -rw-r--r-- | app/ui/tui.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/app/ui/tui.py b/app/ui/tui.py index 60e2dda..19764ab 100644 --- a/app/ui/tui.py +++ b/app/ui/tui.py @@ -403,13 +403,27 @@ class Frame: + 2 * row["indent"] return len(row["text"]) + 2 * row["indent"] + def _status_extra(self) -> int: + """Rows the status block needs beyond its single bottom row. + + A multi-line status stacks upward from the row above the footer; + the dialog must grow (and the buttons row must shift up) so the + block clears the buttons and the body rows. + """ + if not self.status: + return 0 + return max(0, len(self.status[0].split("\n")) - 1) + def _measure(self, width: int) -> int: """Dialog width: widest row plus frame, capped to the screen.""" longest = max(len(self.title) + 4, len(self.footer) + 4, 40) for row in self.rows: longest = max(longest, self._row_width(row) + 4) if self.status: - longest = max(longest, len(self.status[0]) + 6) + # Measure per line: a multi-line status must not widen the + # dialog to the combined length of its lines. + longest = max(longest, max(len(line) for line + in self.status[0].split("\n")) + 6) if self.buttons: labels, _ = self.buttons longest = max(longest, @@ -463,7 +477,8 @@ class Frame: # Borders, title, status and footer are fixed chrome; a titled # frame also reserves a blank line below its title, and buttons # take their own row above the status. - chrome = 6 + (1 if self.title else 0) + (1 if self.buttons else 0) + chrome = 6 + (1 if self.title else 0) + (1 if self.buttons else 0) \ + + self._status_extra() dialog_h = min(max(self.MIN_HEIGHT, len(flat) + chrome), height) visible = max(1, dialog_h - chrome) self.page_size = max(1, visible) @@ -605,7 +620,7 @@ class Frame: rendered = [f"[ {label} ]" for label in labels] total = sum(len(r) for r in rendered) + 3 * (len(rendered) - 1) x = inner_x + max(0, (inner_w - total) // 2) - y = y0 + dialog_h - 4 + y = y0 + dialog_h - 4 - self._status_extra() for index, text in enumerate(rendered): if index: x += 3 @@ -623,10 +638,14 @@ class Frame: if self.status: text, kind = self.status attr = theme.get(kind, theme["body"]) - text = _fit(f" {text} ", inner_w) - _addstr(scr, y0 + dialog_h - 3, - inner_x + max(0, (inner_w - len(text)) // 2), - text, attr) + # The status is a block of lines stacking upward from the + # row above the footer (an embedded "\n" never spills onto + # the footer's row); each line is fitted on its own. + for offset, line in enumerate(reversed(text.split("\n"))): + line = _fit(f" {line} ", inner_w) + _addstr(scr, y0 + dialog_h - 3 - offset, + inner_x + max(0, (inner_w - len(line)) // 2), + line, attr) footer = _fit(self.footer, inner_w) _addstr(scr, y0 + dialog_h - 2, inner_x + max(0, (inner_w - len(footer)) // 2), |
