home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / pcomm2 / part06 / s_term.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-09-14  |  3.1 KB  |  114 lines

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