Subject: cursor keys and redhat 6

From: Matti Koskinen <[email-masked]>
Date: Tue, 20 Jul 1999 07:04:13 +0300

hello

after upgrading to rh 6, cursor keys don't work in clisp (all versions i
have) when running in xterm.
in console everything works just fine, so i think this has something to
do with Xmodmap or similar.
as for once, the installation process went ok and i didn't have to hack
anything to suit my needs,
system is as installation left it.

what things shall i look and edit?

thanks

-matti
[email-masked]

---

From: Bruno Haible <[email-masked]>
Date: Tue, 20 Jul 1999 12:47:53 +0200 (MET DST)

Matti Koskinen <[email-masked]> writes:

> do with Xmodmap or similar. ...
>

There are several places to look at, corresponding to the various processing
stages of that keypress. First, it's transformed into an X event by the
X server. Then, xterm translates it to a sequence of characters which it
feeds to the program running in xterm. Then, clisp uses the TERM environment
variable and the terminfo or termcap database to transform such an escape
sequence back to an object of type INPUT-CHARACTER or, inside the readline
library, interpret it directly.

Let's go through the various stages. I add the values I get on my RedHat/Sparc
system.

1. Look at the X event: call
     $ xev
   and type the cursor keys. It should print
           keysym 0xff97, KP_Up
           keysym 0xff96, KP_Left
           keysym 0xff98, KP_Right
           keysym 0xff99, KP_Down

   If it prints different things, then you need to tweak your Xmodmap file.

2. Analyze the sequence of characters produced by xterm: call
     $ TERM=dumb clisp -q
     > (with-keyboard (dotimes (i 20) (print (read-char *keyboard-input*))))
   and type the cursor keys. It should print

#S(SYSTEM::INPUT-CHARACTER :CHAR #\Escape :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\[ :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\A :BITS 0 :FONT 0 :KEY NIL) 

#S(SYSTEM::INPUT-CHARACTER :CHAR #\Escape :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\[ :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\D :BITS 0 :FONT 0 :KEY NIL) 

#S(SYSTEM::INPUT-CHARACTER :CHAR #\Escape :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\[ :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\C :BITS 0 :FONT 0 :KEY NIL) 

#S(SYSTEM::INPUT-CHARACTER :CHAR #\Escape :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\[ :BITS 0 :FONT 0 :KEY NIL) 
#S(SYSTEM::INPUT-CHARACTER :CHAR #\B :BITS 0 :FONT 0 :KEY NIL) 

It can also print Esc O A, Esc O D, Esc O C, Esc O B.

If that doesn't work, look at your /usr/X11R6/lib/X11/app-defaults/XTerm.

3. Check your TERM variable:

     $ echo $TERM

   It should print "xterm".

4. See whether clisp is linked with `libtermcap' or `libncurses'.
     $ ldd /usr/local/lib/clisp/lisp.run
   or
     $ strings /usr/local/lib/clisp/lisp.run | grep lib

   If it is linked with libtermcap, you have to look up in /etc/termcap
   the entries for the value of $TERM. Do "man 5 termcap". In particular,
   look at the values of "ku", "kl", "kr", "kd". They should agree with
   the escape sequences you got above.

   If it is linked with libncurses, call
     $ infocmp $TERM
   Do "man 5 terminfo". In particular, look at the values of "kcuu1",
   "kcub1", "kcuf1", "kcud1". They should agree with the escape sequences
   you got above.

5. Assuming all was ok, ask clisp whether it recognizes the escape sequences:
   $ clisp -q
   > (with-keyboard (dotimes (i 10) (print (read-char *keyboard-input*))))
   and type the cursor keys. It should print

#S(SYSTEM::INPUT-CHARACTER :CHAR NIL :BITS 8 :FONT 0 :KEY :UP) 
#S(SYSTEM::INPUT-CHARACTER :CHAR NIL :BITS 8 :FONT 0 :KEY :LEFT) 
#S(SYSTEM::INPUT-CHARACTER :CHAR NIL :BITS 8 :FONT 0 :KEY :RIGHT) 
#S(SYSTEM::INPUT-CHARACTER :CHAR NIL :BITS 8 :FONT 0 :KEY :DOWN) 

