My Backspace Key doesn't work!

Terminal emulation lets you use your PC to make a connection to anothercomputer and interact with it as if your PC were a terminal, even thoughyour PC is not really a terminal and almost certainly does not have thesame kind of keyboard as the terminal it is emulating.

One of the most confusing aspects of terminal emulation is making the PC keysdo what their keytops say they do. Many people find it quite surprising whenthe Backspace key doesn't backspace, the Arrow keys don't move the cursor, theInsert key doesn't insert, and so on. In general only the letter and digitkeys on the main keypad can be depended upon to act as their labels suggest.The rest, well... each has its own story. This is the story of the Backspacekey.

  • This discussion applies mainly to PC-based versions of Kermit:Kermit 95 andMS-DOS Kermit, which include full key-mappingcapabilities. C-Kermit for UNIX (includingLinux, FreeBSD, AIX, Solaris, HP-UX, etc) has a limited key-mapping featurethat allows backspace/delete configuration. However, most of the discussionis general information that should be useful regardless of connectionmethod and software.

  • The words "left" and "right" are used in the context of left-to-rightwriting systems like English, Russian, or Greek. For right-to-left scriptslike Hebrew or Arabic, the directionality is reversed.

First some terminology. "Backspace" might (or might not) be the name of akey. For example, it is printed on the keytop of the large key at the upperright of main keypad on the PC 101 keyboard. On the DEC keyboard, the samekey is labeled with a symbol (<X]) insteadof a word.  "Backspace" is also is the name of an ASCII controlcharacter (ASCII value 8), which might or might not be associated with theBackspace key. "Backspace" is also an abstract concept relating to computers,terminals, and typewriters, having at least two distinct meanings:

  • To erase the character left of the active position (cursor), andsimultaneously move the cursor to the position previously occupied by thatcharacter. This is called a destructive backspace.

  • To move the cursor one space to the left into the same position as thecharacter that was previously to its left, without erasing that character.This is a nondestructive backspace. Nondestructive backspacing isusually done with the Left Arrow key, discussedelsewhere.

To confuse matters even further, your keyboard might have keys other thanBackspace that suggest a destructive backspace capability. For example,modern (101-key) PC keyboards include both a "Del" and "Delete" key and one ortwo Left Arrow keys in addition to the Backspace key. These arestrictly for local PC functions and not, in general, for sending characters tothe host (but of course in Kermit 95 and MS-DOS Kermit you can map them to dowhatever you want).

To cause a destructive backspace operation, the terminal must send anappropriate code to the host, and the host must reply with appropriateterminal-specific codes to move the terminal's cursor and remove the unwantedcharacter. Unfortunately, different hosts and applications use differentcharacters (or sequences) for destructive backspace (and of course, differentterminals use different codes for screen formatting). The terminal emulator,Kermit or otherwise, has no way of knowing what host or application you areusing, or how it is configured, and therefore no way of knowing what to sendwhen you press the Backspace key.

Of course, Kermit's Backspace key must send something "out of thebox", i.e. in the absence of specific instructions from you. This isdefault backspace assignment. Each emulation (VT100, Wyse 60,Televideo, etc) has an appropriate default assignment, namely what thecorresponding key on the real terminal sends.

Therefore, it should be sufficient to tell the host (the computer you areconnected to) what your terminal type is, and then it should expect thedestructive backspace code that is associated with that terminal. Inpractice, however, this is rarely enough. In Unix(*), forexample, the terminal driver has no connection with the terminal database, sosetting or changing your terminal type in Unix has no effect on the charactersit uses for destructive backspace (or other forms of editing, such as word andline deletion).

