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

  1. /*
  2.  * Display the setup menu, prompts for a bunch of other menus.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <curses.h>
  7. #include "misc.h"
  8.  
  9. void
  10. setup_menu(fd)
  11. int fd;
  12. {
  13.     WINDOW *s_win, *newwin();
  14.     char *ans, *get_str();
  15.     int param_flag, modem_flag;
  16.     void top_line();
  17.     extern int xmc;
  18.  
  19.     s_win = newwin(23, 80, 0, 0);
  20.  
  21.     top_line(s_win);
  22.     mvwaddstr(s_win, 4, 30, "1) TTY Setup");
  23.     mvwaddstr(s_win, 6, 30, "2) Modem Setup");
  24.     mvwaddstr(s_win, 8, 30, "3) Terminal Setup");
  25.     mvwaddstr(s_win, 10, 30, "4) General Setup");
  26.     mvwaddstr(s_win, 12, 30, "5) ASCII Transfer Setup");
  27.     mvwaddstr(s_win, 14, 30, "S) Save setup to disk");
  28.     mvwaddstr(s_win, 19, 0, "--------------------------------------------------------------------------------");
  29.     mvwattrstr(s_win, 20, 0, A_BOLD, "OPTION ==> ");
  30.     mvwaddstr(s_win, 20, 60, "  Press ESC to exit");
  31.     wmove(s_win, 20, 12);
  32.     wrefresh(s_win);
  33.  
  34.     param_flag = 0;
  35.     modem_flag = 0;
  36.                     /* get the options */
  37.     while ((ans = get_str(s_win, 1, "12345Ss", NULL)) != NULL) {
  38.         if (xmc > 0) {
  39.             clear_line(s_win, 0, 0, 0);
  40.             wrefresh(s_win);
  41.         }
  42.         switch(*ans) {
  43.             case '1':
  44.                 if (tty_setup())
  45.                     modem_flag = 1;
  46.                 break;
  47.             case '2':
  48.                 if (modem_setup())
  49.                     modem_flag = 1;
  50.                 break;
  51.             case '3':
  52.                 if (term_setup())
  53.                     param_flag = 1;
  54.                 break;
  55.             case '4':
  56.                 if (gen_setup())
  57.                     param_flag = 1;
  58.                 break;
  59.             case '5':
  60.                 if (ascii_xfer_setup())
  61.                     param_flag = 1;
  62.                 break;
  63.             case 's':
  64.             case 'S':
  65.                 if (xmc > 0)
  66.                     top_line(s_win);
  67.                 if (param_flag || modem_flag) {
  68.                     wmove(s_win, 22, 27);
  69.                     /*
  70.                      * Writes to disk are not critical,
  71.                      * the changes are made in memory.
  72.                      */
  73.                     if (param_flag) {
  74.                         wattrstr(s_win, A_BLINK, "Updating Parameter File");
  75.                         wrefresh(s_win);
  76.                         wait_key(s_win, 3);
  77.                         if (update_param()) {
  78.                             touchwin(s_win);
  79.                             wrefresh(s_win);
  80.                         }
  81.                     }
  82.                     if (modem_flag) {
  83.                         wattrstr(s_win, A_BLINK, "Updating Modem Database");
  84.                         wrefresh(s_win);
  85.                         wait_key(s_win, 3);
  86.                         if (update_modem()) {
  87.                             touchwin(s_win);
  88.                             wrefresh(s_win);
  89.                         }
  90.                     }
  91.                     clear_line(s_win, 22, 27, 0);
  92.                     wrefresh(s_win);
  93.                 }
  94.                 break;
  95.             default:
  96.                 beep();
  97.         }
  98.         touchwin(s_win);
  99.         if (xmc > 0)
  100.             top_line(s_win);
  101.     
  102.         mvwaddch(s_win, 20, 12, ' ');
  103.         wmove(s_win, 20, 12);
  104.         wrefresh(s_win);
  105.     }
  106.     if (fd == -1) {
  107.         werase(s_win);
  108.         wrefresh(s_win);
  109.     }
  110.     delwin(s_win);
  111.     return;
  112. }
  113.  
  114. /*
  115.  * Put the top line on the window.
  116.  */
  117.  
  118. void
  119. top_line(win)
  120. WINDOW *win;
  121. {
  122.     clear_line(win, 0, 0, 0);
  123.     wrefresh(win);
  124.     waddstr(win, "---------------------------------- ");
  125.     wattrstr(win, A_BOLD, "Setup Menu");
  126.     waddstr(win, " ----------------------------------");
  127.     wrefresh(win);
  128.     return;
  129. }
  130.