Problems with CTRL-SHIFT

15 views
Skip to first unread message

Stéphane Goujet

unread,
Feb 13, 2018, 2:25:13 AM2/13/18
to tilde-te...@googlegroups.com
Hello,


I am in the process of making a patch that allows shortcuts to be
configurable. It is almost ready(*) but I just met a problem with handling
key combinations of the kind CTRL+SHIFT+normal_key.

I looked at what comes into "bool main_t::process_key(t3_widget::key_t
key)" (file tilde-0.3.9/src/main.cc)

For example for CTRL+SHIFT+'s', I'd expect one of:
* 0x50000073 (CTRL SHIFT 's', better)
* 0x10000053 (CTRL 'S', not great, but I guess we could do something
with it)

But I don't get either. And what I get varies:
-- in my urxvt, I get 0x10000073 (that's CTRL 's');
-- in the console, I get... nothing (process_key() is not called);
-- in a Cygwin terminal + ssh, I get a very weird 0x00000093.


So, I'd like to ask: are you sure your key handling system works fine
(for those cases)? If so, why don't I get what I expect and how can I get
the right information in another way?
Or can it be that all 3 terminal setups I tried 'eat' the CTRL-SHIFT
combination?
Or, I don't know, something else :-)


Faithfully yours,
Stéphane.


NB: tilde version is 0.3.9, and library libt3widget is 0.5.4 (I think
other libraries are not involved?).

(*) well, "ready" considering that I am not at all a C++ programmer and
that I struggle with your architecture, so that means you'll have to
heavily review it, and very likely adapt it so that it fits nice with your
achitecture, perhaps rewrite it. Anyway, it will show it is possible, and
one way of doing it. Then you'll do what you want.

Gertjan Halkes

unread,
Feb 13, 2018, 2:39:22 AM2/13/18
to Tilde text editor
Hi Stéphane,

Thank you for your message and your interest in the Tilde text editor.

First one remark: the recently released libt3widget 0.6.0 contains some code changes which make configurable keybindings possible. Currently, tilde doesn't actually use the functionality, so what is really missing is menus etc. in Tilde to actually make use of this.

To answer your questions about CTRL-SHIFT-normal key: I'm afraid here you/we are running into a limitation of the key reporting by terminals and terminal emulators. Terminals report CTRL+normal key as a value in the range 0x00-0x1f. libt3widget translates that internally to EKEY_CTRL + 's' (for your example), but what it received was a single byte: 0x13. How terminals handle CTRL-SHIFT-normal key is very terminal dependent. Most simply ignore the SHIFT key. The linux console apparently drops the key combination entirely, and the Cygwin terminal does something even more funky: it sets the top bit of the byte. The latter in a way actually makes some strange kind of sense, because this allows typing the control characters in the C1 range (0x80-0x9f).

So, although I'd also love to be able to use those combinations, it is unfortunately not possible. Tilde attempts to do the best it can with the limited capabilities provided by the terminals.

Best regards,
Gertjan Halkes

Stéphane Goujet

unread,
Feb 16, 2018, 3:02:41 AM2/16/18
to Tilde text editor
Hello,

On Mon, 12 Feb 2018, Gertjan Halkes wrote:

> First one remark: the recently released libt3widget 0.6.0 contains some
> code changes which make configurable keybindings possible. Currently, tilde
> doesn't actually use the functionality, so what is really missing is menus
> etc. in Tilde to actually make use of this.

Ah, all right. Then there is no point in me polishing my patch and
sending it to you :-)



> To answer your questions about CTRL-SHIFT-normal key: I'm afraid here
> you/we are running into a limitation of the key reporting by terminals and
> terminal emulators. Terminals report CTRL+normal key as a value in the
> range 0x00-0x1f. libt3widget translates that internally to EKEY_CTRL + 's'
> (for your example), but what it received was a single byte: 0x13. How
> terminals handle CTRL-SHIFT-normal key is very terminal dependent. Most
> simply ignore the SHIFT key. The linux console apparently drops the key
> combination entirely, and the Cygwin terminal does something even more
> funky: it sets the top bit of the byte. The latter in a way actually makes
> some strange kind of sense, because this allows typing the control
> characters in the C1 range (0x80-0x9f).
>
> So, although I'd also love to be able to use those combinations, it is
> unfortunately not possible. Tilde attempts to do the best it can with the
> limited capabilities provided by the terminals.

Ah yes, I forgot that CTRL+letter gets mapped to actual ASCII control
characters. And for the rest it is indeed terminal dependant.

I didn't know at which level you got your keypresses, and I thought that
if it was at ncurses level, the role of ncurses/terminfo was to unify
those terminal specific things. But it doesn't really :-/

So it is either writing code to detect which terminal is used and
interpret keys accordingly, or not supporting those extended features,
indeed.

Thank you for your detailed answers :-)


Goodbye,
Stéphane.
Reply all
Reply to author
Forward
0 new messages