From ef1768505ccadce82880a707b60b3d5b8f44684a Mon Sep 17 00:00:00 2001 From: Fernando Basso Date: Fri, 10 Dec 2021 07:58:02 -0300 Subject: [PATCH] Add cell width configuration in preferences Currently, we have a setting for changing the line height (cell height), but not for changing cell width (both available in VTE). Depending on the font used, it is useful to have the ability to set a little more space between characters. This commit adds a configuration similar to the existing one for line height, but for character space (cell width scale [1]). Thanks Matt Rose for helping and encouraging me to implement this. 1. https://lazka.github.io/pgi-docs/Vte-2.91/classes/Terminal.html#Vte.Terminal.set_cell_width_scale --- terminatorlib/config.py | 2 + terminatorlib/preferences.glade | 74 ++++++++++++++++++++++++++++++++- terminatorlib/prefseditor.py | 23 ++++++++++ terminatorlib/terminal.py | 2 + 4 files changed, 100 insertions(+), 1 deletion(-) diff --git a/terminatorlib/config.py b/terminatorlib/config.py index b0888a71..2a5e01d8 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -114,6 +114,7 @@ DEFAULTS = { 'smart_copy' : True, 'clear_select_on_copy' : False, 'line_height' : 1.0, + 'cell_width' : 1.0, 'case_sensitive' : True, 'invert_search' : False, 'link_single_click' : False, @@ -245,6 +246,7 @@ DEFAULTS = { 'use_theme_colors' : False, 'bold_is_bright' : False, 'line_height' : 1.0, + 'cell_width' : 1.0, 'focus_on_close' : 'auto', 'force_no_bell' : False, 'cycle_term_tab' : True, diff --git a/terminatorlib/preferences.glade b/terminatorlib/preferences.glade index 2c73f5e5..9eb5b61b 100644 --- a/terminatorlib/preferences.glade +++ b/terminatorlib/preferences.glade @@ -347,6 +347,13 @@ 0.10 0.20 + + 1 + 2 + 1 + 0.10 + 0.20 + 1 0.10 @@ -880,7 +887,7 @@ 36 True - + True False @@ -992,6 +999,71 @@ 4 + + + 100 + True + True + baseline + True + adjustment1 + 0 + 0 + False + bottom + + + + 2 + 1 + + + + + True + False + Cell Width: + 0 + + + 0 + 5 + + + + + 100 + True + True + baseline + True + adjustment_cellwidth + 1 + False + bottom + + + + 2 + 5 + + + + + True + False + 1.0 + right + 5 + 5 + 1 + 1 + + + 1 + 5 + + 100 diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 90e2b04c..d59c80db 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -263,6 +263,17 @@ class PrefsEditor: widget.set_value(lineheightsize) widget = guiget('lineheight_value_label') widget.set_text(str(lineheightsize)) + + # + # Cell Width + # + cellwidthsize = self.config['cell_width'] + cellwidthsize = round(float(cellwidthsize),1) + widget = guiget('cellwidth') + widget.set_value(cellwidthsize) + widget = guiget('cellwidth_value_label') + widget.set_text(str(cellwidthsize)) + # Window geometry hints geomhint = self.config['geometry_hinting'] widget = guiget('wingeomcheck') @@ -1264,6 +1275,18 @@ class PrefsEditor: label_widget = guiget('lineheight_value_label') label_widget.set_text(str(value)) + def on_handlewidth_value_changed(self, widget): + """Handles cell width changed""" + value = widget.get_value() + value = round(float(value), 1) + if value > 2.0: + value = 2.0 + self.config['cell_width'] = value + self.config.save() + guiget = self.builder.get_object + label_widget = guiget('cellwidth_value_label') + label_widget.set_text(str(value)) + def on_focuscombo_changed(self, widget): """Focus type changed""" selected = widget.get_active() diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 6c224b94..69cfa6fe 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -718,6 +718,8 @@ class Terminal(Gtk.VBox): self.vte.set_allow_bold(self.config['allow_bold']) if hasattr(self.vte,'set_cell_height_scale'): self.vte.set_cell_height_scale(self.config['line_height']) + if hasattr(self.vte,'set_cell_width_scale'): + self.vte.set_cell_width_scale(self.config['cell_width']) if hasattr(self.vte, 'set_bold_is_bright'): self.vte.set_bold_is_bright(self.config['bold_is_bright'])