mirror of
https://github.com/daylinmorgan/yartsu.git
synced 2024-12-22 04:20:44 -06:00
fix: drop needless resources usage and embed themes
This commit is contained in:
parent
fa5e7c6a74
commit
00e68d5568
11 changed files with 223 additions and 22 deletions
218
src/yartsu/_themes.py
Normal file
218
src/yartsu/_themes.py
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
THEMES = (
|
||||||
|
(
|
||||||
|
"cat-mocha",
|
||||||
|
(
|
||||||
|
[198, 208, 245],
|
||||||
|
[30, 30, 46],
|
||||||
|
[
|
||||||
|
[179, 188, 223],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[86, 89, 112],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[161, 168, 201],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[67, 70, 90],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cat-macchiato",
|
||||||
|
(
|
||||||
|
[197, 207, 245],
|
||||||
|
[36, 39, 58],
|
||||||
|
[
|
||||||
|
[179, 188, 223],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[86, 89, 112],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[161, 168, 201],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[67, 70, 90],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cat-frappe",
|
||||||
|
(
|
||||||
|
[198, 206, 239],
|
||||||
|
[48, 52, 70],
|
||||||
|
[
|
||||||
|
[179, 188, 223],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[86, 89, 112],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[161, 168, 201],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[67, 70, 90],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"cat-latte",
|
||||||
|
(
|
||||||
|
[76, 79, 105],
|
||||||
|
[239, 241, 245],
|
||||||
|
[
|
||||||
|
[179, 188, 223],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[86, 89, 112],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[161, 168, 201],
|
||||||
|
[243, 139, 168],
|
||||||
|
[166, 227, 161],
|
||||||
|
[249, 226, 175],
|
||||||
|
[135, 176, 249],
|
||||||
|
[245, 194, 231],
|
||||||
|
[148, 226, 213],
|
||||||
|
[67, 70, 90],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"dracula",
|
||||||
|
(
|
||||||
|
[248, 248, 242],
|
||||||
|
[40, 42, 54],
|
||||||
|
[
|
||||||
|
[33, 34, 44],
|
||||||
|
[255, 85, 85],
|
||||||
|
[80, 250, 123],
|
||||||
|
[241, 250, 140],
|
||||||
|
[189, 147, 249],
|
||||||
|
[255, 121, 198],
|
||||||
|
[139, 233, 253],
|
||||||
|
[248, 248, 242],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[98, 114, 164],
|
||||||
|
[255, 110, 110],
|
||||||
|
[105, 255, 148],
|
||||||
|
[255, 255, 165],
|
||||||
|
[214, 172, 255],
|
||||||
|
[255, 146, 223],
|
||||||
|
[164, 255, 255],
|
||||||
|
[255, 255, 255],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"gruvbox-dark",
|
||||||
|
(
|
||||||
|
[213, 196, 161],
|
||||||
|
[40, 40, 40],
|
||||||
|
[
|
||||||
|
[40, 40, 40],
|
||||||
|
[251, 73, 52],
|
||||||
|
[184, 187, 38],
|
||||||
|
[250, 189, 47],
|
||||||
|
[131, 165, 152],
|
||||||
|
[211, 134, 155],
|
||||||
|
[142, 192, 124],
|
||||||
|
[213, 196, 161],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[102, 92, 84],
|
||||||
|
[254, 128, 25],
|
||||||
|
[60, 56, 54],
|
||||||
|
[80, 73, 69],
|
||||||
|
[189, 174, 147],
|
||||||
|
[235, 219, 178],
|
||||||
|
[214, 93, 14],
|
||||||
|
[251, 241, 199],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"gruvbox-light",
|
||||||
|
(
|
||||||
|
[80, 73, 69],
|
||||||
|
[251, 241, 199],
|
||||||
|
[
|
||||||
|
[251, 241, 199],
|
||||||
|
[157, 0, 6],
|
||||||
|
[121, 116, 14],
|
||||||
|
[181, 118, 20],
|
||||||
|
[7, 102, 120],
|
||||||
|
[143, 63, 113],
|
||||||
|
[66, 123, 88],
|
||||||
|
[80, 73, 69],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[189, 174, 147],
|
||||||
|
[175, 58, 3],
|
||||||
|
[235, 219, 178],
|
||||||
|
[213, 196, 161],
|
||||||
|
[102, 92, 84],
|
||||||
|
[60, 56, 54],
|
||||||
|
[214, 93, 14],
|
||||||
|
[40, 40, 40],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"nord",
|
||||||
|
(
|
||||||
|
[215, 222, 233],
|
||||||
|
[46, 52, 64],
|
||||||
|
[
|
||||||
|
[59, 66, 82],
|
||||||
|
[191, 97, 106],
|
||||||
|
[163, 190, 140],
|
||||||
|
[235, 203, 139],
|
||||||
|
[129, 161, 193],
|
||||||
|
[180, 142, 173],
|
||||||
|
[136, 192, 208],
|
||||||
|
[229, 233, 240],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[76, 86, 106],
|
||||||
|
[191, 97, 106],
|
||||||
|
[163, 190, 140],
|
||||||
|
[235, 203, 139],
|
||||||
|
[129, 161, 193],
|
||||||
|
[180, 142, 173],
|
||||||
|
[143, 188, 187],
|
||||||
|
[236, 239, 244],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
|
@ -6,13 +6,13 @@ from pathlib import Path
|
||||||
from rich.__main__ import make_test_card
|
from rich.__main__ import make_test_card
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
|
||||||
|
from ._argparse import ArgumentParser
|
||||||
from ._export_format import CONSOLE_SVG_FORMAT
|
from ._export_format import CONSOLE_SVG_FORMAT
|
||||||
from ._run_cmd import run_cmd
|
from ._run_cmd import run_cmd
|
||||||
from ._version import __version__
|
from ._version import __version__
|
||||||
from .argparse import ArgumentParser
|
|
||||||
from .console import Console
|
from .console import Console
|
||||||
from .term import term
|
from .term import term
|
||||||
from .themes import ThemeDB
|
from .theme import ThemeDB
|
||||||
|
|
||||||
themes = ThemeDB()
|
themes = ThemeDB()
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from importlib.resources import files
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from rich import box
|
from rich import box
|
||||||
|
@ -16,6 +15,7 @@ from rich.terminal_theme import (
|
||||||
TerminalTheme,
|
TerminalTheme,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from ._themes import THEMES
|
||||||
from .term import term
|
from .term import term
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ class YartsuTheme(TerminalTheme):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def load_theme(cls, themepath: Path, src: str):
|
def load_theme(cls, themepath: Path, src: str):
|
||||||
# theme_file = files("yartsu") / "themes" / f"{name}.json"
|
|
||||||
name = themepath.stem
|
name = themepath.stem
|
||||||
|
|
||||||
with themepath.open("r") as f:
|
with themepath.open("r") as f:
|
||||||
|
@ -70,10 +69,9 @@ class YartsuTheme(TerminalTheme):
|
||||||
|
|
||||||
class ThemeDB:
|
class ThemeDB:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.default = os.getenv("YARTSU_THEME", "cat-mocha")
|
self.default = os.getenv("YARTSU_THEME", "cat-frappe")
|
||||||
self.selected = self.default
|
self.selected = self.default
|
||||||
self.themes = {
|
self.themes = {
|
||||||
**self._load_user_themes(),
|
|
||||||
**self._load_yartsu_themes(),
|
**self._load_yartsu_themes(),
|
||||||
**{
|
**{
|
||||||
"dimmed_monokai": DIMMED_MONOKAI,
|
"dimmed_monokai": DIMMED_MONOKAI,
|
||||||
|
@ -96,14 +94,7 @@ class ThemeDB:
|
||||||
return theme_dir
|
return theme_dir
|
||||||
|
|
||||||
def _load_yartsu_themes(self):
|
def _load_yartsu_themes(self):
|
||||||
return {
|
return {name: YartsuTheme(*colors, src="yartsu") for name, colors in THEMES}
|
||||||
themepath.stem: YartsuTheme.load_theme(themepath, src="yartsu")
|
|
||||||
for themepath in sorted(
|
|
||||||
resource
|
|
||||||
for resource in (files("yartsu") / "themes").iterdir()
|
|
||||||
if resource.is_file()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
def _load_user_themes(self):
|
def _load_user_themes(self):
|
||||||
if (themes_dir := self._user_themes_location()).is_dir():
|
if (themes_dir := self._user_themes_location()).is_dir():
|
|
@ -1 +0,0 @@
|
||||||
{"name": "cat-frappe", "format": "rgb", "foreground": [198, 206, 239], "background": [48, 52, 70], "colors": [[179, 188, 223], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [86, 89, 112]], "bright_colors": [[161, 168, 201], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [67, 70, 90]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "cat-latte", "format": "rgb", "foreground": [76, 79, 105], "background": [239, 241, 245], "colors": [[179, 188, 223], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [86, 89, 112]], "bright_colors": [[161, 168, 201], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [67, 70, 90]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "cat-macchiato", "format": "rgb", "foreground": [197, 207, 245], "background": [36, 39, 58], "colors": [[179, 188, 223], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [86, 89, 112]], "bright_colors": [[161, 168, 201], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [67, 70, 90]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "cat-mocha", "format": "rgb", "foreground": [198, 208, 245], "background": [30, 30, 46], "colors": [[179, 188, 223], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [86, 89, 112]], "bright_colors": [[161, 168, 201], [243, 139, 168], [166, 227, 161], [249, 226, 175], [135, 176, 249], [245, 194, 231], [148, 226, 213], [67, 70, 90]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "dracula", "format": "rgb", "foreground": [248, 248, 242], "background": [40, 42, 54], "colors": [[33, 34, 44], [255, 85, 85], [80, 250, 123], [241, 250, 140], [189, 147, 249], [255, 121, 198], [139, 233, 253], [248, 248, 242]], "bright_colors": [[98, 114, 164], [255, 110, 110], [105, 255, 148], [255, 255, 165], [214, 172, 255], [255, 146, 223], [164, 255, 255], [255, 255, 255]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "gruvbox-dark", "format": "rgb", "foreground": [213, 196, 161], "background": [40, 40, 40], "colors": [[40, 40, 40], [251, 73, 52], [184, 187, 38], [250, 189, 47], [131, 165, 152], [211, 134, 155], [142, 192, 124], [213, 196, 161]], "bright_colors": [[102, 92, 84], [254, 128, 25], [60, 56, 54], [80, 73, 69], [189, 174, 147], [235, 219, 178], [214, 93, 14], [251, 241, 199]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "gruvbox-light", "format": "rgb", "foreground": [80, 73, 69], "background": [251, 241, 199], "colors": [[251, 241, 199], [157, 0, 6], [121, 116, 14], [181, 118, 20], [7, 102, 120], [143, 63, 113], [66, 123, 88], [80, 73, 69]], "bright_colors": [[189, 174, 147], [175, 58, 3], [235, 219, 178], [213, 196, 161], [102, 92, 84], [60, 56, 54], [214, 93, 14], [40, 40, 40]]}
|
|
|
@ -1 +0,0 @@
|
||||||
{"name": "nord", "format": "rgb", "foreground": [216, 222, 233], "background": [46, 52, 64], "colors": [[59, 66, 82], [191, 97, 106], [163, 190, 140], [235, 203, 139], [129, 161, 193], [180, 142, 173], [136, 192, 208], [229, 233, 240]], "bright_colors": [[76, 86, 106], [191, 97, 106], [163, 190, 140], [235, 203, 139], [129, 161, 193], [180, 142, 173], [143, 188, 187], [236, 239, 244]]}
|
|
Loading…
Reference in a new issue