Using mc via telnet
Pavel Roskin
proski at gnu.org
Fri Sep 21 02:01:03 UTC 2001
Hello!
> > Yes. "Learn Keys" is just a cheap substitute to making the keys work as
> > they are described in terminfo and/or termcap.
>
> I don't call it "cheap"! I call it an EXCELLENT feature!!!
> I wish more applications would follow this route.
Incidentally, I have been thinking about it. It is clear for me that the
terminfo standard doesn't solve all problems present in termcap. What MC
actually does is an attempt to work around deficiencies of the terminfo
standards, not just "bugs" in the terminfo database.
The terminfo relies solely on the TERM variable, which is actually not so
reliable. On my pretty standard RedHat 7.1, both xterm and rxvt set
TERM=xterm by default. And yet F1 sends "\eOP" on xterm and "\e[11~" on
rxvt.
If you look in mc.lib, you will find that some keys are defined more than
once to work with different terminals with the same TERM. This is not
allowed in terminfo definitions (as far as I know).
More definitions are added "behind the scenes", in the code, because even
the format of mc.lib is not sufficient to express the rules. So, for
example, "\eOP" is added as another definition of F1 if $TERM begins with
"xterm".
Another problem is that if you are running telnet in xterm and you have a
working connection back from the remote host to your X server, it is a
different situation than when the X connection is not available (i.e. you
are behind firewall). MC compiled with X events support can distinguish
Ctrl-M and Enter in the first case, but not in the second.
Finally, there is no way to describe in terminfo keys with modifiers e.g.
the sequence for Shift-Home. Yet it's well defined and unique in rxvt.
If you want to share the "Learn Keys" code with other applications, it
means establishing a standard. For a standard to succeed, it must be very
good (or you should have influence of software vendors, which is not the
case).
I think that "Learn Keys" is not sufficient for even MC itself. Run MC in
xterm and try selecting text in the editor with Shift-arrows. It doesn't
work? Now go to "Learn Keys". The Shift-arrows are not there. They are
not in terminfo either.
Terminfo is good if you don't want to use your terminal to the maximum
extent possible. But if you want to use any keys in any combination
allowed by your hardware, terminfo is too restrictive.
What MC is doing now is creating a "better terminfo" with support for
multiple sequences per key, new keys combinations and support for data
from the sources other that the terminal (X11 events, linux specific
ioctl).
Another solution would be creating a new terminal client-server protocol
and designing both the terminal (a reference terminal) and the screen
library in the same time. I believe it's a much cleaner approach.
The application (i.e. the screen library it's linked with) could send
request to the terminal. Not just the name of the terminal, but the
properties - number of keys, number of screen buffers (xterm has two),
state of the modifiers. It would be very useful to request the cursor
position, e.g. after sending some Japanese characters, that can be more
than one character wide, without the client knowing anything about
Japanese alphabet.
Functional keys could be sent in plaintext (escaped, of course), and the
level of detalization could be negotiated, e.g. the client could prefer
"Alt-Enter" over "Right Alt-Keypad Enter".
All the terminal functionality could be build into existing terminals,
e.g. rxvt. A special sequence would just put the terminal into the new
client-server mode.
I think it's a much better idea than sharing half-baked "Learn Keys"
functionality with other applications. It may even be easier to do than
to implement the "better terminfo" with optional support for X events and
Linux ioctl. And yet it won't use X at all - why open another connection
if one is already open?
--
Regards,
Pavel Roskin
More information about the mc
mailing list