Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.8 $; site trsvax Path: utzoo!watmath!clyde!cbosgd!ihnp4!inuxc!pur-ee!uiucdcs!convex!trsvax!gm From: gm@trsvax Newsgroups: net.unix Subject: Re: help - escape key detection Message-ID: <65900004@trsvax> Date: Tue, 24-Sep-85 18:40:00 EDT Article-I.D.: trsvax.65900004 Posted: Tue Sep 24 18:40:00 1985 Date-Received: Sat, 28-Sep-85 05:03:50 EDT References: <595@dicomed.UUCP> Lines: 38 Nf-ID: #R:dicomed.UUCP:-59500:trsvax:65900004:000:1964 Nf-From: trsvax!gm Sep 24 17:40:00 1985 There is this excellent book out from Prentice-Hall titled "Advanced UNIX Progamming" by Marc J. Rockland. Under the chapter devoted to signals, there is this section which talks about escape key detection: --------------------------------------------------------------------------- There's one other common use for ALARM. Ordinarily we would consider the scheme we are about to present too harebrained to be included in a sober book like this one, but because it's used in the popular text editor vi (from Berkeley), we'll describe it anyhow. The problem this scheme solves is this: Many CRT terminals transmit an escape sequence when a function key like HOME or END is pressed. Such a sequence consists of the escape character followed by a series of additional characters that indicate which key was pressed. [describes how HOME key works...] This is the solution adopted by vi: When an escape is read, the alarm clock is set to one second and then a read is issued for the next character. If read returns before the alarm goes off, it is assumed that characters could have been transmitted that quickly only if they were generated by the keyboard as a function key was pressed; if the alarm goes off (interrupting read), it is assumed that the characters were typed slowly by a human--that is, the escape itself was actually pressed. [goes on to describe problems with this system; eg. fast typist or a slow system could screw this scheme up.] --------------------------------------------------------------------------- It gives a section of code which would simulate what vi does. If you are really interested in this, you should get a copy of this book. [The text in this note is provided by an individual and is not supported by Tandy Corp. Because the original recording was made with analog equipment, the high resolution of the Compact Disk can reveal limitations of the source.] George Moore (gm@trsvax.UUCP) Brought to you by Super Global Mega Corp .com