Commit a5ef6ec9 authored by mathieui's avatar mathieui

Add a context manager in Win for colored text

parent 41127e50
......@@ -77,6 +77,19 @@ class Win:
# of the screen.
pass
@contextmanager
def colored_text(self, color: Optional[Tuple]=None, attr: Optional[int]=None):
"""Context manager which sets up an attr/color when inside"""
if attr is None:
if color is not None:
attr = to_curses_attr(color)
else:
yield None
return
self._win.attron(attr)
yield None
self._win.attroff(attr)
def addstr(self, *args) -> None:
"""
Safe call to addstr
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment