From 500ad24cc350093927fbba2c48331670e79302b1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 5 Jun 2014 13:20:10 +0200 Subject: [PATCH] Add keybindings for Ctrl-?/H/J/[ for Delete/Backspace/Return/Escape --- qutebrowser/config/configdata.py | 11 +++++++++++ qutebrowser/test/utils/test_readline.py | 8 ++++++++ qutebrowser/utils/readline.py | 14 ++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index e7d7fc769..e4c624e47 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -685,6 +685,7 @@ DATA = OrderedDict([ ('', 'leave-mode'), ('', 'leave-mode'), ('', 'open-editor'), + ('', '${}'), )), ('keybind.hint', sect.ValueList( @@ -692,11 +693,13 @@ DATA = OrderedDict([ ('', 'follow-hint'), ('', 'leave-mode'), ('', 'leave-mode'), + ('', '${}'), )), ('keybind.passthrough', sect.ValueList( types.KeyBindingName(), types.KeyBinding(), ('', 'leave-mode'), + ('', '${}'), )), # FIXME we should probably have a common section for input modes with a @@ -723,6 +726,10 @@ DATA = OrderedDict([ ('', 'rl-kill-word'), ('', 'rl-unix-word-rubout'), ('', 'rl-yank'), + ('', 'rl-delete-char'), + ('', 'rl-backward-delete-char'), + ('', '${}'), + ('', '${}'), )), ('keybind.prompt', sect.ValueList( @@ -742,6 +749,10 @@ DATA = OrderedDict([ ('', 'rl-kill-word'), ('', 'rl-unix-word-rubout'), ('', 'rl-yank'), + ('', 'rl-delete-char'), + ('', 'rl-backward-delete-char'), + ('', '${}'), + ('', '${}'), )), ('aliases', sect.ValueList( diff --git a/qutebrowser/test/utils/test_readline.py b/qutebrowser/test/utils/test_readline.py index 0172689e0..3486f3fd1 100644 --- a/qutebrowser/test/utils/test_readline.py +++ b/qutebrowser/test/utils/test_readline.py @@ -92,6 +92,14 @@ class ReadlineBridgeTest(TestCase): self.bridge.rl_end_of_line() self.qle.end.assert_called_with(False) + def test_rl_delete_char(self): + self.bridge.rl_delete_char() + self.qle.del_.assert_called_with() + + def test_rl_backward_delete_char(self): + self.bridge.rl_backward_delete_char() + self.qle.backspace.assert_called_with() + def test_rl_unix_line_discard(self): """Set a selected text, delete it, see if it comes back with yank.""" self._set_selected_text("delete test") diff --git a/qutebrowser/utils/readline.py b/qutebrowser/utils/readline.py index 7c202280f..8d43b5cc3 100644 --- a/qutebrowser/utils/readline.py +++ b/qutebrowser/utils/readline.py @@ -126,3 +126,17 @@ class ReadlineBridge: if self.widget is None or self.widget not in self.deleted: return self.widget.insert(self.deleted[self.widget]) + + @cmd.register(instance='rl_bridge', hide=True, modes=['command', 'prompt']) + def rl_delete_char(self): + """Readline: Delete the character at point.""" + if self.widget is None: + return + self.widget.del_() + + @cmd.register(instance='rl_bridge', hide=True, modes=['command', 'prompt']) + def rl_backward_delete_char(self): + """Readline: Delete the character behind the cursor.""" + if self.widget is None: + return + self.widget.backspace()