enhanced_term_getc - Gets a charactor from the key-board
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
This routine gets a charactor from the key-board, with immediate return. It
translates some special characters such as arrow keys into symbolic form.
If the higher level code has not called term_set_raw_mode_with_no_echo()
before the first call to enhanced_term_getc(), then enhanced_term_getc makes
the call. This sets the terminal into raw mode and takes over the echoing of
characters. This means that an inadvertant exit under some systems/shells
(including sh/csh) can leave the user without character echo. The mode can be
reset using term_reset(). However, this is automaticlally done in
kjb_cleanup(), which itself is automatically called on program exit (as well
as by kjb_exit() and any abnmormal termination trapped by the KJB library.
If the call to term_set_raw_mode_with_no_echo() is in place before the call
to enhanced_term_getc(), then the call is not made.
This routine assumes that the program is being run with the terminal in raw
mode, and thus it does not change the mode back, even if it set it. The
model that is being followed is that this routine assumest that it is simply
the first routine to be called that needs the raw mode, and thus takes the
responsibility of setting it.
Although it may seem better to restore the terminal mode on exit, this leads
to a number of problems, especially with respect to typing ahead. Since I
normally use raw mode for I/O, it is best to enter into raw mode when needed
and restore the mode on program exit. Using the macro KJB_INIT() sets things
up so that most points of exit are covered by the appropriate cleanup.
Nonetheless it is not a bad idea to call kjb_cleanup() before program exit
(for systems without atexit()) and using kjb_exit() and kjb_abort() instead
of their standard counterparts. Howerver, on most platforms, not doing so
will not normally cause problems.
In addition to the integer return values that getc() has, this routine will
ERROR Unexpected read problem
INTERRUPTED Only when I/O is NOT being restarted on interupt
WOULD_BLOCK Only in non-blocking mode
ERASE_CHAR As set by "stty erase" or default
UP_ARROW Based on TERM
DOWN_ARROW Based on TERM
LEFT_ARROW Based on TERM
RIGHT_ARROW Based on TERM
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.