This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RXVT doesn't recognize ALT + Cursor keys


Corinna Vinschen wrote:
I'm just a bit puzzled about the key codes.  By default, when rxvt is
invoked without explicitely setting the terminal name (-tn option),
rxvt is recognized as an xterm.

This is a configure option for rxvt (--with-term=) which defaults to "xterm". There are a few differences between rxvt (and rxvt-native-cygwin and rxvt-cygwin) and xterm, such as the ACS character codes -- and Home, End, Delete, and BackSpace handling. (Original xterm didn't even specify Home/End. Ones newer than ten years do, tho, only differently than rxvt).


I've always thought rxvt should report 'rxvt', but since SteveO's original version used the default 'xterm' settings, I've never changed it. It *mostly* works in that mode -- and 'xterm' is ALWAYS available in /etc/termcap or */terminfo/*, while even the undecorated 'rxvt' might be missing. Like on gentoo-embedded without ncurses-extra-terminfo installed.

So, in the absence of -tn, cygwin's rxvt will continue to default to 'xterm' -- but 'xterm' is NOT a perfect match for rxvt's terminal handling, and we shouldn't try to make it so. If we did, then cygwin's rxvt would just be broken on systems that actually HAVE the correct (undecorated) 'rxvt' terminfo installed.

However, if it is the list's opinion, I'm willing to be persuaded that cygwin's rxvt should default to setting TERM=rxvt in the absence of -tn...

 The cursor keys correctly return
ESC [ A to ESC [ D.  However, the Home and End keys return ESC [ 7 ~
and ESC [ 8 ~, while a real xterm returns ESC [ H and ESC [ F.

From the terminfo.src file, distributed with ncurses, in the xterm-color section:


"This description [ed: of xterm-color] is "compatible" with color_xterm, rxvt and XFree86 xterm, except that each of those implements the home, end, delete keys differently."

So, yeah, here's what terminfo.src says about rxvt-basic:

#                   Normal       Shift        Control      Ctrl+Shift
#  Tab              ^I           ESC [ Z      ^I           ESC [ Z
#  BackSpace        ^H           ^?           ^?           ^?
#  Find             ESC [ 1 ~    ESC [ 1 $    ESC [ 1 ^    ESC [ 1 @
#  Insert           ESC [ 2 ~    paste        ESC [ 2 ^    ESC [ 2 @
#  Execute          ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
#  Select           ESC [ 4 ~    ESC [ 4 $    ESC [ 4 ^    ESC [ 4 @
#  Prior            ESC [ 5 ~    scroll-up    ESC [ 5 ^    ESC [ 5 @
#  Next             ESC [ 6 ~    scroll-down  ESC [ 6 ^    ESC [ 6 @
#  Home             ESC [ 7 ~    ESC [ 7 $    ESC [ 7 ^    ESC [ 7 @
#  End              ESC [ 8 ~    ESC [ 8 $    ESC [ 8 ^    ESC [ 8 @
#  Delete           ESC [ 3 ~    ESC [ 3 $    ESC [ 3 ^    ESC [ 3 @
#  F1               ESC [ 11 ~   ESC [ 23 ~   ESC [ 11 ^   ESC [ 23 ^
... more function keys ...
#  Up               ESC [ A      ESC [ a      ESC O a      ESC O A
#  Down             ESC [ B      ESC [ b      ESC O b      ESC O B
#  Right            ESC [ C      ESC [ c      ESC O c      ESC O C
#  Left             ESC [ D      ESC [ d      ESC O d      ESC O D
#  KP_Enter         ^M                                     ESC O M
#  KP_F1            ESC O P                                ESC O P
#  KP_F2            ESC O Q                                ESC O Q
#  KP_F3            ESC O R                                ESC O R
#  KP_F4            ESC O S                                ESC O S
#  XK_KP_Multiply   *                                      ESC O j
#  XK_KP_Add        +                                      ESC O k
#  XK_KP_Separator  ,                                      ESC O l
#  XK_KP_Subtract   -                                      ESC O m
#  XK_KP_Decimal    .                                      ESC O n
#  XK_KP_Divide     /                                      ESC O o
#  XK_KP_0          0                                      ESC O p
... more keypad numbers ...

Ok, so I set the terminal to rxvt-cygwin-native as suggested in the
README file.

Frankly, plain old "rxvt" (or rxvt-color, or rxvt-xpm: all three are identical) will work just as well. The only difference between the cygwin variants and rxvt is the ACS charset. And the two cygwin variants differ between each other in only ONE character in that charset.


Now the Home and End keys are ok, because the termcap/terminfo entry
for these keys is matching.  However, the termcap/terminfo entries
expect ESC O A to ESC O D for the cursor keys but, as I wrote above,
rxvt returns the xterm sequences ESC [ A to ESC [ D, so the cursor
keys don't work anymore.

I used to have to fix my /etc/termcap. But now the /etc/termcap in termcap-20050421-1.tar.bz2 says:


rxvt|rxvt terminal emulator (X Window System):\
:am:eo:km:mi:ms:xn:xo:\
:co#80:it#8:li#24:\
:AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:\
:K1=\EOw:K2=\EOu:K3=\EOy:K4=\EOq:K5=\EOs:LE=\E[%dD:\
:RI=\E[%dC:UP=\E[%dA:ae=^O:al=\E[L:as=^N:bl=^G:cd=\E[J:\
:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:cr=^M:\
:cs=\E[%i%d;%dr:ct=\E[3g:dc=\E[P:dl=\E[M:do=^J:ei=\E[4l:\
:ho=\E[H:i1=\E[?47l\E=\E[?1l:ic=\E[@:im=\E[4h:\
:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\
:k0=\E[21~:k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~:\
:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:k9=\E[20~:\
:kD=\E[3~:kI=\E[2~:kN=\E[6~:kP=\E[5~:kb=^H:kd=\E[B:ke=\E>:\
:kh=\E[7~:kl=\E[D:kr=\E[C:ks=\E=:ku=\E[A:le=^H:mb=\E[5m:\
:md=\E[1m:me=\E[m\017:mr=\E[7m:nd=\E[C:rc=\E8:sc=\E7:\
:se=\E[27m:sf=^J:so=\E[7m:sr=\EM:st=\EH:ta=^I:\
:te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:ue=\E[24m:up=\E[A:\
:us=\E[4m:vb=\E[?5h\E[?5l:ve=\E[?25h:vi=\E[?25l:\
:vs=\E[?25h:
rxvt-cygwin-native|rxvt terminal emulator (native MS Window System port) on cygwin:\


:ac=+\257,\256-^0\333`\004a\261f\370g\361h\260j\331k\277l\332m\300n\305o
~p\304q\304r\304s_t\303u\264v\301w\302x\263y\363z\362{\343|\330~\376:\
        :tc=rxvt:


Two things:


#1) this /etc/termcap does not have an explicit rxvt-cygwin (that is, X11) terminal. That's a bug, and should probably be fixed by the termcap cygwin package maintainer.

#2) For termcap, the arrow key spellings are:
       kd=\E[B  ku=\E[A  kl=\E[D  kr=\E[C

I don't see where you're getting ESC O A from that. Ditto the terminfo:

$ infocmp -I rxvt-basic

#Reconstructed via infocmp from file: /usr/share/terminfo/r/rxvt-basic
rxvt-basic|rxvt terminal base (X Window System),
	am, bce, xenl, eo, mir, msgr, xon,
	cols#80, it#8, lines#24,
	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
	bel=^G, cr=^M, csr=\E[%i%p1%d;%p2%dr, tbc=\E[3g,
	clear=\E[H\E[2J, el1=\E[1K, el=\E[K, ed=\E[J,
	cup=\E[%i%p1%d;%p2%dH, cud1=^J, home=\E[H, civis=\E[?25l,
	cub1=^H, cnorm=\E[?25h, cuf1=\E[C, cuu1=\E[A, dl1=\E[M,
	enacs=\E(B\E)0, smacs=^N, blink=\E[5m, bold=\E[1m,
	smcup=\E7\E[?47h, smir=\E[4h, rev=\E[7m, smso=\E[7m,
	smul=\E[4m, rmacs=^O, sgr0=\E[0m\017,
	rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmso=\E[27m,
	rmul=\E[24m, flash=\E[?5h\E[?5l, is1=\E[?47l\E=\E[?1l,
	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
	ich1=\E[@, il1=\E[L, ka1=\EOw, ka3=\EOy, kb2=\EOu, kbs=^H,
	kcbt=\E[Z, kc1=\EOq, kc3=\EOs, kdch1=\E[3~, kcud1=\E[B,
	kend=\E[8~, kent=\EOM, kel=\E[8\^, kf1=\E[11~, kf10=\E[21~,
	kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
	kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
	kf19=\E[33~, kf2=\E[12~, kf20=\E[34~, kf21=\E[23$,
	kf22=\E[24$, kf23=\E[11\^, kf24=\E[12\^, kf25=\E[13\^,
	kf26=\E[14\^, kf27=\E[15\^, kf28=\E[17\^, kf29=\E[18\^,
	kf3=\E[13~, kf30=\E[19\^, kf31=\E[20\^, kf32=\E[21\^,
	kf33=\E[23\^, kf34=\E[24\^, kf35=\E[25\^, kf36=\E[26\^,
	kf37=\E[28\^, kf38=\E[29\^, kf39=\E[31\^, kf4=\E[14~,
	kf40=\E[32\^, kf41=\E[33\^, kf42=\E[34\^, kf43=\E[23@,
	kf44=\E[24@, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
	kf8=\E[19~, kf9=\E[20~, kfnd=\E[1~, khome=\E[7~,
	kich1=\E[2~, kcub1=\E[D, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
	kcuf1=\E[C, kDC=\E[3$, kslt=\E[4~, kEND=\E[8$, kHOM=\E[7$,
	kIC=\E2$, kLFT=\E[d, kNXT=\E[6$, kPRV=\E[5$, kRIT=\E[c,
	kcuu1=\E[A, rmkx=\E>, smkx=\E=, dl=\E[%p1%dM,
	cud=\E[%p1%dB, ich=\E[%p1%d@, il=\E[%p1%dL,
	cub=\E[%p1%dD, cuf=\E[%p1%dC, cuu=\E[%p1%dA,
	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h,
	rc=\E8, sc=\E7, ind=^J, ri=\EM, s0ds=\E(B, s1ds=\E(0,
	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;m%?%p9%t\016%e\017%;,
	hts=\EH, ht=^I, u6=\E[%i%d;%dR, u7=\E[6n, u8=\E[?1;2c,
	u9=\E[c,

Where the arrow key spellings are:

kcub1=\E[D kcuf1=\E[C cuf1=\E[C, cuu1=\E[A,

So again, I don't see where you're getting ESC O A from that. Are you sure your installed termcap and terminfo files haven't been corrupted? I really believe The Right Thing To Do is to ensure /etc/termcap and and/usr/share/terminfo/ are up to date, rather than make rxvt's terminal handling on cygwin different than on all other platforms.

So the question is, how is that supposed to work?  Wouldn't it make
sense to change the escape sequences of Home and End key to their xterm
equivalents and drop the idea to set TERM to rxvt-cygwin-native?
At least this looks like the simpler approach, rather than changing
the termcap/terminfo entries of the world...

Well, the rest of the world's 'rxvt' terminfo is correct as far as Home/End/Delete/BS goes -- even for cygwin -- IF it is installed. The cygwin variants are actually in most distributions' terminfo by now, too. termcap...well, termcap just sucks, which is why it was replaced 15 years ago.


But even there, IF you have plain old 'rxvt' in your termcap, that's usually good enough unless you're a stickler for line art characters. rxvt's TERM setting defaults to xterm only because it will almost ALWAYS be present, and will *mostly* work.

Again, perhaps THAT is the behavior that should change: without -tn, rxvt should report 'rxvt' not 'xterm' (folks would still have to explicitly set TERM to get the proper ACS chars for cygwin-specific modes)

Comments?

(More on the proposed patch, downthread)

--
Chuck


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]