From 31f429a71fb493defbc96ae882d22f530aaa4158 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Fri, 13 Aug 2021 17:27:47 +0200 Subject: [PATCH 1/6] Changed cursor customization GUI --- terminatorlib/preferences.glade | 126 ++++++++++++++++---------------- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 3e157f19..16f02c2c 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1536,8 +1536,8 @@ False 12 - - + + True False 6 @@ -1574,18 +1574,6 @@ 0 - - - True - False - Color: - 0 - - - 0 - 1 - - Blink @@ -1599,26 +1587,59 @@ 0 - 2 + 4 2 - + + Use default colors + True + True + False + True + + + 0 + 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 +1647,32 @@ 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 From bc3b64570eed6cc2b9cbcd68fd3062c50e5b38f8 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Fri, 13 Aug 2021 17:58:48 +0200 Subject: [PATCH 2/6] Removed inconsistencies: Text/Font color -> Foreground + fixed missing margin --- terminatorlib/preferences.glade | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 16f02c2c..d06a95fe 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -2030,7 +2030,7 @@ True False - _Text color: + _Foreground: True center foreground_colorbutton @@ -2045,7 +2045,7 @@ True False - _Background color: + _Background: True center background_colorbutton @@ -2546,8 +2546,8 @@ True True False + start True - 0.5 True True @@ -2565,8 +2565,8 @@ True True False + start True - 0.5 True solid_radiobutton @@ -2583,7 +2583,7 @@ True True False - True + start True solid_radiobutton @@ -3110,16 +3110,17 @@ 18 - + True False + start 6 12 True False - Font color: + Foreground: 0 @@ -3262,7 +3263,7 @@ False - False + True 0 @@ -3308,9 +3309,10 @@ - + True False + 12 12 From ee823a9cc9faca0af9011ab0c20acc0eeada8b65 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 14 Aug 2021 15:14:02 +0200 Subject: [PATCH 3/6] Custom foreground color for cursor (GUI not implemented yet) --- terminatorlib/config.py | 6 +++--- terminatorlib/terminal.py | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 1e368ff7..7c24f59e 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -215,8 +215,9 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_color' : '', - 'cursor_color_fg' : True, + 'cursor_fg_color' : '#000000', + 'cursor_bg_color' : '#ffffff', + 'cursor_color_default' : True, 'term' : 'xterm-256color', 'colorterm' : 'truecolor', 'font' : 'Mono 10', @@ -844,4 +845,3 @@ class ConfigBase(Borg): def set_layout(self, layout, tree): """Set a layout""" self.layouts[layout] = tree - diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 0226cc1b..d2cca46a 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -837,12 +837,18 @@ class Terminal(Gtk.VBox): 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() + cursor_fg_color.parse(self.config['cursor_fg_color']) + self.vte.set_color_cursor_foreground(cursor_fg_color) + # background + cursor_bg_color = Gdk.RGBA() + 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""" From eae7dcca3d425bc629fd7692a6ded67b2ddd7263 Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 14 Aug 2021 16:45:18 +0200 Subject: [PATCH 4/6] Make the GUI work --- terminatorlib/config.py | 4 +- terminatorlib/preferences.glade | 5 ++- terminatorlib/prefseditor.py | 69 ++++++++++++++++----------------- 3 files changed, 40 insertions(+), 38 deletions(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 7c24f59e..03d1686d 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -215,8 +215,8 @@ DEFAULTS = { 'color_scheme' : 'grey_on_black', 'cursor_blink' : True, 'cursor_shape' : 'block', - 'cursor_fg_color' : '#000000', - 'cursor_bg_color' : '#ffffff', + 'cursor_fg_color' : '', + 'cursor_bg_color' : '', 'cursor_color_default' : True, 'term' : 'xterm-256color', 'colorterm' : 'truecolor', diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index d06a95fe..67b5ed59 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -1592,12 +1592,13 @@ - + Use default colors True True False True + 0 @@ -1640,6 +1641,7 @@ True True True + False @@ -1662,6 +1664,7 @@ True True True + False diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index c35c0d0f..5f195d63 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -498,24 +498,27 @@ class PrefsEditor: # 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_color'])) - except (ValueError, TypeError): + widget.set_color(Gdk.color_parse(self.config['cursor_fg_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['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_bg_color'])) + except: + try: + 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,25 @@ class PrefsEditor: 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) + + self.config['cursor_color_default'] = value self.config.save() - def on_cursor_color_color_set(self, widget): - """Cursor colour changed""" - self.config['cursor_color'] = color2hex(widget) + 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_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): From 880a15d5d39c8a027e7580d8cddb79a9d595176f Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 14 Aug 2021 17:07:00 +0200 Subject: [PATCH 5/6] Make terminal cursor colors fallback to foreground & background --- terminatorlib/terminal.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index d2cca46a..7dfd2022 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -843,11 +843,17 @@ class Terminal(Gtk.VBox): else: # foreground cursor_fg_color = Gdk.RGBA() - cursor_fg_color.parse(self.config['cursor_fg_color']) + 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() - cursor_bg_color.parse(self.config['cursor_bg_color']) + 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): From 9ded8988adfcbf10863a050db08f77a760d8062e Mon Sep 17 00:00:00 2001 From: Vulcalien Date: Sat, 14 Aug 2021 17:10:38 +0200 Subject: [PATCH 6/6] When "Use default colors" is unchecked, save the current values --- terminatorlib/prefseditor.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 5f195d63..f5055b64 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -1170,6 +1170,11 @@ class PrefsEditor: 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()