about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-14 00:19:00 +0200
committerhut <hut@lavabit.com>2010-04-14 00:19:00 +0200
commit19c1fa4f622ffd1597943f0005ba58a30b170bb4 (patch)
tree42b64e4f511fd4bd383eab35fd0369bc2c5bb243 /ranger
parent36352437d24d55c49c5daad3d64a217728b9d094 (diff)
parente07d8797bf8b1029205f48e65241a4819768f310 (diff)
downloadranger-19c1fa4f622ffd1597943f0005ba58a30b170bb4.tar.gz
Merge branch 'master' into devel
Conflicts:
	ranger/gui/widgets/console.py
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__main__.py6
-rw-r--r--ranger/core/environment.py3
-rw-r--r--ranger/core/fm.py3
-rw-r--r--ranger/defaults/keys.py4
-rw-r--r--ranger/gui/widgets/console.py12
-rw-r--r--ranger/gui/widgets/statusbar.py8
-rw-r--r--ranger/shared/__init__.py7
7 files changed, 20 insertions, 23 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py
index 674ad8f6..827452ff 100644
--- a/ranger/__main__.py
+++ b/ranger/__main__.py
@@ -75,7 +75,8 @@ def main():
 	from ranger.ext import curses_interrupt_handler
 	from ranger.core.fm import FM
 	from ranger.core.environment import Environment
-	from ranger.shared.settings import SettingsAware
+	from ranger.shared import (EnvironmentAware, FileManagerAware,
+			SettingsAware)
 	from ranger.gui.defaultui import DefaultUI as UI
 	from ranger.fsobject.file import File
 
@@ -111,11 +112,12 @@ def main():
 	else:
 		path = '.'
 
-	Environment(path)
+	EnvironmentAware._assign(Environment(path))
 
 	try:
 		my_ui = UI()
 		my_fm = FM(ui=my_ui)
+		FileManagerAware._assign(my_fm)
 
 		# Run the file manager
 		my_fm.initialize()
diff --git a/ranger/core/environment.py b/ranger/core/environment.py
index 00b152d3..e5deda07 100644
--- a/ranger/core/environment.py
+++ b/ranger/core/environment.py
@@ -58,9 +58,6 @@ class Environment(SettingsAware, SignalDispatcher):
 		self.hostname = socket.gethostname()
 		self.home_path = os.path.expanduser('~')
 
-		from ranger.shared import EnvironmentAware
-		EnvironmentAware.env = self
-
 		self.signal_bind('move', self._set_cf_from_signal, priority=0.1,
 				weak=True)
 
diff --git a/ranger/core/fm.py b/ranger/core/fm.py
index 626ce838..224ef06f 100644
--- a/ranger/core/fm.py
+++ b/ranger/core/fm.py
@@ -58,9 +58,6 @@ class FM(Actions, SignalDispatcher):
 		self.run = Runner(ui=self.ui, apps=self.apps,
 				logfunc=mylogfunc)
 
-		from ranger.shared import FileManagerAware
-		FileManagerAware.fm = self
-
 		self.log.append('Ranger {0} started! Process ID is {1}.' \
 				.format(__version__, os.getpid()))
 		self.log.append('Running on Python ' + sys.version.replace('\n',''))
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 44acd79f..136fe11d 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -116,7 +116,7 @@ def initialize_commands(map):
 			', or //l// to create symlinks')
 
 	# ---------------------------------------------------- run programs
-	map('s', fm.execute_command(os.environ['SHELL']))
+	map('S', fm.execute_command(os.environ['SHELL']))
 	map('E', fm.edit_file())
 	map(',term', fm.execute_command('x-terminal-emulator', flags='d'))
 	map('du', fm.execute_command('du --max-depth=1 -h | less'))
@@ -230,7 +230,7 @@ def initialize_commands(map):
 
 	map(':', ';', fm.open_console(cmode.COMMAND))
 	map('>', fm.open_console(cmode.COMMAND_QUICK))
-	map('!', fm.open_console(cmode.OPEN))
+	map('!', 's', fm.open_console(cmode.OPEN))
 	map('r', fm.open_console(cmode.OPEN_QUICK))
 
 	map.rebuild_paths()
diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py
index 3f00c3c5..677be2a3 100644
--- a/ranger/gui/widgets/console.py
+++ b/ranger/gui/widgets/console.py
@@ -20,15 +20,19 @@ commands, searching and executing files.
 
 import string
 import curses
+import re
 from collections import deque
 
 from . import Widget
 from ranger.defaults import commands
 from ranger.gui.widgets.console_mode import is_valid_mode, mode_to_class
 from ranger import log, relpath_conf
+from ranger.core.runner import ALLOWED_FLAGS
 from ranger.ext.shell_escape import shell_quote
 from ranger.ext.get_executables import get_executables
 from ranger.ext.direction import Direction
+from ranger.container import CommandList, History
+from ranger.container.history import HistoryEmptyException
 import ranger
 
 DEFAULT_HISTORY = 0
@@ -58,7 +62,6 @@ class Console(Widget):
 	historypaths = []
 
 	def __init__(self, win):
-		from ranger.container import CommandList, History
 		Widget.__init__(self, win)
 		self.commandlist = CommandList()
 		self.settings.keys.initialize_console_commands(self.commandlist)
@@ -156,7 +159,6 @@ class Console(Widget):
 		self.line = ''
 
 	def press(self, key):
-		from curses.ascii import ctrl, ESC
 
 		keytuple = self.env.keybuffer.tuple_with_numbers()
 		try:
@@ -198,7 +200,6 @@ class Console(Widget):
 		self.on_line_change()
 
 	def history_move(self, n):
-		from ranger.container.history import HistoryEmptyException
 		try:
 			current = self.history.current()
 		except HistoryEmptyException:
@@ -388,7 +389,6 @@ class SearchConsole(Console):
 		self.history = self.histories[SEARCH_HISTORY]
 
 	def execute(self):
-		import re
 		if self.fm.env.cwd:
 			regexp = re.compile(self.line, re.L | re.U | re.I)
 			self.fm.env.last_search = regexp
@@ -422,6 +422,8 @@ class OpenConsole(ConsoleWithTab):
 
 	def init(self):
 		self.history = self.histories[OPEN_HISTORY]
+		OpenConsole.prompt = "{0}@{1} $ ".format(self.env.username,
+				self.env.hostname)
 
 	def execute(self):
 		command, flags = self._parse()
@@ -613,13 +615,11 @@ class QuickOpenConsole(ConsoleWithTab):
 
 		return None
 
-
 	def _is_app(self, arg):
 		return self.fm.apps.has(arg) or \
 			(not self._is_flags(arg) and arg in get_executables())
 
 	def _is_flags(self, arg):
-		from ranger.core.runner import ALLOWED_FLAGS
 		return all(x in ALLOWED_FLAGS for x in arg)
 
 	def _is_mode(self, arg):
diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py
index 78666a3d..caf5786e 100644
--- a/ranger/gui/widgets/statusbar.py
+++ b/ranger/gui/widgets/statusbar.py
@@ -145,10 +145,7 @@ class StatusBar(Widget):
 			target = self.column.target.pointed_obj
 		else:
 			target = self.env.at_level(0).pointed_obj
-
-		if target is None \
-				or not target.accessible \
-				or (target.is_directory and target.files is None):
+		if target is None or not target.accessible:
 			return
 
 		perms = target.get_permission_string()
@@ -204,9 +201,6 @@ class StatusBar(Widget):
 			return
 
 		target = self.column.target
-		if target is None:
-			return
-
 		if target is None \
 				or not target.accessible \
 				or (target.is_directory and target.files is None):
diff --git a/ranger/shared/__init__.py b/ranger/shared/__init__.py
index a476bd5f..048b9e7a 100644
--- a/ranger/shared/__init__.py
+++ b/ranger/shared/__init__.py
@@ -20,9 +20,16 @@ class Awareness(object):
 
 class EnvironmentAware(Awareness):
 	env = None
+	@staticmethod
+	def _assign(instance):
+		EnvironmentAware.env = instance
+
 
 class FileManagerAware(Awareness):
 	fm = None
+	@staticmethod
+	def _assign(instance):
+		FileManagerAware.fm = instance
 
 from .mimetype import MimeTypeAware
 from .settings import SettingsAware