#define COL_ID_WIDTH 25
-#define CR '\015'
#define ESC '\033'
#define DEL '\177'
#define BELL '\007'
static int
get_string(char *str, int len, char *def) {
size_t cells = 0, i = 0;
- int x, y, key;
+ int x, y;
int use_def = FALSE;
wint_t c;
refresh();
+ while (1) {
#if !defined(HAVE_SLCURSES_H) && !defined(HAVE_SLANG_SLCURSES_H) && \
defined(HAVE_LIBNCURSESW) && defined(HAVE_WIDECHAR)
- while ((key = get_wch(&c)) != ERR &&
- c != '\r' && c != '\n' && c != KEY_ENTER) {
+ if (get_wch(&c) == ERR) {
#else
- while ((c = getch()) != '\n' && c != CR) {
+ if ((c = getch()) == ERR) {
#endif
+ if (!isatty(STDIN_FILENO))
+ exit(2);
+ else
+ break;
+ }
+ if (c == '\r' || c == '\n' || c == KEY_ENTER)
+ break;
+
switch (c) {
case ESC:
move(y, x);
refresh();
key = getch();
+ if (key == ERR)
+ if (!isatty(STDIN_FILENO))
+ exit(2);
+
/* Clear out all prompts and such */
clear_warning();
for (i = y; i < ylast; i++) {
}
/* Enter equals the keyboard shortcut of current menu item */
- if (key == CR)
+ if (key == '\r')
key = menuItems[current].key;
/* Give alternatives for arrow keys in case the window manager