help - escape key detection

Oleg Kiselev x258 oleg at birtch.UUCP
Tue Oct 1 15:33:13 AEST 1985


>      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.
> 					George Moore (gm at trsvax.UUCP)

Oops! Don't lough, but it seems we wasted a few hours writing the same
damned thing... Only we used sititimer(2) ( a 4.2 BSD call - lets you set
intervals in useconds). 

But, seriously, there is a problem with that scheme as well -- some terminals
perform HOME and some other functions on the CRT ONLY -- and don't send
anything to the program... Example - HDS terminals. Or am I missing something?



More information about the Comp.unix mailing list