Replace content CLI with Textual TUI
This commit is contained in:
1 parent
0d58ddd430
commit
737700a9a8
28 files changed
+2403
-167
No files matched your search
@@ -0,0 +1,57 @@
|
||||
from textual.theme import Theme
|
||||
|
||||
import site_themes
|
||||
|
||||
|
||||
def to_textual_theme(theme: dict) -> Theme:
|
||||
colors = theme["colors"]
|
||||
border_start, border_end = theme.get("activeBorder") or (colors["accent"], colors["accent"])
|
||||
return Theme(
|
||||
name=theme["id"],
|
||||
primary=border_start,
|
||||
secondary=colors["blue"],
|
||||
accent=border_end,
|
||||
foreground=colors["foreground"],
|
||||
background=colors["dark_background"],
|
||||
surface=colors["background"],
|
||||
panel=colors["lighter_background"],
|
||||
boost=colors["selection"],
|
||||
warning=colors["yellow"],
|
||||
error=colors["red"],
|
||||
success=colors["green"],
|
||||
dark=theme.get("mode") != "light",
|
||||
variables={
|
||||
"text-muted": colors["muted"],
|
||||
"border": border_start,
|
||||
"border-blurred": colors["selection"],
|
||||
"block-cursor-background": colors["accent"],
|
||||
"block-cursor-foreground": colors["dark_background"],
|
||||
"block-cursor-text-style": "bold",
|
||||
"block-cursor-blurred-background": colors["selection"],
|
||||
"block-hover-background": colors["selection"],
|
||||
"footer-key-foreground": colors["accent"],
|
||||
"input-selection-background": f"{colors['accent']} 35%",
|
||||
"input-cursor-background": colors["foreground"],
|
||||
"scrollbar": colors["selection"],
|
||||
"scrollbar-hover": colors["muted"],
|
||||
"scrollbar-active": colors["accent"],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def load_site_themes() -> list[Theme]:
|
||||
try:
|
||||
themes = site_themes.load_themes()
|
||||
except (OSError, ValueError):
|
||||
return []
|
||||
textual_themes = []
|
||||
for theme in themes:
|
||||
try:
|
||||
textual_themes.append(to_textual_theme(theme))
|
||||
except (KeyError, ValueError):
|
||||
continue
|
||||
return textual_themes
|
||||
|
||||
|
||||
def default_theme_id() -> str | None:
|
||||
return site_themes.default_theme_id()
|
||||
Reference in new issue
Block a user