home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / pcomm-2.0.2 / part02 / s_term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-13  |  2.8 KB  |  102 lines

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