diff options
-rw-r--r-- | doc/ranger.1 | 3 | ||||
-rw-r--r-- | ranger/container/keybuffer.py | 10 | ||||
-rw-r--r-- | ranger/container/keymap.py | 20 | ||||
-rw-r--r-- | ranger/core/actions.py | 4 | ||||
-rw-r--r-- | ranger/data/mime.types | 2 | ||||
-rw-r--r-- | ranger/defaults/apps.py | 2 | ||||
-rw-r--r-- | ranger/gui/widgets/statusbar.py | 6 |
7 files changed, 37 insertions, 10 deletions
diff --git a/doc/ranger.1 b/doc/ranger.1 index 6adaf43f..68353dd9 100644 --- a/doc/ranger.1 +++ b/doc/ranger.1 @@ -72,6 +72,9 @@ Reload everything ^L Redraw the screen .TP +S +Open a shell in the current directory +.TP yy Yank the selection. (mark the files as copied) .TP diff --git a/ranger/container/keybuffer.py b/ranger/container/keybuffer.py index 50914f84..0f19a341 100644 --- a/ranger/container/keybuffer.py +++ b/ranger/container/keybuffer.py @@ -18,9 +18,10 @@ from collections import deque from string import digits from ranger.ext.keybinding_parser import parse_keybinding, \ DIRKEY, ANYKEY, PASSIVE_ACTION -from ranger.container.keymap import Binding, KeyMap +from ranger.container.keymap import Binding, KeyMap # mainly for assertions MAX_ALIAS_RECURSION = 20 +digitlist = [ord(n) for n in digits] class KeyBuffer(object): """The evaluator and storage for pressed keys""" @@ -28,10 +29,12 @@ class KeyBuffer(object): self.assign(keymap, direction_keys) def assign(self, keymap, direction_keys): + """Change the keymap and direction keys of the keybuffer""" self.keymap = keymap self.direction_keys = direction_keys def add(self, key): + """Add a key and evaluate it""" assert isinstance(key, int) assert key >= 0 self.all_keys.append(key) @@ -92,7 +95,7 @@ class KeyBuffer(object): tree = self.tree_pointer else: tree = self.dir_tree_pointer - if chr(key) in digits and ANYKEY not in tree: + if key in digitlist and ANYKEY not in tree: attr = self.eval_command and 'quant' or 'direction_quant' if getattr(self, attr) is None: setattr(self, attr, 0) @@ -111,7 +114,7 @@ class KeyBuffer(object): return None except KeyError: try: - chr(key) in digits or self.direction_keys._tree[key] + key in digitlist or self.direction_keys._tree[key] self.tree_pointer = self.tree_pointer[DIRKEY] except KeyError: try: @@ -154,6 +157,7 @@ class KeyBuffer(object): self.done = True def clear(self): + """Reset the keybuffer. Do this once before the first usage.""" self.max_alias_recursion = MAX_ALIAS_RECURSION self.failure = False self.done = False diff --git a/ranger/container/keymap.py b/ranger/container/keymap.py index 167ba160..e44fcfd7 100644 --- a/ranger/container/keymap.py +++ b/ranger/container/keymap.py @@ -22,7 +22,24 @@ DIRARG = 'dir' ALIASARG = 'alias' class CommandArgs(object): - """The arguments which are passed to a keybinding function""" + """ + A CommandArgs object is passed to the keybinding function. + + This object simply aggregates information about the pressed keys + and the current environment. + + Attributes: + fm: the FM instance + wdg: the currently focused widget (or fm, if none is focused) + keybuffer: the keybuffer object + n: the prefixed number, eg 5 in the command "5yy" + directions: a list of directions which are entered for "<dir>" + direction: the first direction object from that list + keys: a string representation of the keybuffer + matches: all keys which are entered for "<any>" + match: the first match + binding: the used Binding object + """ def __init__(self, fm, widget, keybuf): self.fm = fm self.wdg = widget @@ -40,6 +57,7 @@ class CommandArgs(object): return CommandArgs(widget.fm, \ widget, widget.env.keybuffer) + class KeyMap(Tree): """Contains a tree with all the keybindings""" def map(self, *args, **keywords): diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 4b4fc032..2d9546be 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -99,7 +99,9 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): self.log.appendleft(text) if hasattr(self.ui, 'notify'): self.ui.notify(text, duration=duration, bad=bad) - hint = notify + + def hint(self, text): + self.ui.status.hint = text def redraw_window(self): """Redraw the window""" diff --git a/ranger/data/mime.types b/ranger/data/mime.types index c8fa5243..35e34fdc 100644 --- a/ranger/data/mime.types +++ b/ranger/data/mime.types @@ -18,3 +18,5 @@ video/mkv mkv video/flash flv video/ogg ogv ogm video/divx div divx + +text/x-ruby rb diff --git a/ranger/defaults/apps.py b/ranger/defaults/apps.py index 45f2ace3..9064a7d9 100644 --- a/ranger/defaults/apps.py +++ b/ranger/defaults/apps.py @@ -49,7 +49,7 @@ from ranger.api.apps import * from ranger.ext.get_executables import get_executables INTERPRETED_LANGUAGES = re.compile(r''' - ^(text|application)\/x-( + ^(text|application)/x-( haskell|perl|python|ruby|sh )$''', re.VERBOSE) diff --git a/ranger/gui/widgets/statusbar.py b/ranger/gui/widgets/statusbar.py index 64c5e4c7..752bfd6b 100644 --- a/ranger/gui/widgets/statusbar.py +++ b/ranger/gui/widgets/statusbar.py @@ -24,7 +24,7 @@ such as the space used by all the files in this directory. from pwd import getpwuid from grp import getgrgid from os import getuid -from time import strftime, localtime +from time import time, strftime, localtime from ranger.ext.human_readable import human_readable from . import Widget @@ -49,7 +49,7 @@ class StatusBar(Widget): self.column = column self.settings.signal_bind('setopt.display_size_in_status_bar', self.request_redraw, weak=True) - + def request_redraw(self): self.need_redraw = True @@ -245,14 +245,12 @@ class StatusBar(Widget): right.add('All', base, 'all') def _print_result(self, result): - import _curses self.win.move(0, 0) for part in result: self.color(*part.lst) self.addstr(part.string) self.color_reset() -from time import time class Message(object): elapse = None text = None |