summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-12-13 18:12:53 +0100
committerhut <hut@lavabit.com>2010-12-13 18:13:50 +0100
commitea45cca99102e2c0c2629c7129b2970e8a85a5fe (patch)
treea36e00dd87ec7f6e9ad153bd2fd6a7366c24e12f
parentee7f171116b57514e2ce11cb3b7932a22478be79 (diff)
downloadranger-ea45cca99102e2c0c2629c7129b2970e8a85a5fe.tar.gz
defaults.commands: Added search_inc(remental)
-rw-r--r--ranger/core/actions.py8
-rw-r--r--ranger/defaults/commands.py5
-rw-r--r--ranger/fsobject/directory.py10
3 files changed, 14 insertions, 9 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 51a70844..75f85baf 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -368,16 +368,16 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	# -- Searching
 	# --------------------------
 
-	def search_file(self, text, regexp=True):
+	def search_file(self, text, offset=1, regexp=True):
 		if isinstance(text, str) and regexp:
 			try:
 				text = re.compile(text, re.L | re.U | re.I)
 			except:
 				return False
 		self.env.last_search = text
-		self.search(order='search')
+		self.search(order='search', offset=offset)
 
-	def search(self, order=None, forward=True):
+	def search(self, order=None, offset=1, forward=True):
 		original_order = order
 		if self.search_forward:
 			direction = bool(forward)
@@ -401,7 +401,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 			elif order == 'tag':
 				fnc = lambda x: x.realpath in self.tags
 
-			return self.env.cwd.search_fnc(fnc=fnc, forward=forward)
+			return self.env.cwd.search_fnc(fnc=fnc, offset=offset, forward=forward)
 
 		elif order in ('size', 'mimetype', 'ctime'):
 			cwd = self.env.cwd
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index 6258d30d..9861ddeb 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -91,6 +91,11 @@ class search(Command):
 		self.fm.search_file(parse(self.line).rest(1), regexp=True)
 
 
+class search_inc(Command):
+	def quick(self):
+		self.fm.search_file(parse(self.line).rest(1), regexp=True, offset=0)
+
+
 class shell(Command):
 	def execute(self):
 		line = parse(self.line)
diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py
index 5d1a89a0..c5c1e6a9 100644
--- a/ranger/fsobject/directory.py
+++ b/ranger/fsobject/directory.py
@@ -339,18 +339,18 @@ class Directory(FileSystemObject, Accumulator, Loadable, SettingsAware):
 
 		Accumulator.move_to_obj(self, arg, attr='path')
 
-	def search_fnc(self, fnc, forward=True):
+	def search_fnc(self, fnc, offset=1, forward=True):
 		if not hasattr(fnc, '__call__'):
 			return False
 
 		length = len(self)
 
 		if forward:
-			generator = ((self.pointer + (x + 1)) % length \
-					for x in range(length-1))
+			generator = ((self.pointer + (x + offset)) % length \
+					for x in range(length - 1))
 		else:
-			generator = ((self.pointer - (x + 1)) % length \
-					for x in range(length-1))
+			generator = ((self.pointer - (x + offset)) % length \
+					for x in range(length - 1))
 
 		for i in generator:
 			_file = self.files[i]