Skip to content

Commit

Permalink
Make Attribute.NORMAL clean up all other attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiderfelipe committed Dec 7, 2021
1 parent 7cebadb commit 26ff507
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cusser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class Cusser:
)

_ON_ATTR_MAP = {
Attribute.NORMAL: curses.A_NORMAL,
Attribute.BOLD: curses.A_BOLD,
Attribute.DIM: curses.A_DIM,
Attribute.ITALIC: curses.A_ITALIC,
Expand Down Expand Up @@ -100,10 +99,12 @@ def addstr(self, text: Text) -> None:

def _set_attribute(self, attribute: Attribute) -> None:
"""Set the current attribute."""
if attribute == Attribute.NORMAL:
self._set_color(ColorRole.FOREGROUND, None)
self._set_color(ColorRole.BACKGROUND, None)
return self.window.attrset(curses.A_NORMAL)

if attribute in self._ON_ATTR_MAP:
if attribute == Attribute.NORMAL:
self._set_color(ColorRole.FOREGROUND, None)
self._set_color(ColorRole.BACKGROUND, None)
return self.window.attron(self._ON_ATTR_MAP[attribute])

if attribute in self._OFF_ATTR_MAP:
Expand Down

0 comments on commit 26ff507

Please sign in to comment.