Faximum TechNote #095

Faximum TechNote #095

(http://www.faximum.com/technotes/095)

TITLE:    #095 - Problems with Terminal Function & Cursor Keys

KEYWORDS: terminal cursor function keys terminfo VT-100 VT-220 telnet xterm

RELEASE:  Faximum ELS/PLUS

CLASSIFICATION: ELS-PLUS

PROBLEM:  A user reports that some or all of the function and/or cursor
          keys on his terminal are not recognised by the Faximum user 
	  interface.


CAUSE:	  Faximum relies on the operating system terminfo libraries to
	  determine what escape sequences are generated by the different
	  cursor/function keys on the terminal.  If Faximum does not 
	  recognise a certain key it is because the sequence being generated
	  by the terminal is different from that described in the operating
	  system's terminfo database.


SOLUTION: This TechNote describes how to determine what escape sequences
	  are being generated by a given key and how to determine what 
	  escape sequence are expected.


	  Section I - Determining the Escape Sequence Generated by a Key
	  --------------------------------------------------------------

	  To determine the escape sequence generated by a function key, run
	  the cat program with the -v flag (i.e. type 'cat -v') and then 
	  press each of the function keys in turn (F1 through F8).
	
	  This will cause the escape sequence generated by the function keys
	  to appear on the screen.  It might look like: ^[p

	  Note that ^[ is shorthand for the ESC character.

	  When you are finished you can exit cat by pressing:
		1.  the "Enter" or "Carriage Return" key
		2.  the CTRL-D key
	

	  Section II - Determining the Escape Sequence Expected from a Key
	  ----------------------------------------------------------------
	  
	  In order to determine what escape sequence your operating system 
	  is expecting from the various function keys you can either examine 
	  the source files for the terminfo database or (on SCO and some 
	  other Intel versions of UNIX) request the terminfo description for 
	  a particular terminal.

	  The source files that are used to create the terminfo database
	  are usually found in /usr/lib/terminfo or /usr/share/lib/terminfo
	  in files with a .src or .ti suffix.

	  If you examine the file(s) which contain the descriptions for the
	  terminals you are interested in, you will see a list of parameters
	  for each terminal.  The kf1 through kf8 parameters define the
	  escape sequence expected from the terminal for function keys 1
	  through 8.  Parameters kcub1 (left cursor), kcud1 (down cursor), 
	  kcuf1 (right cursor), and kcuu1 (up cursor) describe the cursor
	  keys.

	  Note that in the terminfo source file \E represents the ESC 
	  character (which appears as ^[ in vi).  Note also that if
	  the sequence ends with a carriage return (i.e. \r), you will not
	  be able to see the carriage return when you press the function key
	  in vi.

	  With SCO and Linux you can also obtain a list of terminfo 
	  parameters for your terminals by running the
	  infocmp or untic programs.  Make sure that your TERM 
	  environment variable is set and type:
		infocmp
	  or
		untic
	  
	  This ought to produce a list of parameters for your terminal.
	  Again, examine the values for the kf1 through kf8 parameters (or,
	  if the problem is with the cursor keys, the various kcu paramaters)
	  to see what escape sequences the terminal ought to be generating and
	  compare this with what you observed using vi (as described above).

	  
	  Section III - Some Common Cases
	  ----------------------------------------------------------------

	  III(a) - SCO

	  There are a number of special cases related to DEC terminals (or
	  software which emulate DEC terminals).

	  On some DEC terminals (vt2x0 and vt3x0), the F5 key does not, in
	  fact, send an escape sequence.  To obtain the F5 escape sequence
	  you may have to press the F6 key (similarly, press the F7 key in
	  place of F6, etc.)

	  On some SCO operating systems, the standard vt220 terminal type
	  "maps F5--F9 to the second block of function keys at the top of 
	  the keyboard".  The alternate vt220d terminal type  uses a
	  different mapping: "This vt220 description regards F6--F10 as the 
	  second block of function keys # at the top of the keyboard....
	  and agrees with the labeling on some terminals that emulate the 
	  vt220.  There is no support for an F5."

	  On DEC VT-100 terminals the problem is that there are no function
	  keys above PF4.  On these terminals it has been the practice to
	  switch the numeric keypad into an extended function key mode and
	  consider key pad 4 to be function key 5, key pad 5 to be F6,
	  key pad 6 to be F7, and the key pad , (comma) to be F8.  We agree
	  that these are not intuitive and might suggest that if this causes
	  problems then you might consider rewriting the terminfo description
	  for your terminal.


	  III(b) - AIX

	  Note that on some versions of AIX it is not possible to use
	  DEC terminals without additional custom terminfo descriptions
	  (the ones provided with AIX do not provide a complete set of
	  function keys from F1 through F8).

	  Users who wish to develop special terminfo descriptions or who
	  need to support DEC terminals with the AIX version of Faximum
	  ought to contact Faximum Technical Support for assistance.


	  III(c) - Windows telnet Programs

	  Customer who wish to use telnet programs under Windows to
	  connect to UNIX or Linux servers to run the full-screen
	  Faximum ELS & PLUS user interface ought to realise that the
	  standard Windows telnet program does NOT support function
	  keys above F4. Faximum recommends the use of the "PuTTY"
	  telnet program available from:
	  	http://www.chiark.greenend.org.uk/~sgtatham/putty/
	
	  We have tested PuTTY with Linux using both the TERM=xterm
	  and the TERM=linux settings.

	  
	  Section IV - What to Do if All Else Fails
	  ----------------------------------------------------------------

	  If you are unable, after examining the terminfo description for
	  your terminal, to determine the cause of your problem, then
	  please e-mail or fax the following information to Faximum
	  Technical Support:

	    a) a list of the function or cursor keys are causing the problem;

	    b) an indication of the terminals are experiencing the problem 
	       (all terminals, or only certain terminals);

	    c) a list of the exact steps to take to reproduce the problem on
	       your system;

	    d) the make and model of the terminals causing the problems
	       and an indication of whether you are actually using
	      a terminal or a PC emulating a terminal, and if the
	       latter, the details of how the terminal is connected
	       to the computer (i.e. by a serial cable or by TCP/IP);

	    e) the output of the following command:
			echo $TERM

	    f) the output of the untic or infocmp command as described
	       above.

	    g) the escape sequence being sent by the terminal when you
	       please the function or cursor key(s) that are causing the
	       problem (using the method described in Section I above).

	  With this information Technical Support will try to determine
	  what is causing your problem.
		

TechNote: 095 - Copyright 1995-2001 Faximum Software Inc., All Rights Reserved.
Last Updated: Sun Apr 29 00:31:50 PDT 2001
Find all Faximum TechNotes at http://www.faximum.com/support

© Copyright 2001 Faximum Software Inc. All Rights Reserved.