Commit Graph

78 Commits

Author SHA1 Message Date
brightonanc 92a005293a Cleanup and a few new tests to appease the formatting, branch coverage, etc.
Merges needed were:
    * qutebrowser/keyinput/basekeyparser.py for the new count precaution (commit 51aa7ab)
    * tests/unit/keyinput/test_basekeyparser.py for new count precaution (commit 51aa7ab)
      unit test
2025-12-21 03:37:41 -05:00
brightonanc f114aacad2 Implemented the nuances for the hint mode. 2025-12-21 03:37:41 -05:00
brightonanc 595cda4896 Implementing an initial attempt at forwarding keys. Seems proper, but a few checks still need to be done.
Merges needed were:
* qutebrowser/keyinput/basekeyparser.py for the new count precaution (commit 51aa7ab)
* qutebrowser/keyinput/modeparsers.py for a simple syntax restructure (semantically
  identical)
* tests/unit/keyinput/test_basekeyparser.py for new count precaution (commit 51aa7ab)
  unit test
* qutebrowser/keyinput/modeman.py for import changes (commit eb8121f)
2025-12-21 03:37:41 -05:00
Philipp Albrecht 51aa7abe54 Handle count exceeding string to int conversion
When handling counts during keyparsing we convert the count string to an integer. If the
count is too high (i.e. the count string has too many digits), we run into Python's
integer string conversion length limit[1]:
```
ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has
4301 digits; use sys.set_int_max_str_digits() to increase the limit
```

Instead of blowing up with an exception, we now handle this more gracefully by showing
an error message.

Reproducer:
```
$ qutebrowser --temp-basedir ":later 500 fake-key -g $(printf '1%.0s' {1..4301})j"
```

**NOTE:**
I had to rename `_debug_log()`'s `message` argument to `msg`, because pylint yelled at
me for redefined-outer-name[2].

[1] https://docs.python.org/3/library/stdtypes.html#integer-string-conversion-length-limitation
[2] https://pylint.readthedocs.io/en/stable/user_guide/messages/warning/redefined-outer-name.html
2023-08-27 13:31:11 +02:00
Florian Bruhin 0718b25796 reuse: Initial copyright text update for myself
git ls-files | \
    xargs sed -Ei 's/Copyright [0-9]{4}(-[0-9]{4}) Florian Bruhin \(The Compiler\) <mail@qutebrowser\.org>/SPDX-FileCopyrightText: Florian Bruhin (The Compiler) <mail@qutebrowser.org>/'
2023-07-23 12:49:05 +02:00
Florian Bruhin b2aaba6043 reuse: Adjust most license headers
git ls-files | xargs grep -l "is free software"  | xargs reuse annotate --license="GPL-3.0-or-later" --skip-unrecognised
2023-07-23 12:11:07 +02:00
Florian Bruhin 4e67a1727a Fix lint/test issues 2023-06-30 19:29:28 +02:00
Philipp Albrecht d9e8b638bf Remove vim modelines
We're deprecating vim modelines in favor of `.editorconfig`.

Removing vim modelines could be done using two one-liners. Most of the vim modelines
were followed by an empty line, so this one-liner took care of these ones:

```sh
rg '^# vim: .+\n\n' -l | xargs sed -i '/^# vim: /,+1d'
```

Then some of the vim modelines were followed by a pylint configuration line, so running
this one-liner afterwards took care of that:

```sh
rg '^# vim:' -l | xargs sed -i '/^# vim: /d'
```
2023-06-30 11:03:06 +02:00
Florian Bruhin 0877fb0d78 Run scripts/dev/rewrite_enums.py 2022-08-23 18:31:38 +02:00
Florian Bruhin d47cfd99d7 Run scripts/dev/rewrite_qt_imports.sh 2022-08-23 18:09:11 +02:00
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
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 222f1f19a1 Bump copyright years
Closes #6015
2021-01-20 20:06:19 +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 d6eebbd3f9 tests: Get rid of fake_keyevent
Use keyutils.KeyInfo(...).to_event() instead.
2020-06-17 16:00:23 +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 7b2b977432 Move supports_count to a class attribute 2019-10-09 17:39:01 +02:00
Jay Kamat 3e816f5f8b
Update copyright for 2019 2019-02-22 21:45:08 -08:00
Florian Bruhin a458615030 Further simplify caplog.messages 2018-10-25 11:16:26 +02:00
Florian Bruhin 3b8964183e Use caplog.messages 2018-10-24 10:57:17 +02:00
Florian Bruhin 29ad252278 Handle ² keypress correctly
Turns out str.isdigit() also handles ² as a digit, but int('²') causes a
ValueError.

