diff options
author | Helmut Grohne <helmut@subdivi.de> | 2016-12-19 20:13:21 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2016-12-19 20:13:21 +0100 |
commit | b8fb407411a4e5c0ed52ec33dc3c52e68837e341 (patch) | |
tree | 2176d94dc7c132c99782e534e6384fb6d1019456 | |
parent | 784ef25cd706fbd17270e1711977dfce140255cb (diff) | |
download | tcvt-b8fb407411a4e5c0ed52ec33dc3c52e68837e341.tar.gz |
fix broken color handling
When printing "\e[32mx\e[33mx\e[32mx\e[0m", the expected outcome is that
the first and third x share the same color. Prior to clearing A_COLOR,
the colors would be ORed yielding three different colors. This breaks
e.g. usage with mutt.
-rwxr-xr-x | tcvt.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -90,6 +90,9 @@ class Simple: def attron(self, attr): self.screen.attron(attr) + def attroff(self, attr): + self.screen.attroff(attr) + def clrtoeol(self): self.screen.clrtoeol() @@ -223,6 +226,9 @@ class Columns: def attron(self, attr): self.attrs |= attr + def attroff(self, attr): + self.attrs &= ~attr + def clrtoeol(self): self.curwin.clrtoeol() @@ -603,15 +609,19 @@ class Terminal: self.screen.attrset(0) elif 30 <= code <= 37: self.fg = code - 30 + self.screen.attroff(curses.A_COLOR) self.screen.attron(get_color(self.fg, self.bg)) elif code == 39: self.fg = 7 + self.screen.attroff(curses.A_COLOR) self.screen.attron(get_color(self.fg, self.bg)) elif 40 <= code <= 47: self.bg = code - 40 + self.screen.attroff(curses.A_COLOR) self.screen.attron(get_color(self.fg, self.bg)) elif code == 49: self.bg = 0 + self.screen.attroff(curses.A_COLOR) self.screen.attron(get_color(self.fg, self.bg)) else: raise ValueError("feed esc [ %r m" % code) |