diff options
-rw-r--r-- | poezio/windows/base_wins.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py index 6a689067..d6c72912 100644 --- a/poezio/windows/base_wins.py +++ b/poezio/windows/base_wins.py @@ -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 |