home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / pcomm / part05 / s_term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-17  |  2.7 KB  |  94 lines

  1. /*
  2.  * Display the terminal setup, query for changes.  A return code of 1
  3.  * means something was changed.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <curses.h>
  8. #include "misc.h"
  9. #include "param.h"
  10.  
  11. int
  12. term_setup()
  13. {
  14.     WINDOW *t_win, *newwin();
  15.     int i, num, ret_code;
  16.     char *ans, *strdup(), *str_prompt(), *menu_prompt();
  17.     void free_ptr();
  18.     extern char *v_duplex[], *v_crio[], *v_flow[];
  19.  
  20.     t_win = newwin(23, 80, 0, 0);
  21.  
  22.     waddstr(t_win, "-------------------------------- ");
  23.     wattrstr(t_win, A_BOLD, "Terminal Setup");
  24.     waddstr(t_win, " --------------------------------");
  25.     mvwprintw(t_win, 4, 22, "1) Hot key ................ %d", param->hot);
  26.     mvwprintw(t_win, 6, 22, "2) ASCII version of hot ... %s", param->ascii_hot);
  27.     mvwprintw(t_win, 9, 22, "3) Duplex ................. %s", param->d_duplex);
  28.     mvwprintw(t_win, 11, 22, "4) Flow control ........... %s", param->flow);
  29.     mvwprintw(t_win, 13, 22, "5) CR translation (in) .... %s", param->cr_in);
  30.     mvwprintw(t_win, 15, 22, "6) CR translation (out) ... %s", param->cr_out);
  31.     mvwprintw(t_win, 19, 0, "--------------------------------------------------------------------------------");
  32.     mvwattrstr(t_win, 20, 0, A_BOLD, "OPTION ==> ");
  33.     mvwaddstr(t_win, 20, 60, "Press ESC to return");
  34.     wmove(t_win, 20, 12);
  35.     touchwin(t_win);
  36.     wrefresh(t_win);
  37.                     /* get the option number */
  38.     ret_code = 0;
  39.     while ((i = get_num(t_win, 1)) != -1) {
  40.         switch(i) {
  41.             case 1:
  42.                 if ((num = num_prompt(t_win, 4, 50, "Hot key", "decimal code for the hot key")) != -1) {
  43.                     param->hot = num;
  44.                     ret_code = 1;
  45.                 }    
  46.                 break;
  47.             case 2:
  48.                 if ((ans = str_prompt(t_win, 6, 50, "ASCII version of hot key", "(printable version)")) != NULL) {
  49.                     free_ptr(param->ascii_hot);
  50.                     param->ascii_hot = strdup(ans);
  51.                     ret_code = 1;
  52.                 }    
  53.                 break;
  54.             case 3:
  55.                 if ((ans = menu_prompt(t_win, 9, 50, "Duplex", v_duplex)) != NULL ) {
  56.                     free_ptr(param->d_duplex);
  57.                     param->d_duplex = strdup(ans);
  58.                     ret_code = 1;
  59.                 }
  60.                 break;
  61.             case 4:
  62.                 if ((ans = menu_prompt(t_win, 11, 50, "Flow control", v_flow)) != NULL ) {
  63.                     free_ptr(param->flow);
  64.                     param->flow = strdup(ans);
  65.                     ret_code = 1;
  66.                 }
  67.                 break;
  68.             case 5:
  69.                 if ((ans = menu_prompt(t_win, 13, 50, "CR translation (in)", v_crio)) != NULL ) {
  70.                     free_ptr(param->cr_in);
  71.                     param->cr_in = strdup(ans);
  72.                     ret_code = 1;
  73.                 }
  74.                 break;
  75.             case 6:
  76.                 if ((ans = menu_prompt(t_win, 15, 50, "CR translation (out)", v_crio)) != NULL ) {
  77.                     free_ptr(param->cr_out);
  78.                     param->cr_out = strdup(ans);
  79.                     ret_code = 1;
  80.                 }
  81.                 break;
  82.             default:
  83.                 beep();
  84.         }
  85.         mvwaddch(t_win, 20, 12, ' ');
  86.         clear_line(t_win, 21, 0, 0);
  87.         clear_line(t_win, 22, 0, 0);
  88.         wmove(t_win, 20, 12);
  89.         wrefresh(t_win);
  90.     }
  91.     delwin(t_win);
  92.     return(ret_code);
  93. }
  94.