Fix some more stuff (and break some :D)
This commit is contained in:
parent
ddcb5445a2
commit
a8aaf01ff0
@ -136,9 +136,10 @@ class KeyConfig:
|
||||
"""Make sure the given mode exists and normalize the key."""
|
||||
if mode not in configdata.DATA['bindings.default'].default:
|
||||
raise configexc.KeybindingError("Invalid mode {}!".format(mode))
|
||||
if utils.is_special_key(key):
|
||||
# <Ctrl-t>, <ctrl-T>, and <ctrl-t> should be considered equivalent
|
||||
return utils.normalize_keystr(key)
|
||||
# FIXME needed?
|
||||
# if utils.is_special_key(key):
|
||||
# # <Ctrl-t>, <ctrl-T>, and <ctrl-t> should be considered equivalent
|
||||
# return utils.normalize_keystr(key)
|
||||
return key
|
||||
|
||||
def get_bindings_for(self, mode):
|
||||
@ -160,10 +161,11 @@ class KeyConfig:
|
||||
cmd = cmd.strip()
|
||||
cmd_to_keys.setdefault(cmd, [])
|
||||
# put special bindings last
|
||||
if utils.is_special_key(key):
|
||||
cmd_to_keys[cmd].append(key)
|
||||
else:
|
||||
cmd_to_keys[cmd].insert(0, key)
|
||||
# FIXME update
|
||||
# if utils.is_special_key(key):
|
||||
# cmd_to_keys[cmd].append(key)
|
||||
# else:
|
||||
cmd_to_keys[cmd].insert(0, key.toString())
|
||||
return cmd_to_keys
|
||||
|
||||
def get_command(self, key, mode, default=False):
|
||||
|
@ -117,10 +117,10 @@ class ConfigCommands:
|
||||
return
|
||||
|
||||
# No --default -> print binding
|
||||
if utils.is_special_key(key):
|
||||
# self._keyconfig.get_command does this, but we also need it
|
||||
# normalized for the output below
|
||||
key = utils.normalize_keystr(key)
|
||||
#if utils.is_special_key(key):
|
||||
# # self._keyconfig.get_command does this, but we also need it
|
||||
# # normalized for the output below
|
||||
# key = utils.normalize_keystr(key)
|
||||
with self._handle_config_error():
|
||||
cmd = self._keyconfig.get_command(key, mode)
|
||||
if cmd is None:
|
||||
|
@ -173,20 +173,24 @@ class BaseKeyParser(QObject):
|
||||
Return:
|
||||
A self.Match member.
|
||||
"""
|
||||
txt = e.text()
|
||||
key = e.key()
|
||||
txt = utils.keyevent_to_string(e)
|
||||
self._debug_log("Got key: 0x{:x} / text: '{}'".format(key, txt))
|
||||
|
||||
if len(txt) == 1:
|
||||
category = unicodedata.category(txt)
|
||||
is_control_char = (category == 'Cc')
|
||||
else:
|
||||
is_control_char = False
|
||||
|
||||
if (not txt) or is_control_char:
|
||||
if txt is None:
|
||||
self._debug_log("Ignoring, no text char")
|
||||
return QKeySequence.NoMatch
|
||||
|
||||
# if len(txt) == 1:
|
||||
# category = unicodedata.category(txt)
|
||||
# is_control_char = (category == 'Cc')
|
||||
# else:
|
||||
# is_control_char = False
|
||||
|
||||
# if (not txt) or is_control_char:
|
||||
# self._debug_log("Ignoring, no text char")
|
||||
# return QKeySequence.NoMatch
|
||||
|
||||
count, cmd_input = self._split_count(self._keystring + txt)
|
||||
match, binding = self._match_key(cmd_input)
|
||||
if match == QKeySequence.NoMatch:
|
||||
@ -233,7 +237,7 @@ class BaseKeyParser(QObject):
|
||||
return (None, None)
|
||||
|
||||
for seq, cmd in self.bindings.items():
|
||||
match = seq.matches(utils.parse_keystring(cmd_input))
|
||||
match = seq.matches(cmd_input)
|
||||
if match != QKeySequence.NoMatch:
|
||||
return (match, cmd)
|
||||
|
||||
|
@ -56,7 +56,8 @@ class PassthroughKeyParser(CommandKeyParser):
|
||||
_mode: The mode this keyparser is for.
|
||||
"""
|
||||
|
||||
do_log = False
|
||||
# FIXME
|
||||
# do_log = False
|
||||
passthrough = True
|
||||
|
||||
def __init__(self, win_id, mode, parent=None, warn=True):
|
||||
|
@ -106,7 +106,6 @@ class KeyHintView(QLabel):
|
||||
bindings_dict = config.key_instance.get_bindings_for(modename)
|
||||
bindings = [(k, v) for (k, v) in sorted(bindings_dict.items())
|
||||
if k.startswith(prefix) and
|
||||
not utils.is_special_key(k) and
|
||||
not blacklisted(k) and
|
||||
(takes_count(v) or not countstr)]
|
||||
|
||||
|
@ -293,8 +293,6 @@ class FullscreenNotification(QLabel):
|
||||
bindings = all_bindings.get('fullscreen --leave')
|
||||
if bindings:
|
||||
key = bindings[0]
|
||||
if utils.is_special_key(key):
|
||||
key = key.strip('<>').capitalize()
|
||||
self.setText("Press {} to exit fullscreen.".format(key))
|
||||
else:
|
||||
self.setText("Page is now fullscreen.")
|
||||
|
@ -33,6 +33,7 @@ import functools
|
||||
import contextlib
|
||||
import socket
|
||||
import shlex
|
||||
import unicodedata
|
||||
|
||||
import attr
|
||||
from PyQt5.QtCore import Qt, QUrl
|
||||
@ -418,10 +419,22 @@ def keyevent_to_string(e):
|
||||
return None
|
||||
mod = e.modifiers()
|
||||
parts = []
|
||||
|
||||
for (mask, s) in modmask2str.items():
|
||||
if mod & mask and s not in parts:
|
||||
parts.append(s)
|
||||
parts.append(key_to_string(e.key()))
|
||||
|
||||
key_string = key_to_string(e.key())
|
||||
if len(key_string) == 1:
|
||||
category = unicodedata.category(key_string)
|
||||
is_control_char = (category == 'Cc')
|
||||
else:
|
||||
is_control_char = False
|
||||
|
||||
if e.modifiers() == Qt.ShiftModifier and not is_control_char:
|
||||
parts = []
|
||||
|
||||
parts.append(key_string)
|
||||
return normalize_keystr('+'.join(parts))
|
||||
|
||||
|
||||
@ -466,6 +479,8 @@ def is_special_key(keystr):
|
||||
|
||||
def _parse_single_key(keystr):
|
||||
"""Convert a single key string to a (Qt.Key, Qt.Modifiers, text) tuple."""
|
||||
# FIXME remove
|
||||
|
||||
if is_special_key(keystr):
|
||||
# Special key
|
||||
keystr = keystr[1:-1]
|
||||
|
Loading…
Reference in New Issue
Block a user