micro: Binding raw escape sequences doesn't work
Description of the problem or steps to reproduce
I’m using MobaXterm on Windows to connect to my Debian machine via SSH. The default key bindings for SelectWordLeft and SelectWordRight (CtrlShiftLeft and CtrlShiftRight) don’t work. I checked in the raw mode (in micro) what it receives when I’m pressing these combinations and it says: EventKey: Left: “\x1bOD” EventKey: Right: “\x1bOC”
So following the instructions for binding raw escape sequences, I added this to my ~/.config/micro/bindings.json: “\x1bOC”: “SelectWordRight”, “\x1bOD”: “SelectWordLeft”,
But after that, when launching micro, it says “Error reading bindings.json: invalid character ‘x’ in string escape code”. Exactly like in this older issue #1863 .
Specifications
Commit hash: c2cebaa3 OS: Debian Stretch (connecting from MobaXterm on Windows, through SSH) Terminal: MobaXterm
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 37
It would work with the config files as well, when zyedidia/json5#1 would be merged. Unfortunately I can’t speed this up, since I’ve no merge rights. Afterwards the dependency within
microneeds to be bumped.From my perspective this highly depends on the users local scenario and mentioned every possibility is too much for the documentation of
microitself. But I confirm, that the documentation should be consistent.Currently it makes no sense, at least in my opinion, because that part need to be changed again after the above mentioned PR is merged (if and when ever). But everyone is encouraged to support with his own PR. 😉
I have to confess that I was not patient enough to read all the 100+ comments here. Still I hope I can be relevant.
I am new to micro, so I read the documentation. When I realise that micro does not work through ssh/tmux/… because it gets the escape sequences and does not interpret them, I started looking for why and failed (it seems either documentation is oblivious about escapes not supported [yes I see the mention, but not the resolution], or maybe it’s supported but my version isn’t latest, v2.11).
Anyway. The documentation talks about
\x1b, and0x1band it seems neither works (as they are) in the config.\uXXXXseems to be vaguely mentioned but it’s not obvious for the causal reader that despite how it’s referred to and how raw mode displays the\u001bform is what works, others aren’t. This is mainly the problem of the documentation (it should be spelled out that\x1bshall be written as\u001b), but inconsistent with raw output as well.Summarizing:
\x1bshould work in config file or raw should be fixed?\x1b[1;5Cfor CtrlRight which shall be in factWordRightin config).Quoting myself:
I was a bit wrong: the documentation in
help keybindingsdoes mention the\unotation.But users don’t necessarily carefully read the documentation or are very familiar with json, so adding support for
\xnotation in bindings.json would still be nice. (Even though micro will forcefully rewrite bindings.json every time, replacing)\xwith the canonical\u, which is BTW also something users wouldn’t expect, but at least keybindings will keep working.One of the problems here is that JSON does not support the
\xnotation, so in bindings.json the raw sequence bindings need to be specified slightly differently:(Yeah, arguably it is a bug: micro does not attempt to properly parse
\x-escaped strings, instead it simply relies on the JSON parser which does not support\xeither, so the resulting behavior is non-intuitive and undocumented.)The bad news here is that it is not the only problem. With the above
\unotation, micro does not print any errors, and I can see that micro does callscreen.Screen.RegisterRawSeq(), however the bindings themselves still don’t work (i.e. nothing happens when I press the corresponding keys). I remember it used to work for me some (rather long) time ago, so I think it is a regression, either in micro or in tcell.