diff --git a/terminatorlib/config.py b/terminatorlib/config.py index 6ceb8faa..2e1e6104 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -130,6 +130,12 @@ DEFAULTS = { 'paste' : 'v', 'toggle_scrollbar' : 's', 'search' : 'f', + 'page_up' : '', + 'page_down' : '', + 'page_up_half' : '', + 'page_down_half' : '', + 'line_up' : '', + 'line_down' : '', 'close_window' : 'q', 'resize_up' : 'Up', 'resize_down' : 'Down', diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index 6db410cc..fddcc4b4 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -101,6 +101,12 @@ class PrefsEditor: 'paste' : 'Paste clipboard', 'toggle_scrollbar' : 'Show/Hide the scrollbar', 'search' : 'Search terminal scrollback', + 'page_up' : 'Scroll upwards one page', + 'page_down' : 'Scroll downwards one page', + 'page_up_half' : 'Scroll upwards half a page', + 'page_down_half' : 'Scroll downwards half a page', + 'line_up' : 'Scroll upwards one line', + 'line_down' : 'Scroll downwards one line', 'close_window' : 'Close window', 'resize_up' : 'Resize the terminal up', 'resize_down' : 'Resize the terminal down', diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 0d4ff000..00611b42 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1503,6 +1503,23 @@ class Terminal(gtk.VBox): if layout.has_key('title') and layout['title'] != '': self.titlebar.set_custom_string(layout['title']) + def scroll_by_page(self, pages): + """Scroll up or down in pages""" + amount = pages * self.vte.get_adjustment().get_page_increment() + self.scroll_by(int(amount)) + + def scroll_by_line(self, lines): + """Scroll up or down in lines""" + amount = lines * self.vte.get_adjustment().get_step_increment() + self.scroll_by(int(amount)) + + def scroll_by(self, amount): + """Scroll up or down by an amount of lines""" + adjustment = self.vte.get_adjustment() + bottom = adjustment.upper - adjustment.page_size + value = adjustment.get_value() + amount + adjustment.set_value(min(value, bottom)) + # There now begins a great list of keyboard event handlers def key_zoom_in(self): self.zoom_in() @@ -1718,6 +1735,24 @@ class Terminal(gtk.VBox): dialog.destroy() return + def key_page_up(self): + self.scroll_by_page(-1) + + def key_page_down(self): + self.scroll_by_page(1) + + def key_page_up_half(self): + self.scroll_by_page(-0.5) + + def key_page_down_half(self): + self.scroll_by_page(0.5) + + def key_line_up(self): + self.scroll_by_line(-1) + + def key_line_down(self): + self.scroll_by_line(1) + # End key events gobject.type_register(Terminal)