From ce6c90a0d88d60aa98b78ec5d072a2270c569d70 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 1 Oct 2011 02:35:40 +0200 Subject: gui.widgets.browserview: improved hint/bookmark list --- ranger/core/actions.py | 4 ++-- ranger/defaults/rc.conf | 1 + ranger/ext/keybinding_parser.py | 11 +++++++---- ranger/gui/widgets/browserview.py | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 1904082e..42cb6747 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -24,7 +24,7 @@ from inspect import cleandoc import ranger from ranger.ext.direction import Direction from ranger.ext.relative_symlink import relative_symlink -from ranger.ext.keybinding_parser import construct_keybinding +from ranger.ext.keybinding_parser import key_to_string from ranger.ext.shell_escape import shell_quote from ranger import fsobject from ranger.core.shared import FileManagerAware, EnvironmentAware, \ @@ -102,7 +102,7 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): else: cmd = cmd_class(string) if cmd.resolve_macros and _MacroTemplate.delimiter in string: - macros = dict(('any%d'%i, construct_keybinding([char])) \ + macros = dict(('any%d'%i, key_to_string(char)) \ for i, char in enumerate(wildcards)) if 'any0' in macros: macros['any'] = macros['any0'] diff --git a/ranger/defaults/rc.conf b/ranger/defaults/rc.conf index d56c90a9..a6fd6098 100644 --- a/ranger/defaults/rc.conf +++ b/ranger/defaults/rc.conf @@ -200,6 +200,7 @@ map zf console filter # Bookmarks map ` draw_bookmarks map ' draw_bookmarks +map m draw_bookmarks map um draw_bookmarks map ` enter_bookmark %any map ' enter_bookmark %any diff --git a/ranger/ext/keybinding_parser.py b/ranger/ext/keybinding_parser.py index 4e590283..7dbf8c25 100644 --- a/ranger/ext/keybinding_parser.py +++ b/ranger/ext/keybinding_parser.py @@ -69,12 +69,15 @@ def construct_keybinding(iterable): """ result = [] for c in iterable: - try: - result.append(chr(c)) - except: - result.append("?") + result.append(key_to_string(c)) return ''.join(result) +def key_to_string(key): + try: + return chr(key) + except: + return '?' + # Arbitrary numbers which are not used with curses.KEY_XYZ DIRKEY = 9001 ANYKEY = 9002 diff --git a/ranger/gui/widgets/browserview.py b/ranger/gui/widgets/browserview.py index c789a7d2..b7ec14c2 100644 --- a/ranger/gui/widgets/browserview.py +++ b/ranger/gui/widgets/browserview.py @@ -16,6 +16,7 @@ """The BrowserView manages a set of BrowserColumns.""" import curses from ranger.ext.signals import Signal +from ranger.ext.keybinding_parser import key_to_string from . import Widget from .browsercolumn import BrowserColumn from .pager import Pager @@ -181,8 +182,7 @@ class BrowserView(Widget, DisplayableContainer): self.need_clear = True hints = [] for k, v in self.fm.env.keybuffer.pointer.items(): - try: k = chr(k) - except: k = str(k) + k = key_to_string(k) if isinstance(v, dict): text = '...' else: -- cgit 1.4.1-2-gfad0 'author Kartik K. Agaram <vc@akkartik.com> 2015-03-16 20:26:59 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-03-16 20:26:59 -0700 932 - clean up comments in the tangled c++' href='/akkartik/mu/commit/cpp/000organization?h=main&id=3c435756bcd997dac981ca78c49c5100eb2211b7'>3c435756 ^
1
2
3
4
5
6
7
8
9
10
11
12
13