Hi netters,
I would like to be able to implement something analogous to cbreak
mode without going through all the extra stuff of doing curses throughout
my whole program. What I want is something that has the same effect
as the following:
cbreak(); /* cbreak mode for module display_on_tek */
ch = getch(); /* get a character into ch */
nocbreak(); /* ending cbreak mode */
without all the added stuff about linking to -lcurses and #including
<curses.h>, etc.
It seems that there should be a way to use termio calls to change
(in the parlance of the termio(7) man page on my SGI/IRIX machine) the "input
processing mode" from the "canonical" to the "non-canonical" style. Canonical
Mode Input processing is the following (from the IRIX 4.x termio(7) man page):
Normally, terminal input is processed in units of lines. A line is
delimited by a new-line (ASCII LF) character, an end-of-file (ASCII EOT)
character, or an end-of-line character. This means that a program
attempting to read will be suspended until an entire line has been typed.
Also, no matter how many characters are requested in the read call, at
most one line will be returned. It is not, however, necessary to read a
whole line at once; any number of characters may be requested in a read,
During input, erase and kill processing is normally done. The erase
character erases the last character typed, except that it will not erase
beyond the beginning of the line. The kill character kills (deletes) the
entire input line, and optionally outputs a new-line character. Both
these characters operate on a key-stroke basis, independently of any
backspacing or tabbing that may have been done. The erase and kill
characters may be changed.
Non-canonical Mode Input Processing (from the same termio man page) means:
". . . input characters are not assembled into lines, and erase and kill
processing does not occur. The MIN and TIME values are used to determine
how to process the characters received."
This would allow a single command, analogous to:
ch = getch(); /* get a character into ch */
to sleep until one, only one, and any one character was typed at the keyboard.
Then it would return that character in the variable ch to the program.
Any ideas, advice, flames ( :) ) and whatever else will be appreciated
greatly.
Dwight
----
Dwight A. Schwartz
University of Illinois at Urbana-Champaign
Department of Chemistry
Illinois EPR Research Center
217-333-3776
----