Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fast resize keyboard shortcuts #36

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions terminatorlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
'title_inactive_fg_color' : '#000000',
'title_inactive_bg_color' : '#c0bebf',
'inactive_color_offset': 0.8,
'fast_resize_step': 50,
'enabled_plugins' : ['LaunchpadBugURLHandler',
'LaunchpadCodeURLHandler',
'APTURLHandler'],
Expand Down Expand Up @@ -152,6 +153,10 @@
'resize_down' : '<Shift><Control>Down',
'resize_left' : '<Shift><Control>Left',
'resize_right' : '<Shift><Control>Right',
'resize_up_fast' : '<Shift>Up',
'resize_down_fast' : '<Shift>Down',
'resize_left_fast' : '<Shift>Left',
'resize_right_fast': '<Shift>Right',
'move_tab_right' : '<Shift><Control>Page_Down',
'move_tab_left' : '<Shift><Control>Page_Up',
'toggle_zoom' : '<Shift><Control>x',
Expand Down
2 changes: 1 addition & 1 deletion terminatorlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def closeterm(self, widget):
self.terminator.group_hoover()
return(True)

def resizeterm(self, widget, keyname):
def resizeterm(self, widget, keyname, fast = False):
"""Handle a keyboard event requesting a terminal resize"""
raise NotImplementedError('resizeterm')

Expand Down
2 changes: 1 addition & 1 deletion terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def closetab(self, widget, label):
err('Notebook::closetab: child is unknown type %s' % child)
return

def resizeterm(self, widget, keyname):
def resizeterm(self, widget, keyname, fast = False):
"""Handle a keyboard event requesting a terminal resize"""
raise NotImplementedError('resizeterm')

Expand Down
24 changes: 15 additions & 9 deletions terminatorlib/paned.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
self.signals.append({'name': 'resize-term',
'flags': GObject.SignalFlags.RUN_LAST,
'return_type': None,
'param_types': (GObject.TYPE_STRING,)})
'param_types': (GObject.TYPE_STRING, GObject.TYPE_BOOLEAN)})


# pylint: disable-msg=W0613
Expand Down Expand Up @@ -322,16 +322,19 @@ def hoover(self):
parent.replace(self, child)
del(self)

def resizeterm(self, widget, keyname):
def resizeterm(self, widget, keyname, fast = False):
"""Handle a keyboard event requesting a terminal resize"""
if keyname in ['up', 'down'] and isinstance(self, Gtk.VPaned):
# This is a key we can handle
position = self.get_position()

if self.maker.isinstance(widget, 'Terminal'):
fontheight = widget.vte.get_char_height()
if not fast:
if self.maker.isinstance(widget, 'Terminal'):
fontheight = widget.vte.get_char_height()
else:
fontheight = 10
else:
fontheight = 10
fontheight = self.config['fast_resize_step']

if keyname == 'up':
self.set_position(position - fontheight)
Expand All @@ -341,18 +344,21 @@ def resizeterm(self, widget, keyname):
# This is a key we can handle
position = self.get_position()

if self.maker.isinstance(widget, 'Terminal'):
fontwidth = widget.vte.get_char_width()
if not fast:
if self.maker.isinstance(widget, 'Terminal'):
fontwidth = widget.vte.get_char_width()
else:
fontwidth = 10
else:
fontwidth = 10
fontwidth = self.config['fast_resize_step']

if keyname == 'left':
self.set_position(position - fontwidth)
else:
self.set_position(position + fontwidth)
else:
# This is not a key we can handle
self.emit('resize-term', keyname)
self.emit('resize-term', keyname, fast)

def create_layout(self, layout):
"""Apply layout configuration"""
Expand Down
4 changes: 4 additions & 0 deletions terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class PrefsEditor:
'resize_down' : _('Resize the terminal down'),
'resize_left' : _('Resize the terminal left'),
'resize_right' : _('Resize the terminal right'),
'resize_up_fast' : _('Resize the terminal up (faster)'),
'resize_down_fast' : _('Resize the terminal down (faster)'),
'resize_left_fast' : _('Resize the terminal left (faster)'),
'resize_right_fast': _('Resize the terminal right (faster)'),
'move_tab_right' : _('Move the tab right'),
'move_tab_left' : _('Move the tab left'),
'toggle_zoom' : _('Maximize terminal'),
Expand Down
22 changes: 17 additions & 5 deletions terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Terminal(Gtk.VBox):
'maximise': (GObject.SignalFlags.RUN_LAST, None, ()),
'unzoom': (GObject.SignalFlags.RUN_LAST, None, ()),
'resize-term': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
(GObject.TYPE_STRING, GObject.TYPE_BOOLEAN)),
'navigate': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
'tab-change': (GObject.SignalFlags.RUN_LAST, None,
Expand Down Expand Up @@ -1768,16 +1768,28 @@ def key_close_term(self):
self.close()

def key_resize_up(self):
self.emit('resize-term', 'up')
self.emit('resize-term', 'up', False)

def key_resize_down(self):
self.emit('resize-term', 'down')
self.emit('resize-term', 'down', False)

def key_resize_left(self):
self.emit('resize-term', 'left')
self.emit('resize-term', 'left', False)

def key_resize_right(self):
self.emit('resize-term', 'right')
self.emit('resize-term', 'right', False)

def key_resize_up_fast(self):
self.emit('resize-term', 'up', True)

def key_resize_down_fast(self):
self.emit('resize-term', 'down', True)

def key_resize_left_fast(self):
self.emit('resize-term', 'left', True)

def key_resize_right_fast(self):
self.emit('resize-term', 'right', True)

def key_move_tab_right(self):
self.emit('move-tab', 'right')
Expand Down