From d6cd804c94c998f4bcc165d40c2c4a948f57c04e Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 8 Apr 2010 19:56:29 +0200 Subject: tc_direction: fixed maximum=X means that the maximum value is set to X-1. Works for lists: d.move(maximum=len(lst)) is this counter intuitive? --- test/tc_direction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tc_direction.py b/test/tc_direction.py index dd7e94ab..18f9eb4c 100644 --- a/test/tc_direction.py +++ b/test/tc_direction.py @@ -71,7 +71,7 @@ class TestDirections(unittest.TestCase): self.assertEqual(3, d.move(direction=3)) self.assertEqual(5, d.move(direction=3, current=2)) self.assertEqual(15, d.move(direction=3, pagesize=5)) - self.assertEqual(10, d.move(direction=3, pagesize=5, maximum=10)) + self.assertEqual(9, d.move(direction=3, pagesize=5, maximum=10)) self.assertEqual(18, d.move(direction=9, override=2)) d2 = Direction(absolute=True) self.assertEqual(5, d2.move(direction=9, override=5)) -- cgit 1.4.1-2-gfad0 From ba6d518ee6b8e48d1ff9de1cc83a8efcbd6ca4c9 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 12 Apr 2010 10:38:27 +0200 Subject: Fixed handling of directories with GC'd subdirs --- ranger/fsobject/directory.py | 5 +++-- ranger/gui/widgets/statusbar.py | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ranger/fsobject/directory.py b/ranger/fsobject/directory.py index bf626004..3574f329 100644 --- a/ranger/fsobject/directory.py +++ b/ranger/fsobject/directory.py @@ -237,6 +237,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): Loads the contents of the directory. Use this sparingly since it takes rather long. """ + self.content_outdated = False if not self.loading: self.load_once() @@ -370,8 +371,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): if self.load_content_once(*a, **k): return True - if self.content_outdated: - self.content_outdated = False + if self.files is None or self.content_outdated: self.load_content(*a, **k) return True @@ -403,6 +403,7 @@ class Directory(FileSystemObject, Accumulator, SettingsAware): """The number of containing files""" if not self.accessible or not self.content_loaded: raise ranger.fsobject.NotLoadedYet() + assert self.files is not None return len(self.files) def __eq__(self, other): diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 75fbbe89..78666a3d 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -146,10 +146,9 @@ class StatusBar(Widget): else: target = self.env.at_level(0).pointed_obj - if target is None: - return - - if target.accessible is False: + if target is None \ + or not target.accessible \ + or (target.is_directory and target.files is None): return perms = target.get_permission_string() @@ -208,7 +207,9 @@ class StatusBar(Widget): if target is None: return - if not target.content_loaded or not target.accessible: + if target is None \ + or not target.accessible \ + or (target.is_directory and target.files is None): return pos = target.scroll_begin -- cgit 1.4.1-2-gfad0 From c0914664cf35ea0f06cb4c24f983d62096594d0c Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 12 Apr 2010 11:26:12 +0200 Subject: cleanup --- ranger/api/apps.py | 7 ++++--- ranger/core/fm.py | 6 ++---- ranger/defaults/apps.py | 3 ++- ranger/ext/get_all_modules.py | 23 ----------------------- ranger/ext/get_executables.py | 33 +++++++++++++++++++++++++-------- ranger/ext/waitpid_no_intr.py | 9 +++++---- ranger/gui/widgets/console.py | 7 ++++--- 7 files changed, 42 insertions(+), 46 deletions(-) delete mode 100644 ranger/ext/get_all_modules.py diff --git a/ranger/api/apps.py b/ranger/api/apps.py index a17a6601..309c0db6 100644 --- a/ranger/api/apps.py +++ b/ranger/api/apps.py @@ -20,6 +20,7 @@ This module provides helper functions/classes for ranger.apps. import os, sys, re from subprocess import Popen, PIPE from ranger.ext.iter_tools import flatten +from ranger.ext.get_executables import get_executables from ranger.shared import FileManagerAware @@ -68,7 +69,7 @@ class Applications(FileManagerAware): if hasattr(dep, 'dependencies') \ and not self._meets_dependencies(dep): return False - if dep not in self.fm.executables: + if dep not in get_executables(): return False return True @@ -78,7 +79,7 @@ class Applications(FileManagerAware): try: application_handler = getattr(self, 'app_' + app) except AttributeError: - if app in self.fm.executables: + if app in get_executables(): return tup(app, *context) continue if self._meets_dependencies(application_handler): @@ -101,7 +102,7 @@ class Applications(FileManagerAware): try: handler = getattr(self, 'app_' + app) except AttributeError: - if app in self.fm.executables: + if app in get_executables(): return tup(app, *context) # generic app handler = self.app_default return handler(context) diff --git a/ranger/core/fm.py b/ranger/core/fm.py index 25e66407..626ce838 100644 --- a/ranger/core/fm.py +++ b/ranger/core/fm.py @@ -51,7 +51,6 @@ class FM(Actions, SignalDispatcher): self.tabs = {} self.current_tab = 1 self.loader = Loader() - self._executables = None self.apps = self.settings.apps.CustomApplications() def mylogfunc(text): @@ -68,9 +67,8 @@ class FM(Actions, SignalDispatcher): @property def executables(self): - if self._executables is None: - self._executables = sorted(get_executables()) - return self._executables + """For compatibility. Calls get_executables()""" + return get_executables() def initialize(self): """If ui/bookmarks are None, they will be initialized here.""" diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index b3500c0d..45f2ace3 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -46,6 +46,7 @@ This example modifies the behaviour of "feh" and adds a custom media player: """ from ranger.api.apps import * +from ranger.ext.get_executables import get_executables INTERPRETED_LANGUAGES = re.compile(r''' ^(text|application)\/x-( @@ -103,7 +104,7 @@ class CustomApplications(Applications): else: parts = default_editor.split() exe_name = os.path.basename(parts[0]) - if exe_name in self.fm.executables: + if exe_name in get_executables(): return tuple(parts) + tuple(c) return self.either(c, 'vim', 'emacs', 'nano') diff --git a/ranger/ext/get_all_modules.py b/ranger/ext/get_all_modules.py deleted file mode 100644 index 62c81437..00000000 --- a/ranger/ext/get_all_modules.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2009, 2010 Roman Zimbelmann -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -def get_all_modules(dirname): - """returns a list of strings containing the names of modules in a directory""" - import os - result = [] - for filename in os.listdir(dirname): - if filename.endswith('.py') and not filename.startswith('_'): - result.append(filename[0:filename.index('.')]) - return result diff --git a/ranger/ext/get_executables.py b/ranger/ext/get_executables.py index 9eeb3345..22c08eb9 100644 --- a/ranger/ext/get_executables.py +++ b/ranger/ext/get_executables.py @@ -13,12 +13,28 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import stat -import os -from os.path import isfile, join, exists +from stat import S_IXOTH, S_IFREG from ranger.ext.iter_tools import unique +from os import listdir, environ, stat +from os.path import join -def get_executables(*paths): + +_cached_executables = None + + +def get_executables(): + """ + Return all executable files in each of the given directories. + + Looks in $PATH by default. + """ + global _cached_executables + if _cached_executables is None: + _cached_executables = sorted(get_executables_uncached()) + return _cached_executables + + +def get_executables_uncached(*paths): """ Return all executable files in each of the given directories. @@ -26,7 +42,7 @@ def get_executables(*paths): """ if not paths: try: - pathstring = os.environ['PATH'] + pathstring = environ['PATH'] except KeyError: return () paths = unique(pathstring.split(':')) @@ -34,15 +50,16 @@ def get_executables(*paths): executables = set() for path in paths: try: - content = os.listdir(path) + content = listdir(path) except: continue for item in content: abspath = join(path, item) try: - filestat = os.stat(abspath) + filestat = stat(abspath) except: continue - if filestat.st_mode & (stat.S_IXOTH | stat.S_IFREG): + if filestat.st_mode & (S_IXOTH | S_IFREG): executables.add(item) return executables + diff --git a/ranger/ext/waitpid_no_intr.py b/ranger/ext/waitpid_no_intr.py index c14fa5b9..12fbcbce 100644 --- a/ranger/ext/waitpid_no_intr.py +++ b/ranger/ext/waitpid_no_intr.py @@ -13,17 +13,18 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +from errno import EINTR +from os import waitpid + def waitpid_no_intr(pid): """catch interrupts which occur while using os.waitpid""" - import os, errno - while True: try: - return os.waitpid(pid, 0) + return waitpid(pid, 0) except KeyboardInterrupt: continue except OSError as e: - if e.errno == errno.EINTR: + if e.errno == EINTR: continue else: raise diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index d7040a4f..3f00c3c5 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -27,6 +27,7 @@ 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.ext.shell_escape import shell_quote +from ranger.ext.get_executables import get_executables from ranger.ext.direction import Direction import ranger @@ -445,8 +446,8 @@ class OpenConsole(ConsoleWithTab): try: position_of_last_space = line.rindex(" ") except ValueError: - return (start + program + ' ' for program in self.fm.executables \ - if program.startswith(line)) + return (start + program + ' ' for program \ + in get_executables() if program.startswith(line)) if position_of_last_space == len(line) - 1: return self.line + '%s ' else: @@ -615,7 +616,7 @@ class QuickOpenConsole(ConsoleWithTab): def _is_app(self, arg): return self.fm.apps.has(arg) or \ - (not self._is_flags(arg) and arg in self.fm.executables) + (not self._is_flags(arg) and arg in get_executables()) def _is_flags(self, arg): from ranger.core.runner import ALLOWED_FLAGS -- cgit 1.4.1-2-gfad0 From eb3795d352893ce760bfa31383cf98ba1ad9d113 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 12 Apr 2010 12:15:22 +0200 Subject: Grey out copied/cut files. --- ranger/colorschemes/default.py | 3 +++ ranger/core/actions.py | 7 +++++++ ranger/defaults/keys.py | 1 + ranger/gui/context.py | 2 +- ranger/gui/widgets/browsercolumn.py | 3 +++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ranger/colorschemes/default.py b/ranger/colorschemes/default.py index 24f8ab91..ca8456e7 100644 --- a/ranger/colorschemes/default.py +++ b/ranger/colorschemes/default.py @@ -59,6 +59,9 @@ class Default(ColorScheme): fg = white else: fg = red + if not context.selected and (context.cut or context.copied): + fg = black + attr |= bold if context.main_column: if context.selected: attr |= bold diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 0f8b74e5..c0599b46 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -531,16 +531,23 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): # -- File System Operations # -------------------------- + def uncut(self): + self.env.copy = set() + self.env.cut = False + self.ui.browser.main_column.request_redraw() + def copy(self): """Copy the selected items""" selected = self.env.get_selection() self.env.copy = set(f for f in selected if f in self.env.cwd.files) self.env.cut = False + self.ui.browser.main_column.request_redraw() def cut(self): self.copy() self.env.cut = True + self.ui.browser.main_column.request_redraw() def paste_symlink(self): from os import symlink, getcwd diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index b43744a9..7a235a5d 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -108,6 +108,7 @@ def initialize_commands(map): # ------------------------------------------ file system operations map('yy', fm.copy()) map('dd', fm.cut()) + map('ud', fm.uncut()) map('pp', fm.paste()) map('po', fm.paste(overwrite=True)) map('pl', fm.paste_symlink()) diff --git a/ranger/gui/context.py b/ranger/gui/context.py index 4ea50714..d4c1c94d 100644 --- a/ranger/gui/context.py +++ b/ranger/gui/context.py @@ -23,7 +23,7 @@ CONTEXT_KEYS = ['reset', 'error', 'good', 'bad', 'space', 'permissions', 'owner', 'group', 'mtime', 'nlink', 'scroll', 'all', 'bot', 'top', 'percentage', - 'marked', 'tagged', 'tag_marker', + 'marked', 'tagged', 'tag_marker', 'cut', 'copied', 'help_markup', 'seperator', 'key', 'special', 'border', 'title', 'text', 'highlight', 'bars', 'quotes', 'tab', diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 4e93ed3e..8cf8990c 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -281,6 +281,9 @@ class BrowserColumn(Pager): if stat.S_ISSOCK(mode): this_color.append('socket') + if self.env.copy and drawn in self.env.copy: + this_color.append('cut' if self.env.cut else 'copied') + if drawn.islink: this_color.append('link') this_color.append(drawn.exists and 'good' or 'bad') -- cgit 1.4.1-2-gfad0 From 48970395e4643cb74c37547363b196c7c4029678 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 13:44:58 +0200 Subject: cleaner use of Awareness classes --- ranger/__main__.py | 5 +++-- ranger/core/environment.py | 3 --- ranger/core/fm.py | 3 --- ranger/shared/__init__.py | 7 +++++++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ranger/__main__.py b/ranger/__main__.py index 674ad8f6..98ce47da 100644 --- a/ranger/__main__.py +++ b/ranger/__main__.py @@ -75,7 +75,7 @@ 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 * from ranger.gui.defaultui import DefaultUI as UI from ranger.fsobject.file import File @@ -111,11 +111,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/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 -- cgit 1.4.1-2-gfad0 From dd6c4eee64d8a6f5cdc8e6c9332ad2f4435f15c6 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 13:47:45 +0200 Subject: Avoid syntax warning --- ranger/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ranger/__main__.py b/ranger/__main__.py index 98ce47da..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 import * + from ranger.shared import (EnvironmentAware, FileManagerAware, + SettingsAware) from ranger.gui.defaultui import DefaultUI as UI from ranger.fsobject.file import File -- cgit 1.4.1-2-gfad0 From c5d42b436afe9674a7f620c626592cff9a059981 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 14:35:49 +0200 Subject: Fixed broken statusbar --- ranger/gui/widgets/statusbar.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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): -- cgit 1.4.1-2-gfad0 From ca654255893b32697923e0865b6762f26c6a86a4 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 20:22:30 +0200 Subject: slightly different prompt for open-console --- ranger/defaults/keys.py | 4 ++-- ranger/gui/widgets/console.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index 03b7e2d3..0c805cb6 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -110,7 +110,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')) @@ -224,7 +224,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 03f61ddf..0da5cba3 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -419,6 +419,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() -- cgit 1.4.1-2-gfad0 From 6406bf0af7409e79e807568a581c1d76de288774 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 23:39:15 +0200 Subject: reopened bug #65 since it reappeared --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 6be34f8c..715ebc1b 100644 --- a/TODO +++ b/TODO @@ -71,7 +71,7 @@ Bugs (X) #54 10/01/23 max_dirsize_for_autopreview not working ( ) #60 10/02/05 utf support improvable (X) #62 10/02/15 curs_set can raise an exception - (X) #65 10/02/16 "source ranger ranger some/file.txt" shouldn't cd after exit + ( ) #65 10/02/16 "source ranger ranger some/file.txt" shouldn't cd after exit (X) #67 10/03/08 terminal title in tty (X) #69 10/03/11 tab-completion breaks with Apps subclass (X) #73 10/03/21 when clicking on the first column, it goes 1x down -- cgit 1.4.1-2-gfad0 From 08bc4ef99547537d645f6eaac5f0f04e5de5fe3d Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 23:50:49 +0200 Subject: README: added Roadmap --- README | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README b/README index 429aefa1..3954488e 100644 --- a/README +++ b/README @@ -124,6 +124,24 @@ Also, see the file HACKING for more detailed instructions on modifying the program. +Roadmap +------- +Short term: + +* A cleaner and more flexible key configuration file +* Performance improvements everywhere +* Simplification of the code + +Long term: + +* One stable branch that you can rely on not crashing +* A plugin system +* Separate ranger into multiple programs: + 1. One daemon running in the background for slow IO operations + 2. A program launcher (ideally an already existing one) + 3. The actual program containing unseparable parts + + Tips ---- -- cgit 1.4.1-2-gfad0 From b34fd133e7172194d9faf73e9c1b8a2bb97ec90e Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 13 Apr 2010 23:53:35 +0200 Subject: README: slightly improved Roadmap --- README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README b/README index 3954488e..7d042929 100644 --- a/README +++ b/README @@ -126,6 +126,7 @@ modifying the program. Roadmap ------- + Short term: * A cleaner and more flexible key configuration file @@ -138,7 +139,7 @@ Long term: * A plugin system * Separate ranger into multiple programs: 1. One daemon running in the background for slow IO operations - 2. A program launcher (ideally an already existing one) + 2. A file launcher (ideally an already existing one) 3. The actual program containing unseparable parts -- cgit 1.4.1-2-gfad0 From e07d8797bf8b1029205f48e65241a4819768f310 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 00:15:50 +0200 Subject: console: move imports to top level --- ranger/gui/widgets/console.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 0da5cba3..8480ea42 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -20,14 +20,18 @@ 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.container import CommandList, History +from ranger.container.history import HistoryEmptyException import ranger DEFAULT_HISTORY = 0 @@ -57,7 +61,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) @@ -155,7 +158,6 @@ class Console(Widget): self.line = '' def press(self, key): - from curses.ascii import ctrl, ESC keytuple = self.env.keybuffer.tuple_with_numbers() try: @@ -197,7 +199,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 +386,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 @@ -612,13 +612,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): -- cgit 1.4.1-2-gfad0 From daa224d86348f0e0fa39d09feef43e34df56d780 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 14 Apr 2010 00:17:40 +0200 Subject: synchronize key combinations with master branch --- ranger/defaults/keys.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py index b298f9c0..72b13051 100644 --- a/ranger/defaults/keys.py +++ b/ranger/defaults/keys.py @@ -145,7 +145,7 @@ map('p', fm.hint('press //p// once again to confirm pasting' \ ', 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')) @@ -257,7 +257,7 @@ def ctrl_c(arg): 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)) -- cgit 1.4.1-2-gfad0