feat: themes
This commit is contained in:
@@ -106,7 +106,9 @@ class CharGrid:
|
||||
def draw_border(self, x: int, y: int, w: int, h: int,
|
||||
weight: BorderWeight = BorderWeight.LIGHT,
|
||||
title: str = "",
|
||||
title_style: CellStyle | None = None) -> None:
|
||||
title_style: CellStyle | None = None,
|
||||
border_chars: dict[str, str] | None = None,
|
||||
title_caps: tuple[str, str] | None = None) -> None:
|
||||
"""Draw a box border. Interior is not cleared.
|
||||
|
||||
Args:
|
||||
@@ -122,7 +124,7 @@ class CharGrid:
|
||||
self._border_counter += 1
|
||||
bid = self._border_counter
|
||||
|
||||
ch = BOX_CHARS[weight]
|
||||
ch = border_chars or BOX_CHARS[weight]
|
||||
border_style = CellStyle()
|
||||
|
||||
# Corners
|
||||
@@ -143,12 +145,14 @@ class CharGrid:
|
||||
|
||||
# Title in top border
|
||||
if title and w > 4:
|
||||
title_text = f" {title} "
|
||||
max_title = w - 4 # leave room for corners + padding
|
||||
lc = title_caps[0] if title_caps else " "
|
||||
rc = title_caps[1] if title_caps else " "
|
||||
title_text = f"{lc}{title}{rc}"
|
||||
max_title = w - 4
|
||||
if len(title_text) > max_title:
|
||||
title_text = title_text[:max_title]
|
||||
|
||||
start_x = x + 2
|
||||
start_x = x + 1
|
||||
ts = title_style or CellStyle(bold=True)
|
||||
self.put_text(start_x, y, title_text, style=ts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user