|
4 | 4 | if TYPE_CHECKING: |
5 | 5 | from rich.theme import Theme |
6 | 6 |
|
7 | | -from httpie.output.ui.palette import GenericColor, PieStyle, Styles # noqa |
| 7 | +from httpie.output.ui.palette import GenericColor, PieStyle, Styles, ColorString, _StyledGenericColor # noqa |
| 8 | + |
| 9 | +RICH_BOLD = ColorString('bold') |
8 | 10 |
|
9 | 11 | # Rich-specific color code declarations |
10 | 12 | # <https://github.com/Textualize/rich/blob/fcd684dd3a482977cab620e71ccaebb94bf13ac9/rich/default_styles.py> |
11 | 13 | CUSTOM_STYLES = { |
12 | | - 'progress.description': GenericColor.WHITE, |
13 | | - 'progress.data.speed': GenericColor.GREEN, |
14 | | - 'progress.percentage': GenericColor.AQUA, |
15 | | - 'progress.download': GenericColor.AQUA, |
16 | | - 'progress.remaining': GenericColor.ORANGE, |
17 | | - 'bar.complete': GenericColor.PURPLE, |
18 | | - 'bar.finished': GenericColor.GREEN, |
19 | | - 'bar.pulse': GenericColor.PURPLE, |
20 | | - 'option': GenericColor.PINK, |
| 14 | + 'progress.description': RICH_BOLD | GenericColor.WHITE, |
| 15 | + 'progress.data.speed': RICH_BOLD | GenericColor.GREEN, |
| 16 | + 'progress.percentage': RICH_BOLD | GenericColor.AQUA, |
| 17 | + 'progress.download': RICH_BOLD | GenericColor.AQUA, |
| 18 | + 'progress.remaining': RICH_BOLD | GenericColor.ORANGE, |
| 19 | + 'bar.complete': RICH_BOLD | GenericColor.PURPLE, |
| 20 | + 'bar.finished': RICH_BOLD | GenericColor.GREEN, |
| 21 | + 'bar.pulse': RICH_BOLD | GenericColor.PURPLE, |
| 22 | + 'option': RICH_BOLD | GenericColor.PINK, |
21 | 23 | } |
22 | 24 |
|
23 | 25 |
|
@@ -55,9 +57,15 @@ def _make_rich_color_theme(style_name: Optional[str]) -> 'Theme': |
55 | 57 | for color, color_set in ChainMap( |
56 | 58 | GenericColor.__members__, CUSTOM_STYLES |
57 | 59 | ).items(): |
| 60 | + if isinstance(color_set, _StyledGenericColor): |
| 61 | + properties = dict.fromkeys(color_set.styles, True) |
| 62 | + color_set = color_set.color |
| 63 | + else: |
| 64 | + properties = {} |
| 65 | + |
58 | 66 | theme.styles[color.lower()] = Style( |
59 | 67 | color=color_set.apply_style(style, style_name=style_name), |
60 | | - bold=style is Styles.PIE, |
| 68 | + **properties, |
61 | 69 | ) |
62 | 70 |
|
63 | 71 | # E.g translate GenericColor.BLUE into blue on key access |
|
0 commit comments