Merge feature from nanikata. Closes LP#332267

This commit is contained in:
Stephen Boddy 2013-07-14 21:01:58 +02:00
parent eababae92a
commit d271137675
3 changed files with 47 additions and 0 deletions

View File

@ -130,6 +130,12 @@ DEFAULTS = {
'paste' : '<Shift><Control>v', 'paste' : '<Shift><Control>v',
'toggle_scrollbar' : '<Shift><Control>s', 'toggle_scrollbar' : '<Shift><Control>s',
'search' : '<Shift><Control>f', 'search' : '<Shift><Control>f',
'page_up' : '',
'page_down' : '',
'page_up_half' : '',
'page_down_half' : '',
'line_up' : '',
'line_down' : '',
'close_window' : '<Shift><Control>q', 'close_window' : '<Shift><Control>q',
'resize_up' : '<Shift><Control>Up', 'resize_up' : '<Shift><Control>Up',
'resize_down' : '<Shift><Control>Down', 'resize_down' : '<Shift><Control>Down',

View File

@ -101,6 +101,12 @@ class PrefsEditor:
'paste' : 'Paste clipboard', 'paste' : 'Paste clipboard',
'toggle_scrollbar' : 'Show/Hide the scrollbar', 'toggle_scrollbar' : 'Show/Hide the scrollbar',
'search' : 'Search terminal scrollback', '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', 'close_window' : 'Close window',
'resize_up' : 'Resize the terminal up', 'resize_up' : 'Resize the terminal up',
'resize_down' : 'Resize the terminal down', 'resize_down' : 'Resize the terminal down',

View File

@ -1503,6 +1503,23 @@ class Terminal(gtk.VBox):
if layout.has_key('title') and layout['title'] != '': if layout.has_key('title') and layout['title'] != '':
self.titlebar.set_custom_string(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 # There now begins a great list of keyboard event handlers
def key_zoom_in(self): def key_zoom_in(self):
self.zoom_in() self.zoom_in()
@ -1718,6 +1735,24 @@ class Terminal(gtk.VBox):
dialog.destroy() dialog.destroy()
return 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 # End key events
gobject.type_register(Terminal) gobject.type_register(Terminal)