Merge branch 'lahwaacz-keyinput'

This commit is contained in:
Florian Bruhin 2016-08-11 21:02:05 +02:00
commit b51dffc517
6 changed files with 21 additions and 13 deletions

View File

@ -90,6 +90,8 @@ Fixed
already worked before) already worked before)
- The command completion now updates correctly when changing aliases - The command completion now updates correctly when changing aliases
- `:undo` now doesn't undo tabs "closed" by `:tab-detach` anymore. - `:undo` now doesn't undo tabs "closed" by `:tab-detach` anymore.
- Fixed an issue with hint chars not being cleared correctly when leaving hint
mode.
v0.8.3 (unreleased) v0.8.3 (unreleased)
------------------- -------------------

View File

@ -145,10 +145,10 @@ Contributors, sorted by the number of commits in descending order:
* Antoni Boucher * Antoni Boucher
* Lamar Pavel * Lamar Pavel
* Bruno Oliveira * Bruno Oliveira
* Jakub Klinkovský
* Jan Verbeek * Jan Verbeek
* Alexander Cogneau * Alexander Cogneau
* Marshall Lochbaum * Marshall Lochbaum
* Jakub Klinkovský
* Felix Van der Jeugt * Felix Van der Jeugt
* Martin Tournoij * Martin Tournoij
* Raphael Pierzina * Raphael Pierzina

View File

@ -1452,7 +1452,7 @@ RETURN_KEYS = ['<Return>', '<Ctrl-M>', '<Ctrl-J>', '<Shift-Return>', '<Enter>',
KEY_DATA = collections.OrderedDict([ KEY_DATA = collections.OrderedDict([
('!normal', collections.OrderedDict([ ('!normal', collections.OrderedDict([
('clear-keychain ;; leave-mode', ['<Escape>', '<Ctrl-[>']), ('leave-mode', ['<Escape>', '<Ctrl-[>']),
])), ])),
('normal', collections.OrderedDict([ ('normal', collections.OrderedDict([
@ -1683,7 +1683,7 @@ CHANGED_KEY_COMMANDS = [
(re.compile(r'^scroll ([-\d]+ [-\d]+)$'), r'scroll-px \1'), (re.compile(r'^scroll ([-\d]+ [-\d]+)$'), r'scroll-px \1'),
(re.compile(r'^search *;; *clear-keychain$'), r'clear-keychain ;; search'), (re.compile(r'^search *;; *clear-keychain$'), r'clear-keychain ;; search'),
(re.compile(r'^leave-mode$'), r'clear-keychain ;; leave-mode'), (re.compile(r'^clear-keychain *;; *leave-mode$'), r'leave-mode'),
(re.compile(r'^download-remove --all$'), r'download-clear'), (re.compile(r'^download-remove --all$'), r'download-clear'),

View File

@ -193,7 +193,7 @@ class BaseKeyParser(QObject):
if match == self.Match.definitive: if match == self.Match.definitive:
self._debug_log("Definitive match for '{}'.".format( self._debug_log("Definitive match for '{}'.".format(
self._keystring)) self._keystring))
self._keystring = '' self.clear_keystring()
self.execute(binding, self.Type.chain, count) self.execute(binding, self.Type.chain, count)
elif match == self.Match.ambiguous: elif match == self.Match.ambiguous:
self._debug_log("Ambiguous match for '{}'.".format( self._debug_log("Ambiguous match for '{}'.".format(
@ -205,7 +205,7 @@ class BaseKeyParser(QObject):
elif match == self.Match.none: elif match == self.Match.none:
self._debug_log("Giving up with '{}', no matches".format( self._debug_log("Giving up with '{}', no matches".format(
self._keystring)) self._keystring))
self._keystring = '' self.clear_keystring()
else: else:
raise AssertionError("Invalid match value {!r}".format(match)) raise AssertionError("Invalid match value {!r}".format(match))
return match return match
@ -271,7 +271,7 @@ class BaseKeyParser(QObject):
time = config.get('input', 'timeout') time = config.get('input', 'timeout')
if time == 0: if time == 0:
# execute immediately # execute immediately
self._keystring = '' self.clear_keystring()
self.execute(binding, self.Type.chain, count) self.execute(binding, self.Type.chain, count)
else: else:
# execute in `time' ms # execute in `time' ms
@ -289,8 +289,7 @@ class BaseKeyParser(QObject):
command/count: As if passed to self.execute() command/count: As if passed to self.execute()
""" """
self._debug_log("Executing delayed command now!") self._debug_log("Executing delayed command now!")
self._keystring = '' self.clear_keystring()
self.keystring_updated.emit(self._keystring)
self.execute(command, self.Type.chain, count) self.execute(command, self.Type.chain, count)
def handle(self, e): def handle(self, e):
@ -307,7 +306,9 @@ class BaseKeyParser(QObject):
if handled or not self._supports_chains: if handled or not self._supports_chains:
return handled return handled
match = self._handle_single_key(e) match = self._handle_single_key(e)
self.keystring_updated.emit(self._keystring) # don't emit twice if the keystring was cleared in self.clear_keystring
if self._keystring:
self.keystring_updated.emit(self._keystring)
return match != self.Match.none return match != self.Match.none
def read_config(self, modename=None): def read_config(self, modename=None):
@ -366,6 +367,8 @@ class BaseKeyParser(QObject):
def clear_keystring(self): def clear_keystring(self):
"""Clear the currently entered key sequence.""" """Clear the currently entered key sequence."""
self._debug_log("discarding keystring '{}'.".format(self._keystring)) if self._keystring:
self._keystring = '' self._debug_log("discarding keystring '{}'.".format(
self.keystring_updated.emit(self._keystring) self._keystring))
self._keystring = ''
self.keystring_updated.emit(self._keystring)

View File

@ -282,6 +282,9 @@ class ModeManager(QObject):
raise NotInModeError("Not in mode {}!".format(mode)) raise NotInModeError("Not in mode {}!".format(mode))
log.modes.debug("Leaving mode {}{}".format( log.modes.debug("Leaving mode {}{}".format(
mode, '' if reason is None else ' (reason: {})'.format(reason))) mode, '' if reason is None else ' (reason: {})'.format(reason)))
# leaving a mode implies clearing keychain, see
# https://github.com/The-Compiler/qutebrowser/issues/1805
self.clear_keychain()
self.mode = usertypes.KeyMode.normal self.mode = usertypes.KeyMode.normal
self.left.emit(mode, self.mode, self._win_id) self.left.emit(mode, self.mode, self._win_id)

View File

@ -278,7 +278,7 @@ class TestKeyConfigParser:
('search ;; clear-keychain', 'clear-keychain ;; search'), ('search ;; clear-keychain', 'clear-keychain ;; search'),
('search;;clear-keychain', 'clear-keychain ;; search'), ('search;;clear-keychain', 'clear-keychain ;; search'),
('search;;foo', None), ('search;;foo', None),
('leave-mode', 'clear-keychain ;; leave-mode'), ('clear-keychain ;; leave-mode', 'leave-mode'),
('leave-mode ;; foo', None), ('leave-mode ;; foo', None),
('download-remove --all', 'download-clear'), ('download-remove --all', 'download-clear'),