Proposed syntax for key sequences
Pavel Roskin
proski at gnu.org
Sun Dec 22 20:44:06 UTC 2002
Hello!
> > echo -ne '\e[?1h\e='; dd
>
> Left: ^[OD
> Ctrl-Left: ^[[D
> Shift-Left: ^[OD
> Alt-Left: ^[^[OD
I could compile CVS putty (UNIX port), and it shows exactly that.
xterm:
Left: ^[OD
Ctrl-Left: ^[O5D
Shift-Left: ^[O2D
rxvt:
Left: ^[OD
Ctrl-Left: ^[Od
Shift-Left: ^[[d
> > In fact, Ctrl-arrows on putty conflict with normal arrows on xterm,
> > not with Shift-arrows as I wrote in the previous message.
>
> As you write, not really, because there is a swath at putty's
> configuration: "Initial state of cursor keys: Normal / Application". You
> can set it as you want, the default is Normal. As I set it to
> Application, the normal dd works as with the echo.
Either way, I cannot hardcode either ^[OD or ^[[D as anything but a cursor
arrow without modifiers. I may try to implement the new syntax for mc.lib
so that you could put your codes for putty there, but I'm very limited in
time, so I cannot promise that.
> > I think the best thing you can do it to ask putty developers to
> > implement xterm specification for the arrow keys. You can even try it
> > yourself.
> It looks like, that they did it, and it works well, just not the
> application mode the default.
No. Look for "Useful mapping of Ctrl-arrows" in window.c in the CVS putty
source.
> Summarizing above, it seems that putty is correct, but mc still not
> works for me. :)
It's not about correctness. putty invents its own sequences, and they
conflict with the sequences implemented by xterm. Given that both
programs are open source, the preference is given to the program that
documents its behavior.
The patch (completely untested) for putty is attached. It doesn't affect
the UNIX port.
--
Regards,
Pavel Roskin
-------------- next part --------------
--- window.c
+++ window.c
@@ -3694,6 +3694,7 @@ static int TranslateKey(UINT message, WP
p += sprintf((char *) p, "\x1B%c", xkey);
else {
int app_flg = (term->app_cursor_keys && !cfg.no_applic_c);
+ char *modifier;
#if 0
/*
* RDB: VT100 & VT102 manuals both state the
@@ -3712,14 +3713,25 @@ static int TranslateKey(UINT message, WP
if (!term->app_keypad_keys)
app_flg = 0;
#endif
- /* Useful mapping of Ctrl-arrows */
- if (shift_state == 2)
- app_flg = !app_flg;
-
+ /* xterm-style modifiers for arrows */
+ switch (shift_state & 3) {
+ case 0:
+ modifier = "";
+ break;
+ case 1:
+ modifier = "2";
+ break;
+ case 2:
+ modifier = "5";
+ break;
+ case 3:
+ modifier = "6";
+ break;
+ }
if (app_flg)
- p += sprintf((char *) p, "\x1BO%c", xkey);
+ p += sprintf((char *) p, "\x1BO%s%c", modifier, xkey);
else
- p += sprintf((char *) p, "\x1B[%c", xkey);
+ p += sprintf((char *) p, "\x1B[%s%c", modifier, xkey);
}
return p - output;
}
More information about the mc-devel
mailing list