35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import curses
|
|
from .big_digits import BIG_DIGITS
|
|
|
|
|
|
def init_colors():
|
|
"""Initialize color pairs matching specification"""
|
|
curses.start_color()
|
|
curses.use_default_colors()
|
|
# Green text on black background (primary color)
|
|
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
|
|
# Highlight color (yellow)
|
|
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
|
|
# Error color (red)
|
|
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
|
|
|
|
def draw_error(stdscr, error_message):
|
|
"""Draw error message following specification"""
|
|
height, width = stdscr.getmaxyx()
|
|
|
|
# Truncate message if too long
|
|
error_message = error_message[:width-4]
|
|
|
|
error_x = max(0, width // 2 - len(error_message) // 2)
|
|
error_y = height - 4 # Show near bottom of screen
|
|
|
|
stdscr.attron(curses.color_pair(3) | curses.A_BOLD)
|
|
stdscr.addstr(error_y, error_x, error_message)
|
|
stdscr.attroff(curses.color_pair(3) | curses.A_BOLD)
|
|
|
|
def draw_big_digit(stdscr, y, x, digit):
|
|
"""Draw a big digit using predefined patterns"""
|
|
patterns = BIG_DIGITS[digit]
|
|
for i, line in enumerate(patterns):
|
|
stdscr.addstr(y + i, x, line)
|