6. If that was ok, and your problem is in the readline library, look at
   your $HOME/.inputrc file. On SuSE Linux, you also have to look at
   /etc/inputrc.

Hope that helps you to get closer to the problem's source.

Bruno

---

From: Matti Koskinen <[email-masked]>
Date: Tue, 20 Jul 1999 18:59:09 +0300

> Hope that helps you to get closer to the problem's source.

everything except inputrc were ok.

/etc/inputrc didn't have cursor-key defines only ins to pgDown and they worked
just like defined. so
i defined e.g "\e[D" : backward-char but this didn't help a bit. as a matter of
fact i changed the predefined
ones to test, but it just look like readline doesn't even read inputrc. Sam,
you're running redhat 6, did you
encounter anything like this?

bash works ok, less etc. clisp is so far  the only one which is immune to cursor
keys.

????

thanks

-matti
[email-masked]

---

From: Erik Arneson <[email-masked]>
Date: Tue, 20 Jul 1999 11:12:58 -0700 (PDT)

> what things shall i look and edit?

It's been my experience that a lot of the xterm settings in RedHat 6.0
are rather broken.  I had to add the following to my .Xdefaults file to
get it to recognize the Meta/Alt key in an xterm.  This might help you,
too.

! Fix broken RedHat xterm stuff.

*eightBitInput: false
*eightBitControl: false
nxterm*Cursor: xterm

! End of file.

-- 
# Erik Arneson    [email-masked]   Webring Software Engineer #
# Yahoo! Inc.     PGP ID: 1024/6EE28A05      (541) 482-3000x105 #
# "If we couldn't laugh we would all go insane." - Jimmy Buffet #

---

From: Bruno Haible <[email-masked]>
Date: Wed, 21 Jul 1999 12:34:37 +0200 (MET DST)

Matti Koskinen writes:
> bash works ok, less etc. clisp is so far  the only one which is immune to
> cursor keys.
> ...
> i defined e.g "\e[D" : backward-char but this didn't help a bit.

/etc/inputrc is only read by some _patched_ readline libraries. (Look for
the bash sources on your RedHat CD.) clisp uses the original readline
library, which only reads $HOME/.inputrc.

You might try to copy /etc/inputrc to $HOME/.inputrc. Or replace it with
the SuSE /etc/inputrc, which I append.

Bruno

