summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2011-09-30 21:11:48 +0200
committerhut <hut@lavabit.com>2011-09-30 21:21:59 +0200
commitfeb6713296c1e95ad22d13128ee7cc296a548940 (patch)
treec3f87cc2f4aed3f7566de5109c8a15067d18a59d /ranger
parent9f58095efd4aeaa363aa4df10a0546ece7f81c95 (diff)
downloadranger-feb6713296c1e95ad22d13128ee7cc296a548940.tar.gz
implemented numeral arguments to keybindings
Diffstat (limited to 'ranger')
-rw-r--r--ranger/api/commands.py7
-rw-r--r--ranger/core/actions.py4
-rw-r--r--ranger/defaults/commands.py1
-rw-r--r--ranger/defaults/rc.conf16
-rw-r--r--ranger/gui/ui.py3
5 files changed, 19 insertions, 12 deletions
diff --git a/ranger/api/commands.py b/ranger/api/commands.py
index 01f47732..f034605d 100644
--- a/ranger/api/commands.py
+++ b/ranger/api/commands.py
@@ -91,11 +91,13 @@ class Command(FileManagerAware):
 	name = None
 	allow_abbrev = True
 	resolve_macros = True
+	quantifier = None
 	_shifted = 0
 
-	def __init__(self, line):
+	def __init__(self, line, quantifier=None):
 		self.line = line
 		self.args = line.split()
+		self.quantifier = quantifier
 
 	def execute(self):
 		"""Override this"""
@@ -285,6 +287,9 @@ class FunctionCommand(Command):
 			else:
 				keywords[arg[:equal_sign]] = value
 
+		if self.quantifier is not None:
+			keywords['narg'] = self.quantifier
+
 		try:
 			return self._based_function(*args, **keywords)
 		except TypeError:
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 741b847f..6b879428 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -92,7 +92,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 		"""Open the console if the current UI supports that"""
 		self.ui.open_console(string, prompt=prompt, position=position)
 
-	def execute_console(self, string='', wildcards=[]):
+	def execute_console(self, string='', wildcards=[], quantifier=None):
 		"""Execute a command for the console"""
 		command_name = string.split()[0]
 		try:
@@ -108,7 +108,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 					macros['any'] = macros['any0']
 				string = self.substitute_macros(string, additional=macros)
 			try:
-				cmd_class(string).execute()
+				cmd_class(string, quantifier=quantifier).execute()
 			except Exception as error:
 				self.notify(error)
 
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index 78a406a7..12b56ed8 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -669,6 +669,7 @@ class eval_(Command):
 		fm = self.fm
 		cmd = self.fm.execute_console
 		p = fm.notify
+		quantifier = self.quantifier
 		try:
 			try:
 				result = eval(code)
diff --git a/ranger/defaults/rc.conf b/ranger/defaults/rc.conf
index e5b4ef30..aeaaa230 100644
--- a/ranger/defaults/rc.conf
+++ b/ranger/defaults/rc.conf
@@ -122,14 +122,14 @@ map ya copy mode=add
 map yr copy mode=remove
 
 # Temporary workarounds
-map dgg eval fm.cut(dirarg=dict(to=0))
-map dG  eval fm.cut(dirarg=dict(to=-1))
-map dj  eval fm.cut(dirarg=dict(down=1))
-map dk  eval fm.cut(dirarg=dict(up=1))
-map ygg eval fm.copy(dirarg=dict(to=0))
-map yG  eval fm.copy(dirarg=dict(to=-1))
-map yj  eval fm.copy(dirarg=dict(down=1))
-map yk  eval fm.copy(dirarg=dict(up=1))
+map dgg eval fm.cut(dirarg=dict(to=0), narg=quantifier)
+map dG  eval fm.cut(dirarg=dict(to=-1), narg=quantifier)
+map dj  eval fm.cut(dirarg=dict(down=1), narg=quantifier)
+map dk  eval fm.cut(dirarg=dict(up=1), narg=quantifier)
+map ygg eval fm.copy(dirarg=dict(to=0), narg=quantifier)
+map yG  eval fm.copy(dirarg=dict(to=-1), narg=quantifier)
+map yj  eval fm.copy(dirarg=dict(down=1), narg=quantifier)
+map yk  eval fm.copy(dirarg=dict(up=1), narg=quantifier)
 
 # Searching
 map /  console search 
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 3c3bbca8..89493618 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -151,7 +151,8 @@ class UI(DisplayableContainer):
 		if keybuffer.result is not None:
 			try:
 				self.fm.execute_console(keybuffer.result,
-						wildcards=keybuffer.wildcards)
+						wildcards=keybuffer.wildcards,
+						quantifier=keybuffer.quantifier)
 			finally:
 				if keybuffer.finished_parsing:
 					keybuffer.clear()
f='#n359'>359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400