26 lines
566 B
Python
26 lines
566 B
Python
"""Display and UI utilities for nanocode."""
|
|
|
|
import os
|
|
import re
|
|
|
|
# ANSI colors
|
|
RESET = "\033[0m"
|
|
BOLD = "\033[1m"
|
|
DIM = "\033[2m"
|
|
BLUE = "\033[34m"
|
|
CYAN = "\033[36m"
|
|
GREEN = "\033[32m"
|
|
YELLOW = "\033[33m"
|
|
RED = "\033[31m"
|
|
MAGENTA = "\033[35m"
|
|
|
|
|
|
def separator():
|
|
"""Return a horizontal separator line that fits the terminal width."""
|
|
return f"{DIM}{'─' * min(os.get_terminal_size().columns, 80)}{RESET}"
|
|
|
|
|
|
def render_markdown(text):
|
|
"""Convert basic markdown bold syntax to ANSI bold."""
|
|
return re.sub(r"\*\*(.+?)\*\*", f"{BOLD}\\1{RESET}", text)
|