From 80b157ee339f7e65b53c7c5f1d6321878135daee Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 29 Nov 2015 05:27:59 +0100 Subject: [PATCH] Add dimming for 256 colour palettes --- terminatorlib/terminal.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 4ea73db7..75bd7fb2 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -722,17 +722,35 @@ class Terminal(Gtk.VBox): getattr(self.fgcolor_inactive, "blue"))) colors = self.config['palette'].split(':') self.palette_active = [] - self.palette_inactive = [] for color in colors: if color: newcolor = Gdk.RGBA() newcolor.parse(color) - newcolor_inactive = newcolor.copy() - for bit in ['red', 'green', 'blue']: - setattr(newcolor_inactive, bit, - getattr(newcolor_inactive, bit) * factor) self.palette_active.append(newcolor) - self.palette_inactive.append(newcolor_inactive) + if len(colors) == 16: + # RGB values for indices 16..255 copied from vte source in order to dim them + shades = [0, 95, 135, 175, 215, 255] + for r in xrange(0, 6): + for g in xrange(0, 6): + for b in xrange(0, 6): + newcolor = Gdk.RGBA() + setattr(newcolor, "red", shades[r] / 255.0) + setattr(newcolor, "green", shades[g] / 255.0) + setattr(newcolor, "blue", shades[b] / 255.0) + self.palette_active.append(newcolor) + for y in xrange(8, 248, 10): + newcolor = Gdk.RGBA() + setattr(newcolor, "red", y / 255.0) + setattr(newcolor, "green", y / 255.0) + setattr(newcolor, "blue", y / 255.0) + self.palette_active.append(newcolor) + self.palette_inactive = [] + for color in self.palette_active: + newcolor = Gdk.RGBA() + for bit in ['red', 'green', 'blue']: + setattr(newcolor, bit, + getattr(color, bit) * factor) + self.palette_inactive.append(newcolor) if self.terminator.last_focused_term == self: self.vte.set_colors(self.fgcolor_active, self.bgcolor, self.palette_active)