home *** CD-ROM | disk | FTP | other *** search
- /*
- * Display the terminal setup, query for changes. A return code of 1
- * means something was changed.
- */
-
- #include <stdio.h>
- #include <curses.h>
- #include "misc.h"
- #include "param.h"
-
- int
- term_setup()
- {
- WINDOW *t_win, *newwin();
- int i, num, ret_code;
- char *ans, *strdup(), *str_prompt(), *menu_prompt();
- void free_ptr();
- extern char *v_duplex[], *v_crio[], *v_flow[];
-
- t_win = newwin(23, 80, 0, 0);
-
- waddstr(t_win, "-------------------------------- ");
- wattrstr(t_win, A_BOLD, "Terminal Setup");
- waddstr(t_win, " --------------------------------");
- mvwprintw(t_win, 4, 22, "1) Hot key ................ %d", param->hot);
- mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
- mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
- mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
- mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
- mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
- mvwprintw(t_win, 19, 0, "--------------------------------------------------------------------------------");
- mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
- mvwaddstr(t_win, 20, 60, "Press ESC to return");
- wmove(t_win, 20, 12);
- touchwin(t_win);
- wrefresh(t_win);
- /* get the option number */
- ret_code = 0;
- while ((i = get_num(t_win, 1)) != -1) {
- switch(i) {
- case 1:
- if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
- param->hot = num;
- ret_code = 1;
- }
- break;
- case 2:
- if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
- free_ptr(param->ascii_hot);
- param->ascii_hot = strdup(ans);
- ret_code = 1;
- }
- break;
- case 3:
- if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL ) {
- free_ptr(param->d_duplex);
- param->d_duplex = strdup(ans);
- ret_code = 1;
- }
- break;
- case 4:
- if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL ) {
- free_ptr(param->flow);
- param->flow = strdup(ans);
- ret_code = 1;
- }
- break;
- case 5:
- if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL ) {
- free_ptr(param->cr_in);
- param->cr_in = strdup(ans);
- ret_code = 1;
- }
- break;
- case 6:
- if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL ) {
- free_ptr(param->cr_out);
- param->cr_out = strdup(ans);
- ret_code = 1;
- }
- break;
- default:
- beep();
- }
- mvwaddch(t_win, 20, 12, ' ');
- clear_line(t_win, 21, 0, 0);
- clear_line(t_win, 22, 0, 0);
- wmove(t_win, 20, 12);
- wrefresh(t_win);
- }
- delwin(t_win);
- return(ret_code);
- }
-