Here we use `string.digits` instead, which is '0123456789'.

Fixes #3743
2018-05-22 12:25:45 +02:00
Florian Bruhin 84c7c37e8e Swap Control/Meta back on macOS
Fixes #3697

(cherry picked from commit fd9e7bed7fd9842eac22ed304a094a92cc953577)
2018-03-14 19:40:56 +01:00
Florian Bruhin b88ac51d25 Fall back to non-keypad keys without any keypad bindings
Fixes #3701
2018-03-13 14:40:54 +01:00
Florian Bruhin 482b622b1b Fix handling of empty bindings without breaking :unbind
1899e313fd as a fix for #3631 broke :unbind, as
the config system treats None and '' equally.

Instead, allow None/'' again, but just handle it as "no binding".
2018-03-08 11:42:27 +01:00
Florian Bruhin d5c04318b2 Fix test/lint 2018-03-08 06:41:15 +01:00
Florian Bruhin 9b9d7647a4 Show the keystring correctly when entering a count 2018-03-07 22:47:31 +01:00
Florian Bruhin 514138aad2 Allow to bind numbers in keybindings
This mostly reverts 4ef5db1bc4 for #1966, but
fixes #3684 by allowing numbers to be bound again. If the user wants to bind
numbers instead of using them for a count, why not let them.
2018-03-07 22:37:10 +01:00
Florian Bruhin 0d94c17edc Apply key_mappings to KeySequences correctly
Fixes #3678
2018-03-06 21:39:57 +01:00
Florian Bruhin 333a37ffb2 Fix old macOS-specific test code 2018-03-05 18:30:34 +01:00
Florian Bruhin d1854eddaf Handle invalid keys coming from Qt
When pressing a key which doesn't exist as Qt.Key, we don't get Qt.Key_unknown
like we'd expect, but we get 0x0 instead...

Let's add that as a new "nil" key (to not conflict with None/unknown/zero/...)
and handle it appropriately.

This can be reproduced by doing:
setxkbmap -layout us,gr -option grp:alt_shift_toggle
and pressing Alt-Shift/Shift-Alt.
2018-03-05 15:42:52 +01:00
Florian Bruhin 52c280ec12 Add unit tests for BaseKeyParser.handle with dry_run=True 2018-03-05 15:33:56 +01:00
Florian Bruhin 88a5c8d29d Make sure bindings with umlauts work
See #303
2018-03-04 22:38:33 +01:00
Florian Bruhin e2f17c4be1 Always prefer exact over partial matches 2018-03-04 21:45:46 +01:00
Florian Bruhin f85e69ec77 Refactor other keyinput tests 2018-03-04 20:21:58 +01:00
Florian Bruhin b3834835ed Bring back keyutils.is_modifier() and modifier handling
Turns out when we press yY, we get three events:

Qt.Key_Y, Qt.NoModifier
Qt.Key_Shift, Qt.ShiftModifier
Qt.Key_Y, Qt.ShiftModifier

If we don't ignore the second one, our keychain will be interrupted by the Shift
keypress.
2018-03-04 20:21:58 +01:00
Florian Bruhin 63e05e12ba Fix lint and tests 2018-03-04 20:21:57 +01:00
Florian Bruhin 19512e988b Expose less from keyutils publicly 2018-03-04 20:20:30 +01:00
Florian Bruhin fdc2458657 Fix test_split_count after _handle_key merge 2018-03-04 20:20:30 +01:00
Florian Bruhin ec3ad8a969 Get rid of _warn_on_keychains and _supports_chains 2018-02-27 13:02:32 +01:00
Florian Bruhin ba012c6ba8 Get rid of BaseKeyparser.Type 2018-02-27 13:01:41 +01:00
Florian Bruhin 362f923f06 Fix lint 2018-02-27 09:34:55 +01:00
Florian Bruhin 5a03d31f6f More test_basekeyparser fixes 2018-02-27 08:53:28 +01:00
Florian Bruhin 9e27f2b3e7 Initial attempts at fixing test_basekeyparser 2018-02-27 08:48:16 +01:00
Florian Bruhin 6f028e9ad0 Update copyright years 2018-02-05 12:19:50 +01:00