/* The original and new terminal definitions
(only set when not in 'Batch' mode) */
static struct termios Tty_original, // our inherited terminal definition
-#ifdef TERMIOS_ONLY
+#ifndef TERMIO_PROXY
Tty_tweaked, // for interactive 'line' input
#endif
Tty_raw; // for unsolicited input
int rc = -1;
fflush(stdout);
-#ifdef TERMIOS_ONLY
+#ifndef TERMIO_PROXY
if (ech) {
tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_tweaked);
rc = read(STDIN_FILENO, buf, cnt);
} // end: keyin
-#ifdef TERMIOS_ONLY
+#ifndef TERMIO_PROXY
/*
* Get line oriented interactive input from the user,
* using native tty support */
static char *linein (const char *prompt) {
+ static const char ws[] = "\b\f\n\r\t\v\x1b\x9b"; // 0x1b + 0x9b are escape
static char buf[MEDBUFSIZ];
+ char *p;
show_pmt(prompt);
memset(buf, '\0', sizeof(buf));
chin(1, buf, sizeof(buf)-1);
putp(Cap_curs_norm);
+ if ((p = strpbrk(buf, ws))) *p = '\0';
// note: we DO produce a vaid 'string'
return buf;
} // end: linein
* Unlike native tty input support, this function provides:
* . true line editing, not just destructive backspace
* . an input limit that's sensitive to current screen dimensions
- * . immediate signal response without the need to wait for '\n' */
+ * . immediate signal response without the need to wait for '\n'
+ * However, the user will loose the ability to paste keystrokes
+ * when this function is chosen over the smaller alternative above! */
static char *linein (const char *prompt) {
// thank goodness memmove allows the two strings to overlap
#define sqzSTR { memmove(&buf[pos], &buf[pos+1], bufMAX-pos); \
tmptty.c_iflag &= ~IGNBRK;
if (key_backspace && 1 == strlen(key_backspace))
tmptty.c_cc[VERASE] = *key_backspace;
-#ifdef TERMIOS_ONLY
+#ifndef TERMIO_PROXY
if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &tmptty))
error_exit(fmtmk(N_fmt(FAIL_tty_mod_fmt), strerror(errno)));
tcgetattr(STDIN_FILENO, &Tty_tweaked);
//#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */
//#define RMAN_IGNORED /* don't consider auto right margin glitch */
//#define STRCMPNOCASE /* use strcasecmp vs. strcmp when sorting */
-//#define TERMIOS_ONLY /* just limp along with native input only */
+//#define TERMIO_PROXY /* true line editing, beyond native input */
//#define TREE_NORESET /* sort keys do NOT force forest view OFF */
//#define TREE_ONEPASS /* for speed, tolerate dangling children */
//#define USE_X_COLHDR /* emphasize header vs. whole col, for 'x' */