enhanced_term_getc - Gets a charactor from the key-board


#include "l/l_sys_term.h"

Example compile flags (system dependent):
   -L/home/kobus/misc/load/linux_x86_64_opteron -L/usr/lib/x86_64-linux-gnu
  -lKJB                               -lfftw3  -lgsl -lgslcblas -ljpeg  -lSVM -lstdc++                    -lpthread -lSLATEC -lg2c    -lacml -lacml_mv -lblas -lg2c      -lncursesw 

int enhanced_term_getc(void);


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 return: 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


Described above


This software is not adequatedly tested. It is recomended that results are checked independantly where appropriate.


Kobus Barnard


Kobus Barnard


kjb_use_default_paging , kjb_enable_paging , kjb_disable_paging , kjb_restore_paging , is_in_background , put_prompt , term_puts , term_put_n_chars , term_put_n_raw_chars , term_get_n_chars , move_cursor_up , term_beep , term_beep_beep , term_get_line , term_getc , toggle_high_light , set_high_light , unset_high_light , term_blank_out_line , term_set_no_blocking , term_set_blocking