Add forward_unbound_keys setting
This commit is contained in:
parent
b372c23b80
commit
0e3e588038
1
TODO
1
TODO
@ -2,7 +2,6 @@ keyparser foo
|
||||
=============
|
||||
|
||||
- Handle keybind to get out of insert mode (e.g. esc)
|
||||
- Add passthrough-keys option to pass through unmapped keys
|
||||
- Add more element-selection-detection code (with options?) based on:
|
||||
-> javascript: http://stackoverflow.com/a/2848120/2085149
|
||||
-> microFocusChanged and check active element via:
|
||||
|
@ -85,12 +85,15 @@ class CommandKeyParser(KeyParser):
|
||||
|
||||
Emit:
|
||||
set_cmd_text: If the keystring should be shown in the statusbar.
|
||||
|
||||
Return:
|
||||
True if event has been handled, False otherwise.
|
||||
"""
|
||||
txt = e.text().strip()
|
||||
if not self._keystring and any(txt == c for c in STARTCHARS):
|
||||
self.set_cmd_text.emit(txt)
|
||||
return
|
||||
super()._handle_single_key(e)
|
||||
return True
|
||||
return super()._handle_single_key(e)
|
||||
|
||||
def execute(self, cmdstr, count=None):
|
||||
"""Handle a completed keychain."""
|
||||
|
@ -176,6 +176,10 @@ DATA = OrderedDict([
|
||||
SettingValue(types.Bool(), "true"),
|
||||
"Whether to automatically enter insert mode if an editable element "
|
||||
"is focused after page load."),
|
||||
|
||||
('forward_unbound_keys',
|
||||
SettingValue(types.Bool(), "false"),
|
||||
"Whether to forward unbound keys to the website in normal mode."),
|
||||
)),
|
||||
|
||||
('tabbar', sect.KeyValue(
|
||||
|
@ -116,12 +116,15 @@ class KeyParser(QObject):
|
||||
|
||||
Args:
|
||||
e: the KeyPressEvent from Qt.
|
||||
|
||||
Return:
|
||||
True if event has been handled, False otherwise.
|
||||
"""
|
||||
logging.debug('Got key: {} / text: "{}"'.format(e.key(), e.text()))
|
||||
txt = e.text().strip()
|
||||
if not txt:
|
||||
logging.debug('Ignoring, no text')
|
||||
return
|
||||
return False
|
||||
|
||||
self._stop_delayed_exec()
|
||||
self._keystring += txt
|
||||
@ -135,7 +138,8 @@ class KeyParser(QObject):
|
||||
count = None
|
||||
|
||||
if not cmd_input:
|
||||
return
|
||||
# Only a count, no command yet, but we handled it
|
||||
return True
|
||||
|
||||
(match, binding) = self._match_key(cmd_input)
|
||||
|
||||
@ -151,6 +155,8 @@ class KeyParser(QObject):
|
||||
logging.debug('Giving up with "{}", no matches'.format(
|
||||
self._keystring))
|
||||
self._keystring = ''
|
||||
return False
|
||||
return True
|
||||
|
||||
def _match_key(self, cmd_input):
|
||||
"""Try to match a given keystring with any bound keychain.
|
||||
|
@ -25,6 +25,8 @@ import logging
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, QObject, QEvent
|
||||
|
||||
import qutebrowser.config.config as config
|
||||
|
||||
|
||||
manager = None
|
||||
|
||||
@ -168,11 +170,19 @@ class ModeManager(QObject):
|
||||
return False
|
||||
elif typ == QEvent.KeyPress:
|
||||
# KeyPress in a non-passthrough mode - call handler and filter
|
||||
# event from widgets
|
||||
# event from widgets (unless unhandled and configured to pass
|
||||
# unhandled events through)
|
||||
self.key_pressed.emit(evt)
|
||||
if handler is not None:
|
||||
handler(evt)
|
||||
return True
|
||||
handled = handler(evt)
|
||||
else:
|
||||
handled = False
|
||||
if handled:
|
||||
return True
|
||||
elif config.get('general', 'forward_unbound_keys'):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
else:
|
||||
# KeyRelease in a non-passthrough mode - filter event and ignore it
|
||||
# entirely.
|
||||
|
Loading…
Reference in New Issue
Block a user