TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jon Guthrie
from: Mark Kimes
date: 1995-03-15 15:53:12
subject: Re: ASYNC help

JG>Among other effects,
 JG>I wanted to be able to allow the user to type in escape sequences
 JG>(like the ^[[A that most terminal programs transmit when you hit
 JG>the up-arrow key) and still recognize single escape characters.
 JG>The ONLY way of doing this reasonably is to use an inter-character
 JG>timeout.  It is NOT possible to do a proper inter-character timeout
 JG>without a second thread

It's not necessary to do a timeout for this sort of thing -- who cares
whether the user's terminal sent it or the user force-typed it (with
some terminals you can't tell the difference)?  To recognize single
escape characters, simply look for ^[ NOT followed immediately by [.
For my own code, I use the following method -- get a character, if it's
^[, peek (no waiting) the next character; if it's [, process balance as
an escape sequence, else process ^[ and continue.  Hasn't ever failed.

--- XHEd-OS/2 1.22
* Origin: The Pit (1:380/16)
SEEN-BY: 105/42 620/243 624/50 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 380/25 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.