diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-12-04 11:17:11 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-12-04 11:17:11 +0100 |
commit | d8b3da74cac8bbc804928482381a505c82e4bca5 (patch) | |
tree | 068afece7d0bd6b05d852c97f449497ed5e11eea /src | |
parent | update dist (diff) | |
download | xpybar-d8b3da74cac8bbc804928482381a505c82e4bca5.tar.gz xpybar-d8b3da74cac8bbc804928482381a505c82e4bca5.tar.bz2 xpybar-d8b3da74cac8bbc804928482381a505c82e4bca5.tar.xz |
add support for reverse video
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/__main__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/__main__.py b/src/__main__.py index 82b332f..6ff2673 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -246,7 +246,7 @@ class Bar: @param descent:int Extra height under the text on each line @param text:str The text to draw ''' - buf, bc, fc, xx = '', self.background, self.foreground, x + buf, bc, fc, xx, reverse = '', self.background, self.foreground, x, False line_height = ascent + self.font_height + descent esc = False for c in text + '\033[m': @@ -282,7 +282,7 @@ class Bar: fc = ((fc >> 16) & 255, (fc >> 8) & 255, fc & 255) fc = self.create_colour(*fc) fci += 1 - elif b == 0: bc, fc = self.background, self.foreground + elif b == 0: bc, fc, reverse = self.background, self.foreground, False elif b == 39: fc = self.foreground elif b == 49: bc = self.background elif 30 <= b <= 37: fc = self.palette[b - 30] @@ -291,14 +291,17 @@ class Bar: elif 100 <= b <= 107: bc = self.palette[b - 100 + 8] elif b == 38: fci = 1 elif b == 48: bci = 1 + elif b == 7: reverse = True + elif b == 27: reverse = False buf = '' esc = False elif c in ('\033', '\n'): if not buf == '': - self.change_colour(bc) + self.change_colour(bc if not reverse else fc) h = self.font_height + ascent w = self.font_width * len(buf) - self.draw_text(x, y + ascent, descent, buf, colour = (fc, bc), clear = (y - h, line_height)) + colours = (fc, bc) if not reverse else (bc, fc) + self.draw_text(x, y + ascent, descent, buf, colour = colours, clear = (y - h, line_height)) x += w buf = '' if c == '\n': |