For most emulations Kermit uses one of the two mostlikely destructive backspace values, and in fact the one that is defined inASCII to be destructive backspace, in most cases Rubout (RUB), also known asDelete (DEL), character number 127, which sometimes is displayed as"^?". Lest anyone believe this is a frivolous choice, wequote from American National Standard X3.4-1977, Section 5.1, ControlCharacters:

  • 0/8 BS (Backspace). A one-active-position format effector thatmoves the position backward on the same line.

  • 7/15 DEL (Delete). Also known as RUB (Rubout). A character usedprimarily to erase or obliterate an erroneous or unwanted character...

(Certain other emulations have their own defaults. For example Data GeneralDASHER terminals use Control-Y for character deletion, because that is whatData General operating systems such as AOS/VS expect.)

What happens if the wrong choice is made? If Delete is chosen but is not thehost's destructive backspace character, it is likely to:

  • Interrupt or cancel the current command (default SIGINT in many Unixes).
  • Be accepted as a data character and echo as "^?".
  • Be ignored.

If Backspace is chosen but is not the host's destructive backspace character,it is likely to:

  • Move the cursor to the beginning of the current line (VMS).
  • Perform a nondestructive backspace.
  • Be accepted as a data character and echo as "^H".
  • Enter "help mode" (EMACS).
  • Recall the correct part of a failing command (TOPS-20).

Even when the host terminal driver uses a specific charactersuch as Backspace for erasure, this does not guarantee that all applicationsalso use it. One well-known case in point is EMACS, which -- in effect --replaces the terminal driver with its own; in EMACS, control-characters areused as commands: Ctrl-H for Help, Ctrl-B for (cursor) Back, Ctrl-F for(cursor) Forward, etc. If you find EMACS's key definitions disconcerting,you can change them, e.g.:

