diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 185e0e5b..ed7af823 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -214,7 +214,8 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_color' : '#aaaaaa', + 'cursor_color' : '', + 'cursor_color_fg' : True, 'term' : 'xterm-256color', 'colorterm' : 'truecolor', 'font' : 'Mono 10', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index ac1cabfa..7820e042 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1808,24 +1808,70 @@ True False + 6 - + + Foreground True True - True + False False - 0 - #000000000000 - + True + True + False - False + True 0 - + + True + False + + + True + True + False + False + True + True + cursor_color_foreground_radiobutton + + + + False + True + 0 + + + + + True + True + True + False + 0 + #000000000000 + + + + False + False + 1 + + + + + + + + True + True + 1 + diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 6b8b7f82..80457541 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -450,13 +450,24 @@ class PrefsEditor: # Cursor blink widget = guiget('cursor_blink') widget.set_active(self.config['cursor_blink']) - # Cursor colour + # 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']) try: 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'])) + except (ValueError, TypeError): + 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'])) ## Command tab # Login shell @@ -931,6 +942,26 @@ class PrefsEditor: self.config['custom_command'] = widget.get_text() self.config.save() + def on_cursor_color_type_toggled(self, widget): + 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'])) + self.config.save() + def on_cursor_color_color_set(self, widget): """Cursor colour changed""" self.config['cursor_color'] = color2hex(widget) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index ec4ebebf..bf9d830d 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -780,18 +780,13 @@ class Terminal(Gtk.VBox): def set_cursor_color(self): """Set the cursor color appropriately""" - if self.config['cursor_color'] == self.config['foreground_color']: - try: - self.vte.set_color_cursor(None) - except TypeError: - # FIXME: I think this is only necessary because of - # https://bugzilla.gnome.org/show_bug.cgi?id=614910 - pass - elif self.config['cursor_color'] != '': + if self.config['cursor_color_fg']: + self.vte.set_color_cursor(None) + else: cursor_color = Gdk.RGBA() cursor_color.parse(self.config['cursor_color']) self.vte.set_color_cursor(cursor_color) - + def get_window_title(self): """Return the window title""" return(self.vte.get_window_title() or str(self.command))