removed the computations from splitaxis and do_scrollbar_toggle as they were obsolete. Removed the ctrl-shft-f binding
for fullscreen state. Cleaned up the splitaxis function, and commented it.
This commit is contained in:
parent
6d79b2d80a
commit
3bb1299f47
88
terminator
88
terminator
|
@ -291,16 +291,28 @@ class TerminatorTerm:
|
||||||
if self._scrollbar.get_property ('visible'):
|
if self._scrollbar.get_property ('visible'):
|
||||||
self._scrollbar.hide ()
|
self._scrollbar.hide ()
|
||||||
else:
|
else:
|
||||||
# We need to make the terminal narrower by the width of the scrollbar
|
|
||||||
self._vte.set_size (self._vte.get_column_count () - int(math.ceil(self._scrollbar.allocation.width / self._vte.get_char_width ())), self._vte.get_row_count ())
|
|
||||||
self._scrollbar.show ()
|
self._scrollbar.show ()
|
||||||
|
|
||||||
#keybindings for the individual splited terminals (affects only the
|
#keybindings for the individual splited terminals (affects only the
|
||||||
#the selected terminal)
|
#the selected terminal)
|
||||||
def on_vte_key_press (self, term, event):
|
def on_vte_key_press (self, term, event):
|
||||||
keyname = gtk.gdk.keyval_name (event.keyval)
|
keyname = gtk.gdk.keyval_name (event.keyval)
|
||||||
mask = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
|
|
||||||
|
|
||||||
|
mask = gtk.gdk.CONTROL_MASK
|
||||||
|
if (event.state & mask) == mask:
|
||||||
|
if keyname == 'plus':
|
||||||
|
self.zoom (True)
|
||||||
|
return (True)
|
||||||
|
elif keyname == 'minus':
|
||||||
|
self.zoom (False)
|
||||||
|
return (True)
|
||||||
|
|
||||||
|
# bindings that should be moved to Terminator as they all just call
|
||||||
|
# a function of Terminator. It would be cleaner is TerminatorTerm
|
||||||
|
# has absolutely no reference to Terminator.
|
||||||
|
# N (next) - P (previous) - O (horizontal) - E (vertical) - W (close)
|
||||||
|
|
||||||
|
mask = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
|
||||||
if (event.state & mask) == mask:
|
if (event.state & mask) == mask:
|
||||||
if keyname == 'N':
|
if keyname == 'N':
|
||||||
self.term.go_next (self)
|
self.term.go_next (self)
|
||||||
|
@ -323,11 +335,6 @@ class TerminatorTerm:
|
||||||
elif keyname == 'V':
|
elif keyname == 'V':
|
||||||
self._vte.paste_clipboard ()
|
self._vte.paste_clipboard ()
|
||||||
return (True)
|
return (True)
|
||||||
elif keyname == 'plus':
|
|
||||||
self.zoom (True)
|
|
||||||
return (True)
|
|
||||||
elif keyname == 'minus':
|
|
||||||
self.zoom (False)
|
|
||||||
|
|
||||||
if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')):
|
if keyname and (keyname == 'Tab' or keyname.endswith('_Tab')):
|
||||||
if event.state == gtk.gdk.CONTROL_MASK:
|
if event.state == gtk.gdk.CONTROL_MASK:
|
||||||
|
@ -509,12 +516,13 @@ class Terminator:
|
||||||
def on_destroy_event (self, widget, data=None):
|
def on_destroy_event (self, widget, data=None):
|
||||||
gtk.main_quit ()
|
gtk.main_quit ()
|
||||||
|
|
||||||
#keybindingd for the whole terminal window (affects the main
|
# keybindings for the whole terminal window (affects the main
|
||||||
# windows containing the splited terminals)
|
# windows containing the splited terminals)
|
||||||
def on_key_press (self, window, event):
|
def on_key_press (self, window, event):
|
||||||
""" Callback for the window to determine what to do with special
|
""" Callback for the window to determine what to do with special
|
||||||
keys. Currently handled key-combo's:
|
keys. Currently handled key-combo's:
|
||||||
* CTRL - SHIFT - F : toggle fullscreen state of the window.
|
* F11: toggle fullscreen state of the window.
|
||||||
|
* CTRL - SHIFT - Q: close all terminals
|
||||||
"""
|
"""
|
||||||
keyname = gtk.gdk.keyval_name (event.keyval)
|
keyname = gtk.gdk.keyval_name (event.keyval)
|
||||||
mask = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
|
mask = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
|
||||||
|
@ -524,58 +532,35 @@ class Terminator:
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
if (event.state & mask) == mask:
|
if (event.state & mask) == mask:
|
||||||
if keyname == 'F':
|
|
||||||
self.toggle_fullscreen ()
|
|
||||||
return (True)
|
|
||||||
if keyname == 'Q':
|
if keyname == 'Q':
|
||||||
if not self.on_delete_event (window, gtk.gdk.Event (gtk.gdk.DELETE)):
|
if not self.on_delete_event (window, gtk.gdk.Event (gtk.gdk.DELETE)):
|
||||||
self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY))
|
self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY))
|
||||||
|
|
||||||
|
|
||||||
def splitaxis (self, widget, vert=True):
|
def splitaxis (self, widget, vertical=True):
|
||||||
term2 = TerminatorTerm (self, self.profile)
|
""" Split the provided widget on the horizontal or vertical axis. """
|
||||||
|
|
||||||
|
# create a new terminal and parent pane.
|
||||||
|
terminal = TerminatorTerm (self, self.profile)
|
||||||
|
pane = (vertical) and gtk.VPaned () or gtk.HPaned ()
|
||||||
|
|
||||||
|
# get the parent of the provided terminal
|
||||||
parent = widget.get_box ().get_parent ()
|
parent = widget.get_box ().get_parent ()
|
||||||
|
|
||||||
if vert:
|
|
||||||
pane = gtk.VPaned ()
|
|
||||||
else:
|
|
||||||
pane = gtk.HPaned ()
|
|
||||||
|
|
||||||
# VTE doesn't seem to cope well with being resized by the window manager. I expect I am supposed to send some kind of WINCH, or just generally connect window resizing events to a callback that will often tell vte about the new size. For now, cheat. Badly.
|
|
||||||
cols = widget._vte.get_column_count ()
|
|
||||||
rows = widget._vte.get_row_count ()
|
|
||||||
allowance = widget._scrollbar.allocation.width + pane.style_get_property ('handle-size')
|
|
||||||
|
|
||||||
if vert:
|
|
||||||
width = cols
|
|
||||||
height = (rows / 2) - (allowance / widget._vte.get_char_height ())
|
|
||||||
else:
|
|
||||||
width = (cols / 2) - (allowance / widget._vte.get_char_width ())
|
|
||||||
height = rows
|
|
||||||
|
|
||||||
widget._vte.set_size (width, height)
|
|
||||||
term2._vte.set_size (width, height)
|
|
||||||
|
|
||||||
if isinstance (parent, gtk.Window):
|
if isinstance (parent, gtk.Window):
|
||||||
# We have just one term
|
# We have just one term
|
||||||
if vert:
|
|
||||||
newpos = parent.allocation.height / 2
|
|
||||||
else:
|
|
||||||
newpos = parent.allocation.width / 2
|
|
||||||
|
|
||||||
widget.get_box ().reparent (pane)
|
widget.get_box ().reparent (pane)
|
||||||
|
|
||||||
pane.pack1 (widget.get_box (), True, True)
|
pane.pack1 (widget.get_box (), True, True)
|
||||||
pane.pack2 (term2.get_box (), True, True)
|
pane.pack2 (terminal.get_box (), True, True)
|
||||||
|
|
||||||
parent.add (pane)
|
parent.add (pane)
|
||||||
pane.set_position (newpos)
|
|
||||||
|
position = (vertical) and parent.allocation.height or parent.allocation.width
|
||||||
|
|
||||||
if isinstance (parent, gtk.Paned):
|
if isinstance (parent, gtk.Paned):
|
||||||
# We are inside a split term
|
# We are inside a split term
|
||||||
if vert:
|
position = (vertical) and widget.get_box().allocation.height or widget.get_box().allocation.width
|
||||||
term2._vte.set_size (cols, (rows / 2) - 1)
|
|
||||||
|
|
||||||
if (widget.get_box () == parent.get_child1 ()):
|
if (widget.get_box () == parent.get_child1 ()):
|
||||||
widget.get_box ().reparent (pane)
|
widget.get_box ().reparent (pane)
|
||||||
|
@ -585,16 +570,21 @@ class Terminator:
|
||||||
parent.pack2 (pane, True, True)
|
parent.pack2 (pane, True, True)
|
||||||
|
|
||||||
pane.pack1 (widget.get_box (), True, True)
|
pane.pack1 (widget.get_box (), True, True)
|
||||||
pane.pack2 (term2.get_box (), True, True)
|
pane.pack2 (terminal.get_box (), True, True)
|
||||||
|
|
||||||
|
# show all, set position of the divider
|
||||||
pane.show ()
|
pane.show ()
|
||||||
term2.get_box ().show ()
|
pane.set_position (position / 2)
|
||||||
|
terminal.get_box ().show ()
|
||||||
|
|
||||||
# insert the term reference into the list
|
# insert the term reference into the list
|
||||||
index = self.term_list.index (widget)
|
index = self.term_list.index (widget)
|
||||||
self.term_list.insert (index + 1, term2)
|
self.term_list.insert (index + 1, terminal)
|
||||||
term2._vte.grab_focus ()
|
|
||||||
|
|
||||||
return (term2)
|
# make the new terminal grab the focus
|
||||||
|
terminal._vte.grab_focus ()
|
||||||
|
|
||||||
|
return (terminal)
|
||||||
|
|
||||||
def closeterm (self, widget):
|
def closeterm (self, widget):
|
||||||
parent = widget.get_box ().get_parent ()
|
parent = widget.get_box ().get_parent ()
|
||||||
|
|
Loading…
Reference in New Issue