mirror of
https://github.com/pdxlocations/contact.git
synced 2026-07-05 01:12:06 +02:00
d5a6a0462f
* init * customize colors * fix splash frame * cleanup
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import curses
|
|
import globals
|
|
|
|
COLOR_MAP = {
|
|
"black": curses.COLOR_BLACK,
|
|
"red": curses.COLOR_RED,
|
|
"green": curses.COLOR_GREEN,
|
|
"yellow": curses.COLOR_YELLOW,
|
|
"blue": curses.COLOR_BLUE,
|
|
"magenta": curses.COLOR_MAGENTA,
|
|
"cyan": curses.COLOR_CYAN,
|
|
"white": curses.COLOR_WHITE
|
|
}
|
|
|
|
def setup_colors():
|
|
"""
|
|
Initialize curses color pairs based on the COLOR_CONFIG.
|
|
"""
|
|
curses.start_color()
|
|
for idx, (category, (fg_name, bg_name)) in enumerate(globals.COLOR_CONFIG.items(), start=1):
|
|
fg = COLOR_MAP.get(fg_name.lower(), curses.COLOR_WHITE)
|
|
bg = COLOR_MAP.get(bg_name.lower(), curses.COLOR_BLACK)
|
|
curses.init_pair(idx, fg, bg)
|
|
globals.COLOR_CONFIG[category] = idx
|
|
|
|
|
|
def get_color(category, bold=False, reverse=False, underline=False):
|
|
"""
|
|
Retrieve a curses color pair with optional attributes.
|
|
"""
|
|
color = curses.color_pair(globals.COLOR_CONFIG[category])
|
|
if bold:
|
|
color |= curses.A_BOLD
|
|
if reverse:
|
|
color |= curses.A_REVERSE
|
|
if underline:
|
|
color |= curses.A_UNDERLINE
|
|
return color |