Merge branch 'Carpetsmoker-issue-716'

This commit is contained in:
Florian Bruhin 2015-06-05 17:50:29 +02:00
commit ace7877010
5 changed files with 24 additions and 11 deletions

View File

@ -685,6 +685,7 @@ How many steps to zoom out.
[options="header",width="75%",cols="25%,75%"] [options="header",width="75%",cols="25%,75%"]
|============== |==============
|Command|Description |Command|Description
|<<clear-keychain,clear-keychain>>|Clear the currently entered key chain.
|<<command-accept,command-accept>>|Execute the command currently in the commandline. |<<command-accept,command-accept>>|Execute the command currently in the commandline.
|<<command-history-next,command-history-next>>|Go forward in the commandline history. |<<command-history-next,command-history-next>>|Go forward in the commandline history.
|<<command-history-prev,command-history-prev>>|Go back in the commandline history. |<<command-history-prev,command-history-prev>>|Go back in the commandline history.
@ -739,6 +740,10 @@ How many steps to zoom out.
|<<toggle-selection,toggle-selection>>|Toggle caret selection mode. |<<toggle-selection,toggle-selection>>|Toggle caret selection mode.
|<<yank-selected,yank-selected>>|Yank the selected text to the clipboard or primary selection. |<<yank-selected,yank-selected>>|Yank the selected text to the clipboard or primary selection.
|============== |==============
[[clear-keychain]]
=== clear-keychain
Clear the currently entered key chain.
[[command-accept]] [[command-accept]]
=== command-accept === command-accept
Execute the command currently in the commandline. Execute the command currently in the commandline.

View File

@ -1143,7 +1143,7 @@ KEY_DATA = collections.OrderedDict([
])), ])),
('normal', collections.OrderedDict([ ('normal', collections.OrderedDict([
('search', ['<Escape>']), ('search ;; clear-keychain', ['<Escape>']),
('set-cmd-text -s :open', ['o']), ('set-cmd-text -s :open', ['o']),
('set-cmd-text :open {url}', ['go']), ('set-cmd-text :open {url}', ['go']),
('set-cmd-text -s :open -t', ['O']), ('set-cmd-text -s :open -t', ['O']),
@ -1340,8 +1340,8 @@ CHANGED_KEY_COMMANDS = [
(re.compile(r'^download-page$'), r'download'), (re.compile(r'^download-page$'), r'download'),
(re.compile(r'^cancel-download$'), r'download-cancel'), (re.compile(r'^cancel-download$'), r'download-cancel'),
(re.compile(r'^search ""$'), r'search'), (re.compile(r"""^search (''|"")$"""), r'search ;; clear-keychain'),
(re.compile(r"^search ''$"), r'search'), (re.compile(r'^search$'), r'search ;; clear-keychain'),
(re.compile(r"""^set-cmd-text ['"](.*) ['"]$"""), r'set-cmd-text -s \1'), (re.compile(r"""^set-cmd-text ['"](.*) ['"]$"""), r'set-cmd-text -s \1'),
(re.compile(r"""^set-cmd-text ['"](.*)['"]$"""), r'set-cmd-text \1'), (re.compile(r"""^set-cmd-text ['"](.*)['"]$"""), r'set-cmd-text \1'),

View File

@ -165,12 +165,6 @@ class BaseKeyParser(QObject):
key = e.key() key = e.key()
self._debug_log("Got key: 0x{:x} / text: '{}'".format(key, txt)) self._debug_log("Got key: 0x{:x} / text: '{}'".format(key, txt))
if key == Qt.Key_Escape:
self._debug_log("Escape pressed, discarding '{}'.".format(
self._keystring))
self._keystring = ''
return self.Match.none
if len(txt) == 1: if len(txt) == 1:
category = unicodedata.category(txt) category = unicodedata.category(txt)
is_control_char = (category == 'Cc') is_control_char = (category == 'Cc')
@ -306,6 +300,7 @@ class BaseKeyParser(QObject):
True if the event was handled, False otherwise. True if the event was handled, False otherwise.
""" """
handled = self._handle_special_key(e) handled = self._handle_special_key(e)
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)
@ -362,3 +357,9 @@ class BaseKeyParser(QObject):
"defined!") "defined!")
if mode == self._modename: if mode == self._modename:
self.read_config() self.read_config()
def clear_keystring(self):
"""Clear the currently entered key sequence."""
self._debug_log("discarding keystring '{}'.".format(self._keystring))
self._keystring = ''
self.keystring_updated.emit(self._keystring)

View File

@ -317,3 +317,8 @@ class ModeManager(QObject):
return self._eventFilter_keypress(event) return self._eventFilter_keypress(event)
else: else:
return self._eventFilter_keyrelease(event) return self._eventFilter_keyrelease(event)
@cmdutils.register(instance='mode-manager', scope='window', hide=True)
def clear_keychain(self):
"""Clear the currently entered key chain."""
self._parsers[self.mode].clear_keystring()

View File

@ -197,8 +197,10 @@ class TestKeyConfigParser:
('download-page', 'download'), ('download-page', 'download'),
('cancel-download', 'download-cancel'), ('cancel-download', 'download-cancel'),
('search ""', 'search'), ('search ""', 'search ;; clear-keychain'),
("search ''", 'search'), ("search ''", 'search ;; clear-keychain'),
("search", 'search ;; clear-keychain'),
("search ;; foobar", None),
('search "foo"', None), ('search "foo"', None),
('set-cmd-text "foo bar"', 'set-cmd-text foo bar'), ('set-cmd-text "foo bar"', 'set-cmd-text foo bar'),