Commit graph

28 commits

Author SHA1 Message Date
Daniel Eklöf
66801e4f33
keymap: alt-tab (C-tab) now emits “ESC tab” by default
In our default mode (roughly equivalent to XTerm’s modifyOtherKeys=1),
alt-tab now emits ESC-tab instead of CSI 27;3;9~.

When modifyOtherKeys=2 is enabled (CSI >4;2m), alt-tab emits the “old”
CSI 27 escape.

This better matches XTerm’s behavior.

Note that other alt-tab combos are ambiguous in XTerm, and thus they
are left unchanged here (i.e. we keep emitting CSI 27 escapes for
them).

Closes #900
2022-02-01 18:37:50 +01:00
Daniel Eklöf
4a74050999
input: add support for modifyOtherKeys=2
Similar to modifyOtherKeys=1 (foot’s default, and only, mode), except
that:

* All modifiers (and not just Ctrl) generate \E[27;m;n~ escapes
* Regular keys (with modifiers) also generate \E[27;m;n~ escapes (for
  example, C-h no longer generates ^H, but \E[27;5;104~)

For our keymap based lookups, this is handled by adding
MOD_MODIFY_OTHER_KEYS_STATE<N> variants.

For “generic” keys, we simply adjust the conditions for when to emit a
\E[27;m;n~ escape - the only requirement is that at least one modifier
is active.
2021-11-13 11:09:07 +01:00
Daniel Eklöf
b5fb4a634b
keymap: iso_left_tab: we no longer “consume” shift when matching
Thus, the modifier list needs to include MOD_SHIFT, or we wont match
anything, causing us to hit the last entry, \E[Z.

Closes #547
2021-05-26 09:13:58 +02:00
Daniel Eklöf
e4f164d958
keymap: handle shift+tab combos correctly, after consuming modifiers
Shift+Tab is an odd bird in XKB; it produces a shifted variant of tab,
ISO_Left_Tab, with Shift being a consumed modifier.

From a terminal perspective, Tab and ISO_Left_Tab are the same key,
with Shift+Tab generating ‘CSI Z’, and all other combos generating a
‘CSI 27;mods;9~’ escape.

Before, when we didn’t filter out consumed modifiers, we could simply
re-use the keymap for Tab when translating ISO_Left_Tab.

This is no longer possible, since shift has been filtered out. As a
result, Shift+Tab no longer generated ‘CSI Z’, but ‘\t’. I.e as if
shift wasn’t being pressed.

This patch adds a separate keymap table for ISO_Left_Tab. It’s MOD_ANY
entry corresponds to Shift+Tab, and emits ‘CSI Z’. All its other
entries *exclude* shift (since it has been consumed), *but*, the
encoded modifier (in the escape sequences) *include* shift.
2021-03-08 20:30:25 +01:00
Daniel Eklöf
c213ee90f1
keymap: add ‘CSI 27;<mod>;27~’ escapes for Esc with modifiers 2020-11-28 11:50:32 +01:00
Daniel Eklöf
2de60eafb7
keymap: fix alt+return combos
All alt+return combos mapped to the same escape sequence as alt+return
itself.

With this patch, alt+<mod(s)>+return map to a standard ‘CSI 27;x;13~’
sequence.
2020-11-19 19:22:52 +01:00
Daniel Eklöf
121b488e74
keymap: use same lookup table for Tab and ISO_Left_Tab
With XKB, Shift+Tab maps to XKB_KEY_ISO_Left_Tab, not
XKB_Key_Tab. Previously, we had two different lookup tables for the
two.

The tab table was correctly populated, while the ISO-left tab
wasn’t. As a result, all Shift+Tab combos (except Shift+Tab itself)
was wrong, and resulted in the same escape sequence as Shift+Tab.

Fix by using the same table for both tab and ISO-left tab.

Closes #210
2020-11-19 19:22:48 +01:00
Daniel Eklöf
18e00a55f6
keymap: emit \E[27;2;13~ for all key combinations involving Shift+Return
This is what XTerm emits with `modifyOtherKeys=1`, which is foot’s only mode.
2020-09-07 22:20:13 +02:00
Daniel Eklöf
26528f6a73
input: add key mapping for XKB_KEY_KP_Decimal 2020-06-27 20:03:41 +02:00
Daniel Eklöf
7a82bcf7a5
keymap: remove trailing whitespaces 2020-04-08 17:54:52 +02:00
Daniel Eklöf
762ed04637
keymap: return: all Alt+<mod> now emits \e\r 2020-04-08 17:33:36 +02:00
Daniel Eklöf
b60c9d0b40
keymap: \t -> spaces 2020-04-08 17:31:21 +02:00
Michael Cardell Widerkrantz
81f518d5b3 Make Alt-Return send ESC Return 2020-03-16 21:28:40 +01:00
Daniel Eklöf
e8197d22f7
keymap: tab: handle all modifiers
Tab is one of the keys included in our "otherModifierKeys"
implementation. However, since the key sym falls outside the checks
required to trigger it, special case it and implement its sequences as
a table.
2020-02-21 19:14:46 +01:00
Daniel Eklöf
ae23023341
keymap: align backspace escapes with XTerm
Backspace now emits DEL for all non-ctrl modifier combos, and BS for
all ctrl modifier combos.

The alt modifier prefixes DEL/BS with ESC.

This also removes my own hack of mapping ctrl+backspace to
alt+backspace.

Describe backspace behavior in both the README and the man page.

TODO: implement DECBKM to allow applications to toggle the backspace
behavior.
2020-02-21 19:11:03 +01:00
Daniel Eklöf
1472383c15
keymap: remove keymap table
Lookup is now done in code, using a switch-statement
2020-01-11 18:37:00 +01:00
Daniel Eklöf
8837309c2e
keymap: add KP enter
This makes the keypad enter key emit "\eOM" in keypad application
mode.
2020-01-11 12:37:07 +01:00
Daniel Eklöf
30f6480644
keymap: add escapes for keypad 'begin'
This is usually the '5' key, in non-num lock mode.
2020-01-10 20:23:56 +01:00
Daniel Eklöf
b8c552a5b7
keymap: add meta modifier mappings for keypad keys 2019-08-15 20:07:33 +02:00
Daniel Eklöf
2c16ec2687
keymap: add meta modifier mappings for non-keypad keys 2019-08-15 19:56:14 +02:00
Daniel Eklöf
9ca01436ee
input: track meta modifier 2019-08-15 19:38:28 +02:00
Daniel Eklöf
c5747fbd7d
keymap: don't ESC prefix return when 'shift' is held down 2019-08-15 19:24:46 +02:00
Daniel Eklöf
18fb70bb3f
keymap: fix sequences for PageDown 2019-07-22 18:45:14 +02:00
Daniel Eklöf
cb78c8cff6
keymap: map tab and back-tab 2019-07-18 14:54:43 +02:00
Daniel Eklöf
056700aa8f
keymap: use hex instead of octal 2019-07-17 11:18:55 +02:00
Daniel Eklöf
34f9d544fd
input: fix backspace escape sequences 2019-07-09 15:09:44 +02:00
Daniel Eklöf
cb8c2cdb35
input: split up keymap
This makes the top level table smaller, and faster to search
through. Eventually, we could do something fancy, like b-search the
top level table.
2019-07-09 15:05:07 +02:00
Daniel Eklöf
3dbef02dac
input: implement keypad application mode
This commit also replaces the previous (temporary) key map with a much
more complete one.
2019-07-09 14:27:26 +02:00