about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSören Tempel <soeren+git@soeren-tempel.net>2021-05-25 12:02:00 +0200
committerSören Tempel <soeren+git@soeren-tempel.net>2021-05-25 12:02:00 +0200
commitc0d6cc482f33a38d29292f88a73fcf00e0d77f36 (patch)
tree570cbb5930c790c188307a0ff18a131e1d61cb24
parente72f61fb3af060eb018d17fd0d324741503c15ed (diff)
terminal: Use single case distinction to set hscroll/wrapmode
Makes the code a bit more readable IMHO. Also add a comment explaining
why we can't use use automatic horizontal scrolling in the first place.
-rw-r--r--saneterm/terminal.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/saneterm/terminal.py b/saneterm/terminal.py
index fcfe0e9..c3ae3cf 100644
--- a/saneterm/terminal.py
+++ b/saneterm/terminal.py
@@ -105,11 +105,21 @@ class Terminal(Gtk.Window):
         self.hist.close()
 
     def update_wrapmode(self):
-        mode = Gtk.WrapMode.WORD_CHAR if self.config['wordwrap'] else Gtk.WrapMode.NONE
-        self.termview.set_wrap_mode(mode)
+        # XXX: Need to set hscroll mode explicitly and cannot rely on
+        # AUTOMATIC, as hypenation may introduce a horizontal scrollbar
+        # otherwise. With Gtk+4.0 we can disable hypenation explicitly.
+        # See: https://gitlab.gnome.org/GNOME/gtk/-/issues/2384
+        if self.config['wordwrap']:
+            wmode = Gtk.WrapMode.WORD_CHAR
+            hscroll = Gtk.PolicyType.NEVER
+        else:
+            wmode = Gtk.WrapMode.NONE
+            hscroll = Gtk.PolicyType.AUTOMATIC
+
+        self.termview.set_wrap_mode(wmode)
 
-        scroll_policy = Gtk.PolicyType.NEVER if self.config['wordwrap'] else Gtk.PolicyType.AUTOMATIC
-        self.scroll.set_policy(scroll_policy, self.scroll.get_policy()[1])
+        _, vscroll = self.scroll.get_policy()
+        self.scroll.set_policy(hscroll, vscroll)
 
     def update_size(self, widget, rect):
         # PTY must already be initialized