home *** CD-ROM | disk | FTP | other *** search
- #include <curses.h>
- #include <ctype.h>
- #include "c_term.h"
-
- int get_bool(Default)
- int Default;
-
- /*
- ---------------------------------------------------------------------------
-
- Last revision -
- 6 January 1985 - GWS
- Change to use curses
-
- 16 November 1984 - GWS
- Ignore XON, XOFF
-
- 11 April 1984 - GWS
-
-
- NAME
- get_bool - "crash-proof" routine for terminal input of boolean
-
- SYNOPSIS
- int get_bool(Default)
- int Default;
-
- DESCRIPTION
- This routine prompts and nudges the user through entry of a
- boolean value.
-
- SEE ALSO
-
-
- DIAGNOSTICS
- none
-
- BUGS
- none known
-
- AUTHOR
- George W. Sherouse
- 11 April 1984
-
- ---------------------------------------------------------------------------
- */
-
- {
- int c;
- int val,
- where_y,
- where_x;
-
- getyx(stdscr, where_y, where_x);
- standout();
-
- val = Default;
- while (1)
- {
- if (val)
- mvprintw(where_y, where_x, "yes");
- else
- mvprintw(where_y, where_x, "no ");
- refresh();
-
- switch (c = (getch() & 0177))
- {
- #ifdef ABORT_CHAR
- case ABORT_CHAR:
- clear();
- standend();
- mvprintw(0, 0, "Program aborted at your request...");
- move(LINES - 1, 0);
- refresh();
- endwin();
- exit(0);
- break;
- #endif ABORT_CHAR
-
- case '\015':
- standend();
- if (val)
- mvprintw(where_y, where_x, "yes");
- else
- mvprintw(where_y, where_x, "no ");
- refresh();
- return(val);
- break;
- case ' ':
- val = !val;
- break;
- case 'y':
- case 'Y':
- val = 1;
- break;
- case 'n':
- case 'N':
- val = 0;
- break;
- case '\021':
- case '\023':
- break;
- default:
- fprintf(stderr, "%c", '\007');
- }
- }
- }
-