|
6 | 6 |
|
7 | 7 | import click |
8 | 8 | from rich.text import Text |
9 | | -from textual import log, on |
| 9 | +from textual import on |
10 | 10 | from textual.app import ComposeResult |
11 | 11 | from textual.containers import Vertical, Horizontal |
12 | 12 | from textual.css.query import NoMatches |
@@ -406,23 +406,27 @@ def _make_command_form_control_label( |
406 | 406 | is_required: bool, |
407 | 407 | multiple: bool, |
408 | 408 | ) -> Text: |
409 | | - if isinstance(name, str): |
410 | | - text = Text.from_markup( |
411 | | - f"{name}[dim]{' multiple' if multiple else ''} {type.name}[/] {' [b red]*[/]required' if is_required else ''}" |
412 | | - ) |
413 | | - else: |
414 | | - names = Text(" / ", style="dim").join([Text(n) for n in name]) |
415 | | - text = Text.from_markup( |
416 | | - f"{names}[dim]{' multiple' if multiple else ''} {type.name}[/] {' [b red]*[/]required' if is_required else ''}" |
417 | | - ) |
| 409 | + def yield_segments() -> Iterable[Text]: |
| 410 | + if isinstance(name, str): |
| 411 | + yield Text(name) |
| 412 | + else: |
| 413 | + yield Text(" / ", style="dim").join([Text(n) for n in name]) |
| 414 | + |
| 415 | + if multiple: |
| 416 | + yield Text("multiple", style="dim") |
| 417 | + |
| 418 | + yield Text(type.name, style="dim") |
| 419 | + |
| 420 | + if is_required: |
| 421 | + yield Text.assemble(Text("*", style="b red"), "required") |
418 | 422 |
|
419 | | - if isinstance(type, (click.IntRange, click.FloatRange)): |
420 | | - if type.min is not None: |
421 | | - text = Text.assemble(text, Text(f"min={type.min} ", "dim")) |
422 | | - if type.max is not None: |
423 | | - text = Text.assemble(text, Text(f"max={type.max}", "dim")) |
| 423 | + if isinstance(type, (click.IntRange, click.FloatRange)): |
| 424 | + if type.min is not None: |
| 425 | + yield Text(f"min={type.min}", style="dim") |
| 426 | + if type.max is not None: |
| 427 | + yield Text(f"max={type.max}", style="dim") |
424 | 428 |
|
425 | | - return text |
| 429 | + return Text(" ").join(yield_segments()) |
426 | 430 |
|
427 | 431 | def focus(self, scroll_visible: bool = True): |
428 | 432 | if self.first_control is not None: |
|
0 commit comments