(define-key global-map "\^h" 'backward-char)                 ; nondestructive
(define-key global-map "\^h" 'backward-delete-char-untabify) ; destructive

Select an Appropriate Terminal Emulation

The first step in making your Backspace key behave as expected is to choose aterminal emulation in Kermit that is appropriate for the computer you areconnecting to, and then (if necessary) tell your host what kind of terminalKermit is emulating. The command for choosing a terminal emulation in Kermitis:

SET TERMINAL TYPE name

Type a question mark (?) in place of the name to get a listof the available emulations. Here are some examples:

Host Operating SystemTerminal Type(s)
(Open)VMS, RT11, RSX, ...VT100, VT102, VT220, VT320
Digital Unix, Tru64, UltrixVT100, VT102, VT220, VT320
DECsystem-10, DECSYSTEM-20VT100, VT102
BBS'sANSI-BBS, AVATAR
AOS/VS or DG/UXD210, D215, D217, D463, D470
Stratus VOSTVI950
LinuxLINUX (or VT100, VT102, VT220, VT320)
SCO XENIX, OSR5, ODT, UNIXSCOANSI
UnixwareAT386
HP-UXHPTERM, HP2621A
AIXAIXTERM, HFT, IBM3151
SINIXSNI-97801, BA80
BeOSBETERM
QNXQNX, QANSI
Most other UNIXVT100 or VT102
3270 protocol convertersVT100, IBM3151, Heath-19

When the most appropriate emulation is not available, most hosts alsosupport VT100 and/or Wyse 50 or 60.

Inform the Host of Your Terminal Type

When you make a Telnet, Rlogin, or SSH connection from Kermit to anotherhost, Kermit informs the other host of your terminal type automaticallywith the messages appropriate to the given protocol. Normally this issufficient to achieve terminal-type agreement, but will fail if the hostuses a different name for your terminal, or does not support it at all.In that case various ruses can be used, most of which are beyond the scopeof this document.

When making network connections from Kermit to another host, you can use theSET TELNET TERMINAL-TYPE command to override the terminal-type name sentautomatically by Kermit to the Telnet, Rlogin, or SSH server on the remotehost. This is handy when the your terminal is known by a different name onthe host. A classic example occurs with SCO UNIX hosts, which use a specialSCO-specific version of "ANSI" terminal, called SCOANSI by Kermit by ANSI bySCO, which is not the same as the ANSI terminal used elsewhere (e.g. onBBS's), known to Kermit as ANSI. Thus when making a connection from Kermitto an SCO UNIX system, Kermit must be told to:

set terminal type scoansi      ; The kind of terminal to emulate
set telnet terminal-type ansi  ; The name to give to the host

When you make a serial-port or modem connection to a VMS host, as well asto certain other hosts (notably BBS's), the host might send escape sequencesdesigned to provoke responses from the terminal that might indicate its type.These probes, if they are done at all, might fail or worse (they might putyour terminal into an unusable state).

For these reasons, it is always best to configure your terminal emulatorto emulate a kind of terminal that is known to be supported on the far endof the connection.

When none of the automatic terminal-type identification methods works,you can still tell the host what kind of terminal you have, "manually",by giving a command that depends on the host operating system and, in the caseof Unix, also on the shell. Some examples (for the DEC VT100 terminal type):

set terminal /device vt100   (VMS, manual)
set terminal /inquire        (VMS, automatic)
term vt100                   (Unix if it has a 'term' command)
export TERM=vt100            (Unix ksh or bash)
setenv TERM vt100            (Unix csh)
TERM=vt100 ; export TERM     (Unix sh)
TERMINAL VT100               (DEC-20)

If the host does not support the kind of terminal you have, it is oftenpossible to tell it the name of some other kind of terminal that iscompatible. For example, suppose you are using C-Kermit on Linux to makea connection to a host that never heard of "Linux" as a terminal type.In this case you can "lie" and say you are using a VT100, because the Linuxterminal is a superset of the VT100. Note that terminal-type names inUNIX are case-sensitive; thus the VT100 or VT-100 terminal type usually mustbe given as "vt100" (lowercase) to match the entry in the host's terminalname list.

After you have successfully informed the host of your terminal type, but theBackspace key still does not work, you have two choices:

  • Change Kermit to send what the host expects.
  • Change the host to expect what Kermit sends.

Well, sometimes three choices. If the Backspace key sends the DEL characterbut the host wants the Backspace character, you can type Ctrl-H (hold down theCtrl key and press the "h" key) instead of using the Backspace key.

Changing What Kermit's Backspace Key Sends

Kermit's SET KEY command lets you redefine the Backspace key (or any otherkey) to send whatever you want it to send (or to take any other actions).

The SET KEY command has two operands: a unique identifier for a key or keycombination, called a keycode, and the value or action to be assignedto the key, called the definition:

set key keycode definition

In Kermit commands, a keycode is a number preceded by a backslash. Keycodesare likely to be different for different operating systems, keyboards, and/orKermit programs. In particular:

ProgramKeycode for Backspace Key
MS-DOS Kermit\270
Kermit 95\264
C-Kermit\127 (usually!)

(You can find out the keycode of any key or key combination by giving theSHOW KEY command. Kermit prompts you to press a key; you can press any keyor key combination and Kermit tells you the keycode.)

As noted above, the characters most commonly used by terminals to send adestructive backspace command to a host computer are single ASCII controlcharacters: Delete and Backspace. Control characters are entered into SETKEY and other Kermit commands by their numeric ASCII value, preceded bybackslash (which tells Kermit that these are character codes, rather thanliteral digits). Here are the characters used for destructive backspace, indecreasing order of likelihood (numbers are shown in decimal):

Character NameAlternative NameASCII value
Delete (DEL)Rubout (RUB)127
Backspace (BS)Control-H (^H)8
End of Medium (EM)Control-Y (^Y)25
Number Sign (#)Pound Sign35
Cancel Character (CCH)(7-bit) ESC T27   84
Cancel Character (CCH)(8-bit)148

(Number sign was used on very old Unix systems that were accessed fromTeletype hardcopy terminals; this original Unix default is still foundhere and there. CCH is an 8-bit (C1) control character from ISO 6429,which has a 7-bit coding as the sequence ESC followed by the letter T.)

Now let's put all this together to show the possible combinations:

ActionKermit 95MS-DOS Kermit
Backspace sends DELset key \264 \127 set key \270 \127
Backspace sends BSset key \264 \8set key \270 \8
Backspace sends EMset key \264 \25set key \270 \25
Backspace sends '#'set key \264 \35 set key \270 \35
Backspace sends CCHset key \264 \148 set key \270 \148
Backspace sends ESC Tset key \264 \27T set key \270 \27T

Of course other arrangements are possible too. Remember, you can assignany definition you want to any key or key combination. Some people mightprefer to have Backspace always send DEL and (say) Shift-Backspace orControl-Backspace always send Ctrl-H (or vice versa). Example for K95:

set key \264  \127      (Kermit 95: Backspace sends DEL)
set key \1151 \8        (Kermit 95: Ctrl-Backspace sends BS)

Where do I put these commands? You can give SET KEY commands at theKermit prompt, or you can put them in your Kermit customization file:MSCUSTOM.INI for MS-DOS Kermit; K95CUSTOM.INI for Kermit 95.

In Kermit 95, if you use the Dialer to make connections, you can alsochoose the Backspace-key action for each connection on the Keyboardpage of the Dialer notebook for that connection.

Changing What the Host Expects

In the days of real terminals, there was no way to change what a terminal'sBackspace (or equivalent) key sent. Therefore host operating systems suchas Unix(*) that did not require a certain kind of terminalfor access had to provide a method for adapting to different terminals.

Other host operating systems (such as VMS) always expect the same characterfor destructive backspace and you can't change it; in the VMS case, you simplyhave no choice but to configure your emulator to send DEL.

Unix hosts, however, let you change your editing and interruption characters(and much else besides) with the stty command. Theparticulars of this command vary greatly from one Unix variety to another, soyou'll need to view the documentation by typing one of the following commandsat the Unix shell prompt:

man stty
info stty

Here are a few examples:

Operating SystemView SettingsChange to BSChange to DEL
Digital Unix 4.0 stty stty erase ^hstty erase "^?"
HP-UX 8.00 stty stty erase ^hstty erase "^?"
HP-UX 10.20 stty stty erase ^hstty erase ^?
IRIX 6.5 stty -a stty erase ^hstty erase ^?
Linux stty -a stty erase ^hstty erase ^?
SCO OSR5 stty stty erase "^H"stty erase "^?"
SINIX 5.42 stty stty erase "^h"stty erase "^?"
Solaris 2.5.1 stty -a stty erase ^hstty erase ^?
SunOS 4.1 stty all stty erase ^hstty erase ^?
Ultrix 4.3 stty all stty erase ^hstty erase "^?"
Unixware 7.0 stty stty erase ^hstty erase ^?

Quoting requirements might vary from shell to shell (sh, ksh, bash, tcsh, etc).When in doubt use doublequotes as shown in many of the examples above.Note that in all cases above, the "^" character is "circumflex"or "caret", normally produced by typing Shift-6. In other words, "^h"in an stty command is circumflex followed by the letter "h", not Control-Hitself. Also note that case might be significant in the control-characterletter name: "h" or "H".

______________
*Remember, "Unix" is a genericterm covering dozens of specific operating systems, such as Linux, FreeBSD,AIX, HP-UX, Solaris, and lots of others.

When C-Kermit Is the Client

As noted in the C-Kermit FAQ,and discussed in the platform-specificsections of the C-Kermit Hints and Tips document, C-Kermit (on Unix, VMS, etc) does not have direct access tothe keyboard, and can not tell which keys have been pressed to produce thecharacters that it reads from "standard input". Therefore, there is no wayto map keys in C-Kermit.

Nevertheless, C-Kermit includes a SET KEY command similar to that ofKermit 95 and MS-DOS Kermit, but it maps characters, not keys.If your terminal's Backspace key sends a single character, you can haveC-Kermit translate it to any other desired character or sequence. To checkwhat your backspace key sends, tell C-Kermit to SHOW KEY, and then pressthe Backspace key:

C-Kermit> show key
 Press key: (press Backspace key here)
Key code \127 => Character \127 (self, no translation)
C-Kermit>

To make it send something else, use SET KEY. In the following example,we make the Backspace key send BS (ASCII 8) and then, in case we actuallyneed to send DEL (ASCII 127) in some situations, we assign it to Ctrl-H:

C-Kermit> set key \127 \8
C-Kermit> set key \8 \127

This sort of thing won't work with function (F) keys, arrow keys, editingkeypad keys, and the like, since (in most cases) they are seen by C-Kermit assequences of characters, and you can't map a sequence. To put itanother way, the only keys you can map in C-Kermit are the ones thatcorrespond with ASCII characters: letters, digits, punctuation, and controlcharacters -- CLICK HERE for a complete list --or with 8-bit single-byte characters (such as A-Umlaut on a German keyboard)if your keyboard has them.

In UNIX, you can map keys outside of Kermit in two situations:

  1. If you are using the UNIX console (physical keyboard and screen)directly, and your UNIX version includes a "loadkeys" command (as do, e.g.,Linux and SCO UNIX), you can use that to assign characters or strings tospecific keys.

  2. If you are using xterm or some other application in an X window, youcan use "xmodmap" to to assign characters or strings to specific keys.

In other situations (as when you are accessing Unix from "outside" viaTelnet, SSH, Rlogin, or modem dialup), there is no way for any software onUNIX to know what keys you have pressed. OK, this is an oversimplification:in UNIX, curses-based applications might be able to recognize theescape sequences associated with F- and arrow keys, but (a) this not reliablesince the distinction between an escape sequence generated by a key and thesame sequence entered separately is uncertain, and (b) even when thesesequences are recognized, it is only by curses-based applications, and few,if any, of these provide for any form of mapping.

Application-Specific Considerations

So many worries over one little key! And we're not done yet. Once you'vemade the connection and mapped your Backspace key to work as desired whencommunicating with the remote shell or whatever, you still might find thatit doesn't work right in certain applications, particularly full-screenand/or forms-filling ones, such as EMACS (mentioned above), menus, BBS's,or data-entry or query programs. This can happen when the program itselfdoes not use the underlying terminal driver, but reads the user's keystrokesdirectly. In this case, the application might be hard-coded to use certaincharacters for certain purposes, regardless of how they are used outsidethe application.

If the application allows keys to be remapped (in an application-specificmanner, of course), as in the EMACS example above, and you can figure outhow to do it (for each such application you use), you'll finally have aconsistently useful Backspace key. If not, you'll have to learn to copewith the keyboarding requirements of each application.

Where to Put Key Definitions

There are many possibilities:

  • Type the appropriate SET KEY commands at the Kermit prompt as needed.
  • If you want a specific mapping to be in effect at all times, put thecorresponding SET KEY command(s) in your Kermit initialization orcustomization file, which is executed automatically every time you startKermit.
  • In Kermit 95 only, you can configure the Backspace key on the Keyboardpage of the Dialer entry for each connection you have defined.
  • If different mappings must be used on different connections, you cancreate command files or macros containing those mappings,and then execute the appropriate one before making each connection.To execute a command file use the TAKE command. To execute a macro thathas already been defined (e.g. by a DEFINE command in your Kermitcustomization file) use the DO command.
  • Alternatively, create a connection script (command file or macro) foreach host or service you connect to with Kermit, and include the appropriateSET KEY commands in each script.

Consult the documentation for the Kermit program you are using for details.

----

(add " set  key  \127  \8" in .kermrc file)

====

http://www.columbia.edu/kermit/backspace.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值