Bug 385380 - Cannot bind non letter/digit/. keys in profile keybinding combinations
Summary: Cannot bind non letter/digit/. keys in profile keybinding combinations
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: keyboard (show other bugs)
Version: master
Platform: unspecified All
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-05 00:25 UTC by Flav
Modified: 2018-05-24 19:57 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 18.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Flav 2017-10-05 00:25:08 UTC
In "Settings">"Edit Current Profile...">"Keyboard">"Edit...", In the Key combination, you can only bind letters, digit, dot and underscore, others are not working.

For example, you can't bind a Ctrl+; to an escape sequence (that could be used in Vim for example).

It seems it's the regex key in the function KeyboardTranslatorReader::tokenize(const QString &line) that cause the limitation.

Replacing :

-       static const QRegularExpression key(QStringLiteral("key\\s+([\\w\\+\\s\\-\\*\\.+)\\s*:\\s*(\"(.*)\"|\\w+)"),


with

+       static const QRegularExpression key(QStringLiteral("key\\s+(.+)\\s*:\\s*(\"(.*)\"|\\w+)"),

Seems to workaround the problem... but I guess there is a reason while the original regex is that complicated, this is why I didn't submitted a patch
Comment 1 Ahmad Samir 2018-03-07 12:11:02 UTC
FWIW, you can use '++Ctrl', note the extra +.

For the rest of it: https://phabricator.kde.org/D10939
Comment 2 Kurt Hindenburg 2018-03-07 13:57:16 UTC
The patch in phabricator changes it to 

static const QRegularExpression key(QStringLiteral("key\\s+(\\S+)\\s*:\\s*(\"(.*)\"|\\w+)"),

I'm not actually sure why the original one is more complex.  I'll try to test it.
Comment 3 Kurt Hindenburg 2018-05-24 19:57:18 UTC
Git commit 47199ba564628f8e7230ce3cea80f65aefe17dfa by Kurt Hindenburg, on behalf of Mariusz Glebocki.
Committed on 24/05/2018 at 19:57.
Pushed by hindenburg into branch 'master'.

Allow any character(s) as a key in key binding.

Summary:
The key (the part before modifiers) is interpreted by QKeySequence.
For special keys (everything except printable characters), it uses names
from `Qt::Key` without `Key_` prefix. For character keys, it uses the
character itself, and it is not possible to use e.g. `Comma`. For this
reason limited set of characters limits possible key bindings.
FIXED-IN: 18.08

Test Plan:
* In profile's key bindings settings (or your keysym file) create entry:
```
key ,-Shift+Ctrl-Alt+Ansi : "Hello from keysym"
```
* Change `-Alt` to `+Alt` if you have a conflict. Do not change shift
  (the shortcut would trigger on `<` instead of `,`). You can also use
   e.g. ``;'[]=` instead of `,`. AltGr+letter works too, so `ą`, `á`, etc.
   can be used.
* Save and close settings
* Press `Ctrl+,`

Expected result: "Hello from keysym" is typed

Actual result:
* the key binding does not work
* empty rows appear in key bindings table

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel, #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D13081

M  +1    -1    src/KeyboardTranslator.cpp

https://commits.kde.org/konsole/47199ba564628f8e7230ce3cea80f65aefe17dfa