diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 1e368ff7..03d1686d 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -215,8 +215,9 @@ 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_color' : '', - 'cursor_color_fg' : True, + 'cursor_fg_color' : '', + 'cursor_bg_color' : '', + 'cursor_color_default' : True, 'term' : 'xterm-256color', 'colorterm' : 'truecolor', 'font' : 'Mono 10', @@ -844,4 +845,3 @@ def get_layout(self, layout): def set_layout(self, layout, tree): """Set a layout""" self.layouts[layout] = tree - diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 3e157f19..67b5ed59 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1536,8 +1536,8 @@ False 12 - - + + True False 6 @@ -1575,50 +1575,73 @@ - + + Blink + False True - False - Color: - 0 + True + False + 0.5 + True + 0 - 1 + 4 + 2 - - Blink - False + + Use default colors True True False - 0.5 True - + 0 - 2 + 1 2 - + + True + False + 12 + Foreground: + 0 + + + 0 + 2 + + + + + True + False + 12 + Background: + 0 + + + 0 + 3 + + + + True False - 6 - - Foreground - False + True True - False - 0.5 - True - True - + True + False @@ -1626,55 +1649,33 @@ 0 + + + 1 + 2 + + + + + True + False - + True - False - - - False - True - True - False - 0.5 - True - True - cursor_color_foreground_radiobutton - - - - False - True - 0 - - - - - False - True - True - True - center - 0 - - - - False - False - 1 - - + True + True + - True + False True - 1 + 0 1 - 1 + 3 @@ -2032,7 +2033,7 @@ True False - _Text color: + _Foreground: True center foreground_colorbutton @@ -2047,7 +2048,7 @@ True False - _Background color: + _Background: True center background_colorbutton @@ -2548,8 +2549,8 @@ True True False + start True - 0.5 True True @@ -2567,8 +2568,8 @@ True True False + start True - 0.5 True solid_radiobutton @@ -2585,7 +2586,7 @@ True True False - True + start True solid_radiobutton @@ -3112,16 +3113,17 @@ 18 - + True False + start 6 12 True False - Font color: + Foreground: 0 @@ -3264,7 +3266,7 @@ False - False + True 0 @@ -3310,9 +3312,10 @@ - + True False + 12 12 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c35c0d0f..f5055b64 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -498,24 +498,27 @@ def set_profile_values(self, profile): # Cursor blink widget = guiget('cursor_blink') widget.set_active(self.config['cursor_blink']) - # Cursor colour - Radio values - if self.config['cursor_color_fg']: - widget = guiget('cursor_color_foreground_radiobutton') - else: - widget = guiget('cursor_color_custom_radiobutton') - widget.set_active(True) - # Cursor colour - swatch - widget = guiget('cursor_color') - widget.set_sensitive(not self.config['cursor_color_fg']) + # Cursor use default colors + widget = guiget('cursor_color_default_checkbutton') + widget.set_active(self.config['cursor_color_default']) + # Cursor foreground + widget = guiget('cursor_fg_color') + try: + widget.set_color(Gdk.color_parse(self.config['cursor_fg_color'])) + except: + try: + widget.set_color(Gdk.color_parse(self.config['background_color'])) + except: + widget.set_color(Gdk.color_parse('#000000')) + # Cursor background + widget = guiget('cursor_bg_color') try: - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except (ValueError, TypeError): + widget.set_color(Gdk.color_parse(self.config['cursor_bg_color'])) + except: try: - self.config['cursor_color'] = self.config['foreground_color'] - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except ValueError: - self.config['cursor_color'] = "#FFFFFF" - widget.set_color(Gdk.color_parse(self.config['cursor_color'])) + widget.set_color(Gdk.color_parse(self.config['foreground_color'])) + except: + widget.set_color(Gdk.color_parse('#ffffff')) ## Command tab # Login shell @@ -1159,29 +1162,30 @@ def on_custom_command_entry_changed(self, widget): self.config['custom_command'] = widget.get_text() self.config.save() - def on_cursor_color_type_toggled(self, widget): + def on_cursor_color_default_checkbutton_toggled(self, checkbutton): + """Cursor: Use default colors changed""" guiget = self.builder.get_object - customwidget = guiget('cursor_color_custom_radiobutton') - colorwidget = guiget('cursor_color') - - colorwidget.set_sensitive(customwidget.get_active()) - self.config['cursor_color_fg'] = not customwidget.get_active() - - try: - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except (ValueError, TypeError): - try: - self.config['cursor_color'] = self.config['foreground_color'] - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) - except ValueError: - self.config['cursor_color'] = "#FFFFFF" - colorwidget.set_color(Gdk.color_parse(self.config['cursor_color'])) + value = checkbutton.get_active() + guiget('cursor_fg_color').set_sensitive(not value) + guiget('cursor_bg_color').set_sensitive(not value) + + if not value: + self.config['cursor_fg_color'] = color2hex(guiget('cursor_fg_color')) + self.config['cursor_bg_color'] = color2hex(guiget('cursor_bg_color')) + self.config.save() + + self.config['cursor_color_default'] = value + self.config.save() + + def on_cursor_fg_color_color_set(self, widget): + """Cursor foreground color changed""" + self.config['cursor_fg_color'] = color2hex(widget) self.config.save() - def on_cursor_color_color_set(self, widget): - """Cursor colour changed""" - self.config['cursor_color'] = color2hex(widget) + def on_cursor_bg_color_color_set(self, widget): + """Cursor background color changed""" + self.config['cursor_bg_color'] = color2hex(widget) self.config.save() def on_cursor_shape_combobox_changed(self, widget): diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 0226cc1b..7dfd2022 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -837,12 +837,24 @@ def reconfigure(self, _widget=None): def set_cursor_color(self): """Set the cursor color appropriately""" - if self.config['cursor_color_fg']: + if self.config['cursor_color_default']: self.vte.set_color_cursor(None) + self.vte.set_color_cursor_foreground(None) else: - cursor_color = Gdk.RGBA() - cursor_color.parse(self.config['cursor_color']) - self.vte.set_color_cursor(cursor_color) + # foreground + cursor_fg_color = Gdk.RGBA() + if self.config['cursor_fg_color'] == '': + cursor_fg_color.parse(self.config['background_color']) + else: + cursor_fg_color.parse(self.config['cursor_fg_color']) + self.vte.set_color_cursor_foreground(cursor_fg_color) + # background + cursor_bg_color = Gdk.RGBA() + if self.config['cursor_bg_color'] == '': + cursor_bg_color.parse(self.config['foreground_color']) + else: + cursor_bg_color.parse(self.config['cursor_bg_color']) + self.vte.set_color_cursor(cursor_bg_color) def get_window_title(self): """Return the window title"""