Skip to content

Commit d431956

Browse files
committed
fixed use of ctrl+wheel on vte for character size
1 parent 40981d0 commit d431956

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎gtk3/terminal_widget.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def _init_ui(self):
141141
# Clic destro → incolla; Ctrl+Shift+V → incolla esplicito
142142
self._vte.connect("button-press-event", self._on_button_press)
143143
self._vte.connect("key-press-event", self._on_key_press)
144+
145+
# Ctrl+rotella → zoom font
146+
self._vte.add_events(Gdk.EventMask.SCROLL_MASK)
147+
self._vte.connect("scroll-event", self._on_scroll)
144148

145149
def _init_search_bar(self):
146150
self._search_bar = Gtk.SearchBar()
@@ -496,6 +500,27 @@ def _on_button_press(self, terminal, event):
496500
return True # blocca il menu contestuale VTE
497501
return False
498502

503+
def _on_scroll(self, terminal, event):
504+
"""Ctrl+rotella → aumenta/diminuisce dimensione font."""
505+
if not (event.state & Gdk.ModifierType.CONTROL_MASK):
506+
return False
507+
direction = event.direction
508+
if direction == Gdk.ScrollDirection.SMOOTH:
509+
if event.delta_y < 0:
510+
direction = Gdk.ScrollDirection.UP
511+
elif event.delta_y > 0:
512+
direction = Gdk.ScrollDirection.DOWN
513+
else:
514+
return False
515+
if direction == Gdk.ScrollDirection.UP:
516+
self._font_size = min(self._font_size + 1, 72)
517+
elif direction == Gdk.ScrollDirection.DOWN:
518+
self._font_size = max(self._font_size - 1, 4)
519+
else:
520+
return False
521+
self._applica_font()
522+
return True
523+
499524
def _on_key_press(self, terminal, event):
500525
"""Ctrl+Shift+V / Shift+Insert → incolla; Ctrl+F → search bar."""
501526
ctrl = bool(event.state & Gdk.ModifierType.CONTROL_MASK)

0 commit comments

Comments
 (0)