################################################################################
## /etc/inputrc
##
## Attempt to put different TERMs together in one readline init file.
## Copyright (c) 1997 S.u.S.E. GmbH Fuerth, Germany.
##
## Author: Werner Fink,  <[email-masked]>
##
################################################################################
#
# Eight bit compatible: Umlaute
#
set meta-flag on
set output-meta on
set convert-meta off
#
# VI line editing
#
$if mode=vi
set editing-mode vi
set keymap vi
$endif
#
# Common standard keypad and cursor
#
"\e[2~":	yank
"\e[3~":	delete-char
"\e[5~":	previous-history
"\e[6~":	next-history
"\e[C":		forward-char
"\e[D":		backward-char
"\e[A":		previous-history
"\e[B":		next-history
$if term=xterm
"\e[E":		re-read-init-file
$else
"\e[G":		re-read-init-file
$endif
#
# Avoid network problems
#   ... \177 (ASCII-DEL) and \010 (ASCII-BS)
#       do `backward-delete-char'
# Note: `delete-char' is maped to \033[3~
#       Therefore xterm's responce on pressing
#       key Delete or KP-Delete should be
#       \033[3~ ... NOT \177
#
"\C-?":		backward-delete-char
"\C-H":		backward-delete-char
#
# Home and End
#
$if term=xterm
#
# Normal keypad and cursor of xterm
#
"\e[1~":	history-search-backward
"\e[4~":	set-mark
"\e[H":		beginning-of-line
"\e[F":		end-of-line
# Home and End of application keypad and cursor of xterm
"\eOH":		beginning-of-line
"\eOF":		end-of-line
$else
#
# TERM=linux or console
#
"\e[1~":	beginning-of-line
"\e[4~":	end-of-line
$endif
#
# Application keypad and cursor of xterm
#
$if term=xterm
"\eOD":         backward-char
"\eOC":         forward-char
"\eOA":         previous-history
"\eOB":         next-history
"\eOE":         re-read-init-file
# DEC keyboard KP_F1 - KP_F4
"\eOP":		prefix-meta
"\eOQ":		undo
"\eOR":		""  
"\eOS":		kill-line
$endif
#
# Function keys F1 - F12
#
$if term=linux
#
# On console the first five function keys
#
"\e[[A":	""
"\e[[B":	""
"\e[[C":	""
"\e[[D":	""
"\e[[E":	""
$else
#
# The first five standard function keys
#
"\e[11~":	""
"\e[12~":	""
"\e[13~":	""
"\e[14~":	""
"\e[15~":	""
$endif
"\e[17~":	""
"\e[18~":	""
"\e[19~":	""
"\e[20~":	""
"\e[21~":	""
# Note: F11, F12 are identical with Shift_F1 and Shift_F2
"\e[23~":	""
"\e[24~":	""
#
# Shift Function keys F1  - F12
#      identical with F11 - F22
#
#"\e[23~":	""
#"\e[24~":	""
"\e[25~":	""
"\e[26~":	""
# DEC keyboard: F15=\e[28~ is Help
"\e[28~":	""
# DEC keyboard: F16=\e[29~ is Menu
"\e[29~":	""
"\e[31~":	""
"\e[32~":	""
"\e[33~":	""
"\e[34~":	""
$if term=xterm
# Not common
"\e[35~":	""
"\e[36~":	""
$endif
#
$if term=xterm
#
# Application keypad and cursor of xterm
# with NumLock ON
#
# Operators
"\eOo":		"/"
"\eOj":		"*"
"\eOm":		"-"
"\eOk":		"+"
"\eOl":		"+"
"\eOM":		accept-line
# Colon and dot
# "\eOl":		","
"\eOn":		"."
# Numbers
"\eOp":		"0"
"\eOq":		"1"
"\eOr":		"2"
"\eOs":		"3"
"\eOt":		"4"
"\eOu":		"5"
"\eOv":		"6"
"\eOw":		"7"
"\eOx":		"8"
"\eOy":		"9"
$endif
#
#  EMACS line editing
#
$if mode=emacs
#
# ... xterm application cursor
#
$if term=xterm
"\e\eOD":	backward-word
"\e\eOC":	forward-word
"\e\eOA":	up-history
"\e\eOB":	down-history
"\C-\eOD":	backward-char
"\C-\eOC":	forward-char
"\C-\eOA":	up-history
"\C-\eOB":	down-history
$endif
#
# Standard cursor
#
"\e\e[D":	backward-word
"\e\e[C":	forward-word
"\e\e[A":	up-history
"\e\e[B":	down-history
"\C-\e[D":	backward-char
"\C-\e[C":	forward-char
"\C-\e[A":	up-history
"\C-\e[B":	down-history
$endif
#
# end
#

---

From: Matti Koskinen <[email-masked]>
Date: Fri, 23 Jul 1999 10:23:36 +0300

> library, which only reads $HOME/.inputrc.

redhat 6 defines INPUTRC=/etc/inputrc. according to man-pages, if INPUTRC is not
set,
.inputrc is read. but i've tried .inputrc too.
strace clisp shows that /etc/inputrc is read, but strace prints some strange
sigsegv's  when reading
inputrc, .Xdefaults etc. actual error is not raised, so these can probably be
ignored.
strangest thing is that bash, though it works,  doesn't even with bind change the
key definitions.
i've asked in one linux newsgroup this and i'm waiting if somebody knows more, or
is this just a bug in
readline.

i even compiled clisp from sources, but that didn't help.
Control-b -e -n and -p works in clisp ok.

> the SuSE /etc/inputrc, which I append.

thanks, i'll try

-matti
[email-masked]