Re: ESCAPE key (was Re: How can I assign the interrupt action...)
Posted in 1992
In article <9153@emory.mathcs.emory.edu>, carsinfo!carsmax!bryan@uceng.uc.edu (Bryan Klopfenstein) writes: |> However, I'm also confused. Isql uses the ESCAPE key to start a query, |> the ubiquitous vi uses the ESCAPE key and escape sequences (such as |> arrow keys) quite well. Many programs use the ESCAPE key to interrupt |> or cancel the current operation -- unlike isql which uses it to start |> EXECUTING, probably the reason for your customer's request. I've seen ESCAPE used for interrupts in DOS programs, but never under UNIX. The typical UNIX use is marking the end of input, as in vi or perform. Are you sure you're not thinking of DOS? |> How can all these other programs work so well under what appear to be |> the same constraints you explain above? The usual method for distinguishing ESCAPE from escape sequences that start with ESCAPE is simple but ugly: you sleep for a short while, and see any more characters have arrived that look like the rest of an escape sequence. If not, then you figure it was really just an ESCAPE. (This means that there's a slight delay in the processing of the ESCAPE key: before I figured this out, I used to wonder why there was always a pause after I typed ESCAPE to a CONSTRUCT statement ...) But this trick is based on receiving ESCAPE as an ordinary character. If you make it the interrupt character, then read() doesn't return it: you just get the signal instead. And if there are characters in the queue that you haven't read yet, you'll get the ESCAPE first, effectively out of sequence :-( I don't know how all this works under DOS, but obviously it's different. -- Harry Bochner bochner@das.harvard.edu