diff options
author | hut <hut@lavabit.com> | 2010-04-14 00:24:10 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-14 00:24:10 +0200 |
commit | 04ce666a809f461db7477edc7884beb4d466deff (patch) | |
tree | 1c6785fe6a989e723781e2bcce9426a60123b2a5 /ranger | |
parent | daa224d86348f0e0fa39d09feef43e34df56d780 (diff) | |
parent | 19c1fa4f622ffd1597943f0005ba58a30b170bb4 (diff) | |
download | ranger-04ce666a809f461db7477edc7884beb4d466deff.tar.gz |
Merge branch 'devel' into newkey
Conflicts: ranger/__main__.py ranger/defaults/keys.py ranger/gui/widgets/console.py
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/__main__.py | 6 | ||||
-rw-r--r-- | ranger/core/environment.py | 3 | ||||
-rw-r--r-- | ranger/core/fm.py | 3 | ||||
-rw-r--r-- | ranger/gui/widgets/console.py | 13 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 8 | ||||
-rw-r--r-- | ranger/shared/__init__.py | 7 |
6 files changed, 19 insertions, 21 deletions
diff --git a/ranger/__main__.py b/ranger/__main__.py index 863eadd5..2aae6343 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,12 +112,13 @@ def main(): else: path = '.' - Environment(path) + EnvironmentAware._assign(Environment(path)) SettingsAware._setup_keys() 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 d83003b1..b712683a 100644 --- a/ranger/core/environment.py +++ b/ranger/core/environment.py @@ -63,9 +63,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 459620c6..495b9f13 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -57,9 +57,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/gui/widgets/console.py b/ranger/gui/widgets/console.py index 3228c511..c93a4f38 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -20,15 +20,20 @@ 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.container.keymap import CommandArgs from ranger.ext.get_executables import get_executables +from ranger.ext.direction import Direction +from ranger.container import History +from ranger.container.history import HistoryEmptyException import ranger DEFAULT_HISTORY = 0 @@ -45,7 +50,6 @@ class _CustomTemplate(string.Template): class Console(Widget): mode = None visible = False - commandlist = None last_cursor_mode = None prompt = ':' copy = '' @@ -58,7 +62,6 @@ class Console(Widget): historypaths = [] def __init__(self, win): - from ranger.container import History Widget.__init__(self, win) self.clear() self.histories = [] @@ -195,7 +198,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: @@ -385,7 +387,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 @@ -419,6 +420,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() @@ -610,13 +613,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 |