Arrow keys not working with vt510

John Goerzen <[email protected]> Mon, 15 Feb 2021 00:30:37 -0600
Newsgroups gmane.comp.gnu.screen.user
Message-ID <[email protected]>
Hi folks,

I have a vt510 (yes, a literal vt510 terminal from the 90s, says 
DEC on the front and everything).  It is set to native vt510 
emulation mode.  It is working fine outside of screen.

Inside screen, the arrow keys are, shall we say, inconsistent:

The are working in:

shell
emacs

Not working with:

less
top
screen's own copy and paste (C-a ESC)

I am highly suspicious that there is an issue with application 
keypad mode here.  In that mode, the terminal sends different 
escape sequences for the arrow keys.  The screen manpage talks 
about this a bit and it seems that screen is aware of it. 
However, it also seems that screen isn't quite handling it right.

I have tried it with TERM=vt510 and TERM=vt420 before starting 
screen.  Within screen, I've tried with TERM=screen and 
TERM=vt100.

If I look at "infocmp vt510", I see:

kcuu1=\E[A

Which is indeed what the vt510 sends in non-application mode 
(confirmed via hd).  With "infocmp screen", it is:

kcuu1=\EOA,

Which is what the vt510 is documented to send in application mode, 
though I haven't been able to confirm or deny this.  This sequence 
also matches the vt100 sequence.

The :info command in screen shows the terminal in app mode in 
emacs and less.  It looks to me like screen may put the vt510 in 
app mode the moment it starts, but again I haven't been able to 
conclusively verify this.

I am speculating here that there is some bug in how this is being 
handled, but I can't immediately figure out where.

Any ideas appreciated.

Thanks,

John