summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-01 22:07:44 +0100
committerhut <hut@lavabit.com>2010-01-01 22:07:44 +0100
commit75c3e884715b69e7771086a873606c1fafad7d0c (patch)
treee7bc8b2e45bec723bb83adfe8103aefc8ea429f9
parentb39fcc5f0ce25fada206b9ee1df53a1fb9cb27cb (diff)
downloadranger-75c3e884715b69e7771086a873606c1fafad7d0c.tar.gz
keys: improved/fixed bindings for pager
-rw-r--r--ranger/defaults/keys.py11
-rw-r--r--ranger/ext/accumulator.py11
-rw-r--r--ranger/gui/widgets/pager.py7
-rw-r--r--ranger/keyapi.py12
4 files changed, 28 insertions, 13 deletions
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 805287bf..49777656 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -243,9 +243,14 @@ def initialize_embedded_pager_commands(command_list):
 	bind, hint = make_abbreviations(command_list)
 
 	bind('j', KEY_DOWN, nwrap.move(relative=1))
-	bind('k', KEY_DOWN, nwrap.move(relative=-1))
-	bind('gg', KEY_DOWN, nwrap.move(absolute=0))
-	bind('G', KEY_DOWN, nwrap.move(absolute=-1))
+	bind('k', KEY_UP, nwrap.move(relative=-1))
+	bind('gg', KEY_HOME, nwrap.move(absolute=0))
+	bind('G', KEY_END, nwrap.move(absolute=-1))
+	bind('J', ctrl('d'), nwrap.move(relative=0.5, pages=True))
+	bind('K', ctrl('u'), nwrap.move(relative=-0.5, pages=True))
+	bind(KEY_NPAGE, ctrl('f'), nwrap.move(relative=1, pages=True))
+	bind(KEY_PPAGE, ctrl('b'), nwrap.move(relative=-1, pages=True))
+	bind('E', fm.edit_file())
 
 	bind('h', wdg.move_horizontal(relative=-4))
 	bind('l', wdg.move_horizontal(relative=4))
diff --git a/ranger/ext/accumulator.py b/ranger/ext/accumulator.py
index c0da8afb..6513bee2 100644
--- a/ranger/ext/accumulator.py
+++ b/ranger/ext/accumulator.py
@@ -3,7 +3,7 @@ class Accumulator(object):
 		self.pointer = 0
 		self.pointed_obj = None
 
-	def move(self, relative=0, absolute=None):
+	def move(self, relative=0, absolute=None, pages=False):
 		i = self.pointer
 		lst = self.get_list()
 		if not lst:
@@ -16,8 +16,11 @@ class Accumulator(object):
 			else:
 				i = absolute
 
-		if isinstance(relative, int):
+		if pages:
+			i += relative * self.get_height()
+		else:
 			i += relative
+		i = int(i)
 
 		if i >= length:
 			i = length - 1
@@ -94,3 +97,7 @@ class Accumulator(object):
 	def get_list(self):
 		"""OVERRIDE THIS"""
 		return []
+
+	def get_height(self):
+		"""OVERRIDE THIS"""
+		return 25
diff --git a/ranger/gui/widgets/pager.py b/ranger/gui/widgets/pager.py
index ab6220db..2d77a2d0 100644
--- a/ranger/gui/widgets/pager.py
+++ b/ranger/gui/widgets/pager.py
@@ -60,13 +60,16 @@ class Pager(Widget):
 					pass
 			self.need_redraw = False
 	
-	def move(self, relative=0, absolute=None):
+	def move(self, relative=0, absolute=None, pages=False):
 		i = self.scroll_begin
 		if isinstance(absolute, int):
 			i = absolute
 
-		if isinstance(relative, int):
+		if pages:
+			i += relative * self.hei
+		else:
 			i += relative
+		i = int(i)
 
 		length = len(self.lines) - self.hei - 1
 		if i >= length:
diff --git a/ranger/keyapi.py b/ranger/keyapi.py
index 2159660a..56552584 100644
--- a/ranger/keyapi.py
+++ b/ranger/keyapi.py
@@ -45,20 +45,20 @@ wdg = Wrapper('wdg')
 # Another wrapper for common actions which use a numerical argument:
 class nwrap(object):
 	@staticmethod
-	def move(relative=0, absolute=None):
+	def move(relative=0, absolute=None, pages=False):
 		if absolute is None:
 			def fnc(arg):
 				if arg.n is not None:
 					if relative >= 0:
-						arg.wdg.move(relative=arg.n)
+						arg.wdg.move(relative=arg.n, pages=pages)
 					else:
-						arg.wdg.move(relative=-arg.n)
+						arg.wdg.move(relative=-arg.n, pages=pages)
 				else:
-					arg.wdg.move(relative=relative)
+					arg.wdg.move(relative=relative, pages=pages)
 		else:
 			def fnc(arg):
 				if arg.n is not None:
-					arg.wdg.move(absolute=arg.n, relative=relative)
+					arg.wdg.move(absolute=arg.n, relative=relative, pages=pages)
 				else:
-					arg.wdg.move(absolute=absolute, relative=relative)
+					arg.wdg.move(absolute=absolute, relative=relative, pages=pages)
 		return fnc