[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] Arrow keys in nano
Vincent Rivière, 09.02.2013 16:41:16:
1) nano disables the termios IEXTEN flag (unlike vim).
Once again, Helmut had the good intuition.
See src/nano.c, in disable_extended_io().
I'm unsure why nano does that.
2) In the MiNTLib, termios/tcsetattr.c
termios' IEXTEN is translated to the kernel Fcntl's XKEY.
That XKEY flag enables the generation of ascii sequences on arrow keys
(such
as Esc A, etc.)
When IEXTEN is unset, then XKEY is removed.
I think that it's wrong.
See the attached testcase. It disables the IEXTEN flag, and waits for a
few
keys. On Linux, the arrows still produce escape sequences. On FreeMiNT
(both
BIOS console and TosWin2 tw52 mode), this does not occur anymore.
So I propose to remove that IEXTEN to XKEY mapping in the MiNTLib. And
always keep XKEY enabled, like Linux.
That will fix nano on the BIOS console and TosWin tw52.
That means to me transporting a linux-bug to freemint, am I right?
If we agree to do that, I will provide a patch.
Go ahead :-)
4) Conflict between tw52 arrow codes and nano shortcuts
As said previously, M-A means Alt+A on modern terminals (not TosWin2).
This
is implemented in terminals by sending the Esc character followed by A.
So
this can also be manually simulated by pressing Esc then A. Not handy,
but
it works.
But Esc A is also the FreeMiNT kernel code for the up arrow! So there is
a
conflict between the kernel escape sequences and the nano shortcuts.
There
is no way to differentiate them.
Sure it is! Any halfway good program measures the time-gap between the Esc
and the A as I already mentioned. There is no conflict when it's done
right.
When TERM is properly configured, the arrow keys have precedence and the
shortcuts are unavailable. I believe this is correct.
They are faster, that's all.
BTW, I seem that nano manually handles a lot of escape sequences by
itself.
See src/winio.c, function get_escape_seq_kbinput(). I'm not sure if this
is
used with ncurses, though.
That's what I suspected all the time.
1) Fix TosWin2 for tw100 (see other thread)
2) Fix the MiNTLib to remove the IEXTEN to XKEY mapping
And nano will work fine in any case (after recompilation).
You'd have to test this with all currently working programs before.
--
Helmut Karlowski