summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lepus.uberspace.de>2013-08-20 13:58:20 +0200
committerhut <hut@lepus.uberspace.de>2013-08-20 13:58:20 +0200
commitf94abca65edb412c9e0d97495aafb53bd01c7edf (patch)
tree7cd7a2a4edee9b9472e64872e6761c7cb394d8c3
parent12f8b60b62a7d995af9f14ae1747b145f6dad53f (diff)
downloadranger-f94abca65edb412c9e0d97495aafb53bd01c7edf.tar.gz
ext.keybinding_parser: interpret keys like <383>
sometimes ranger's keybinding parser doesn't support whatever key you
want to use.  In that case, it would be useful to be able to specify
keys by their curses key code that can be taken from tools like
/doc/tools/print_keys.py.  <383> would then be interpreted as
<S-DELETE>, for example.
-rw-r--r--ranger/ext/keybinding_parser.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/ranger/ext/keybinding_parser.py b/ranger/ext/keybinding_parser.py
index 3589b9dd..0519f69f 100644
--- a/ranger/ext/keybinding_parser.py
+++ b/ranger/ext/keybinding_parser.py
@@ -87,10 +87,13 @@ def parse_keybinding(obj):
                         for key in keys:
                             yield key
                     except KeyError:
-                        yield ord('<')
-                        for c in bracket_content:
-                            yield ord(c)
-                        yield ord('>')
+                        if string.isdigit():
+                            yield int(string)
+                        else:
+                            yield ord('<')
+                            for c in bracket_content:
+                                yield ord(c)
+                            yield ord('>')
                     except TypeError:
                         yield keys  # it was no tuple, just an int
                 else:
/* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>test</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/work/ranger/test/__init__.py">/home/hut/work/ranger/test/__init__.py</a></font></td></tr></table>
    <p></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="test.tc_bookmarks.html">tc_bookmarks</a><br>
<a href="test.tc_colorscheme.html">tc_colorscheme</a><br>
</td><td width="25%" valign=top><a href="test.tc_directory.html">tc_directory</a><br>
<a href="test.tc_displayable.html">tc_displayable</a><br>
</td><td width="25%" valign=top><a href="test.tc_history.html">tc_history</a><br>
<a href="test.tc_keyapi.html">tc_keyapi</a><br>
</td><td width="25%" valign=top><a href="test.tc_ui.html">tc_ui</a><br>
<a href="test.test.html">test</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ['tc_history', 'tc_directory', 'tc_ui', 'tc_bookmarks', 'tc_history', 'tc_keyapi', 'tc_ui', 'tc_displayable', 'tc_keyapi', 'tc_colorscheme', 'tc_bookmarks', 'tc_directory', 'tc_colorscheme', 'tc_displayable']</td></tr></table>
</body></html>