summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-19 00:35:15 +0200
committerhut <hut@lavabit.com>2010-04-19 00:35:15 +0200
commite3eca034f794a056eb8a0df6b926c94d41fdfdac (patch)
tree1196e658fb8dc6a69515a9ab6821a1a204d72029
parent34414c3eae0c2b4d3a866ad00b2d995bb3312f53 (diff)
downloadranger-e3eca034f794a056eb8a0df6b926c94d41fdfdac.tar.gz
core.actions: abstracted searching strings in filenames
-rw-r--r--ranger/core/actions.py7
-rw-r--r--ranger/gui/widgets/console.py6
2 files changed, 8 insertions, 5 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 5b18fae4..115faaa0 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -14,6 +14,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
+import re
 import shutil
 from os.path import join, isdir
 from os import symlink, getcwd
@@ -275,6 +276,12 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware):
 	# -- Searching
 	# --------------------------
 
+	def search_file(self, text, regexp=True):
+		if isinstance(text, str) and regexp:
+			text = re.compile(text, re.L | re.U | re.I)
+		self.env.last_search = text
+		self.search(order='search')
+
 	def search(self, order=None, forward=True):
 		original_order = order
 		if self.search_forward:
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index c18e7f50..0aa1f147 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -391,11 +391,7 @@ class SearchConsole(Console):
 		self.history = self.histories[SEARCH_HISTORY]
 
 	def execute(self):
-		if self.fm.env.cwd:
-			regexp = re.compile(self.line, re.L | re.U | re.I)
-			self.fm.env.last_search = regexp
-			if self.fm.search(order='search'):
-				self.fm.env.cf = self.fm.env.cwd.pointed_obj
+		self.fm.search_file(self.line, regexp=True)
 		self.close()