mathy/pi_finder/ui/colors.py
2025-11-05 12:20:31 +01:00

39 lines
1.1 KiB
Python

from __future__ import annotations
import curses
class UIColors:
"""Shared color palette for the π dashboard."""
HEADER = 1
SEPARATOR = 2
NUMBER = 3
STATUS = 4
WARNING = 5
SUCCESS = 6
METRIC = 7
@classmethod
def setup(cls) -> None:
if not curses.has_colors():
return
curses.start_color()
curses.use_default_colors()
curses.init_pair(cls.HEADER, curses.COLOR_CYAN, -1)
curses.init_pair(cls.SEPARATOR, curses.COLOR_BLUE, -1)
curses.init_pair(cls.NUMBER, curses.COLOR_WHITE, -1)
curses.init_pair(cls.STATUS, curses.COLOR_MAGENTA, -1)
curses.init_pair(cls.WARNING, curses.COLOR_RED, -1)
curses.init_pair(cls.SUCCESS, curses.COLOR_GREEN, -1)
curses.init_pair(cls.METRIC, curses.COLOR_YELLOW, -1)
@staticmethod
def style(pair: int, *, bold: bool = False, dim: bool = False) -> int:
attr = curses.color_pair(pair)
if bold:
attr |= curses.A_BOLD
if dim:
attr |= curses.A_DIM
return attr