Commit Graph

165 Commits

Author SHA1 Message Date
Philipp Albrecht b900f1dd30 Make interpreting number keys as counts configurable
By default numbers are interpreted as counts for bindings. Making this
behavior configurable allows for emacs-like bindings, where number keys
are passed through.
2021-11-28 15:50:04 +01:00
Florian Bruhin 5b6d2c60b4 Fix bindings.key_mappings with multiple keys
Otherwise, when e.g. doing "<Meta+Up>": "gg" in bindings.key_mappings,
there's a crash like:

    Traceback (most recent call last):
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/eventfilter.py", line 105, in eventFilter
        return handler(typing.cast(QKeyEvent, event))
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/eventfilter.py", line 75, in _handle_key_event
        return man.handle_event(event)
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/modeman.py", line 462, in handle_event
        return handler(cast(QKeyEvent, event))
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/modeman.py", line 283, in _handle_keypress
        match = parser.handle(event, dry_run=dry_run)
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/modeparsers.py", line 105, in handle
        match = super().handle(e, dry_run=dry_run)
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/basekeyparser.py", line 309, in handle
        result = self._match_key_mapping(result.sequence)
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/basekeyparser.py", line 246, in _match_key_mapping
        mapped = sequence.with_mappings(
      File "/usr/lib/python3.9/site-packages/qutebrowser/keyinput/keyutils.py", line 675, in with_mappings
        assert len(new_seq) == 1
    AssertionError

While this isn't the intended way to use this setting, we shouldn't
crash - and let's just make it work instead of forbidding it.
2021-03-20 11:10:30 +01:00
Lembrun e8b05af233 Qtbot methods changed to snake case,snake case check added 2021-02-26 22:07:08 +01:00
Florian Bruhin d0d7114923 Revert "old qt: Use ApplicationAttribute to switch Ctrl/Meta on Mac"
This reverts commit 1132324db9.

Causes various issues with Qt/QtWebEngine shortcuts.
Fixes #6174
Closes #6149
2021-02-24 09:57:06 +01:00
Florian Bruhin 1a4fff1a42 doc: Switch URLs to https 2021-01-26 15:19:01 +01:00
Florian Bruhin 41afe0febe Support Super as modifier name
See https://github.com/qutebrowser/qutebrowser/discussions/5999#discussioncomment-297309
2021-01-22 17:37:42 +01:00
Florian Bruhin 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +01:00
Florian Bruhin 14373db9c7 dataclasses: Adjust import order
See #6023
2021-01-13 20:26:57 +01:00
Florian Bruhin 124fe5676b dataclasses: Fix ordering
See #6023
2021-01-13 20:26:51 +01:00
Florian Bruhin c970c63355 dataclasses: Initial switch
See #6023
2021-01-13 20:26:41 +01:00
Florian Bruhin c175823020 Add objects.qapp to avoid needing to None-check
We know that QApplication.instance() will always be non-None for
practical purposes, but the stubs now (correctly) declare it as
Optional.

See https://github.com/stlehmann/PyQt5-stubs/pull/126
2021-01-11 18:47:15 +01:00
Florian Bruhin 19586576c5 Revert "Work around PyQt 5.15.1 waitSignals issues"
This reverts commit b55675ad4a.
2020-11-24 18:48:19 +01:00
Florian Bruhin 1132324db9 old qt: Use ApplicationAttribute to switch Ctrl/Meta on Mac 2020-11-04 18:30:04 +01:00
Florian Bruhin b55675ad4a Work around PyQt 5.15.1 waitSignals issues
This should be reverted with PyQt 5.15.2.
See #5719
2020-09-15 13:56:00 +02:00
Florian Bruhin 2e992d3a74 Fix tests/lint 2020-06-17 17:36:49 +02:00
Florian Bruhin 6031827103 Fix lint 2020-06-17 16:53:34 +02:00
Florian Bruhin d6eebbd3f9 tests: Get rid of fake_keyevent
Use keyutils.KeyInfo(...).to_event() instead.
2020-06-17 16:00:23 +02:00
Florian Bruhin bc88e67395 Add BindingTrie.__str__ 2020-06-17 15:42:42 +02:00
Florian Bruhin b25c7d5b36 modeparsers: Refactor how hints are handled
Instead of binding hints to fake :follow-hint commands, we now use a separate
CommandKeyParser and ask that for its match result.

If the key matches with the command parser, it is bound in hint mode, so we
clear the hint keystring and defer to the command handling instead.

If it doesn't, we continue hint handling as usual - however, the HintKeyParser
is now not a CommandKeyParser anymore, so we don't have to deal with command
parsing (and have a custom execute implementation instead).

Closes #4504
Fixes #4392
Fixes #4368
Helps with #5084, though it doesn't completely fix that yet.
Supersedes #3742 (fix for #3735)
Supersedes #4691 (fix for #4264)
2020-06-17 15:42:42 +02:00
Florian Bruhin e9a23498b2 basekeyparser: Improve debug logging 2020-06-17 14:12:29 +02:00
Florian Bruhin ccc9d1779c modeparsers: Refactor to avoid subclassing
Before the changes in this commit, we've had to have a subclassed parser for
every mode, even if there was no special key handling going on in that mode.

With a couple of changes, we can avoid many of those subclasses and only have
subclasses for bigger changes (like hint or register modes).

- The awkward handling of self._modename in _read_config() is now removed.
  _read_config() doesn't take an argument, always uses the mode in self._mode
  and gets called from __init__.
- BaseKeyParser takes the mode as an argument to __init__.
- The class attributes (do_log/passthrough/supports_count) now also get passed
  via the constructor.
2020-06-17 14:12:24 +02:00
Florian Bruhin 9e4276db9b Adjust copyrights for 2020 2020-01-04 18:21:17 +01:00
Florian Bruhin 943bcbd7bc Unify hint parser tests 2019-10-10 10:06:42 +02:00
Florian Bruhin 7c54355da7 Fix hint filtering with number keypad
In 9557885 a regression was introduced which broke following hints with the
number keypad.

Fixes #5065
2019-10-10 09:54:22 +02:00
Florian Bruhin 36ac7f2470 Move HintManager from a per-tab to a per-window object
This means we use objreg less and we have less HintManager objects - what's
there not to like?
2019-10-09 23:07:32 +02:00
Florian Bruhin d9f5049631 Fix broken test_keychain
Key_X is bound via key-mappings to "message-info a"
2019-10-09 18:15:03 +02:00
Florian Bruhin 038c6e495b Pass commandrunner object to mode parsers
Apart from making things easier to test, this also means there is only one
shared CommandRunner instead of there being one per parser.
2019-10-09 18:08:03 +02:00
Florian Bruhin 7b2b977432 Move supports_count to a class attribute 2019-10-09 17:39:01 +02:00
Florian Bruhin 4e6d977c0a Use qtbot.wait_signal in test_modeparsers 2019-10-09 14:43:11 +02:00
Florian Bruhin be31f1b6e0 Fix coverage 2019-09-13 13:12:54 +02:00
Florian Bruhin 9557885ace Add a proper MatchResult type instead of tuples 2019-09-13 13:12:54 +02:00
Florian Bruhin 2aa6603a0a Make test_bindingtrie more Pythonic 2019-09-12 21:43:20 +02:00
Florian Bruhin f8689774a0 Merge remote-tracking branch 'origin/pr/4730' into binding-trie 2019-09-12 11:52:29 +02:00
Florian Bruhin c6fac2157d Merge remote-tracking branch 'origin/pr/4691' 2019-09-11 16:03:39 +02:00
Florian Bruhin 2df9bf8e53 Merge remote-tracking branch 'origin/pr/4492' 2019-09-11 12:14:31 +02:00
Florian Bruhin 51e515f91c Merge remote-tracking branch 'origin/pr/4585' 2019-09-10 17:27:49 +02:00
Florian Bruhin 56c524d0fe Fix implicit int conversions for QKeySequence
This also fixes some calls to utils.KeySequence with a string.

See #4928
2019-08-18 02:06:09 +02:00
Jay Kamat c9522c1b69
Add tests for binding trie 2019-04-27 12:08:22 -07:00
user202729 e720df22c4 Add tests for modifier keys for test_is_special 2019-04-26 21:13:45 +07:00
user202729 902f942ac3 Add tests for is_special_hint_mode 2019-04-26 21:13:28 +07:00
user202729 60a52baaa6 Fix wrong test for keyutils.is_printable
According to is_special documentation, (Qt.Key,2, Qt.KeypadModifier)
should return True because it requires special representation <num-2>
2019-04-24 13:59:04 +07:00
Joel Bradshaw 3fce3baa69 Reduce rewriting to just surrogates
After testing, these are the only ones that cause problems
2019-03-09 15:26:13 -08:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
user202729 1562074383 Add tests for AltGr modifier key 2019-02-17 10:08:29 +07:00
Florian Bruhin 94f998ac3a Adjust for new pytest import handling
See #4511
2019-02-16 20:00:01 +01:00
Joel Bradshaw b5490c690c Linting, review comments 2018-12-29 09:47:56 -08:00
Joel Bradshaw 3948365120 Take a different tack
We can just rewrite the key code to the actual Unicode code point.

This is much cleaner, as QKeySequence() behaves as expected when given
code points as input, so QKeySequence(ord("𩷶")).toString() == "𩷶".
2018-12-26 23:51:50 -08:00
Joel Bradshaw c2c64d0623 Never mind, early return is what we want
Also, add default variable so old code (e.g. tests) is okay, and
update keycode for the Chinese character even though it doesn't
really matter to the test
2018-12-24 00:37:18 -08:00
Joel Bradshaw 065ece5283 Attempt to add a test for this 2018-12-23 17:21:13 -08:00
Florian Bruhin a458615030 Further simplify caplog.messages 2018-10-25 11:16:26 +02:00