Logo Search packages:      
Sourcecode: dahdi-tools version File versions  Download package

int run_menu ( void   )

This is implemented by the frontend

Definition at line 457 of file menuselect_curses.c.

References changes_made, and run_menu().

Referenced by run_menu().

{
      WINDOW *title;
      WINDOW *menu;
      int maxopt;
      int curopt = 0;
      int c;
      int res = 0;

      setenv("ESCDELAY", "0", 1); /* So that ESC is processed immediately */

      initscr();
      getmaxyx(stdscr, max_y, max_x);
      sigaction(SIGWINCH, &winch_handler, NULL); /* handle window resizing in xterm */
      sigaction(SIGINT, &sigint_handler, NULL); /* handle window resizing in xterm */

      if (max_x < MIN_X || max_y < MIN_Y) {
            fprintf(stderr, "Terminal must be at least %d x %d.\n", MIN_X, MIN_Y);
            endwin();
            return -1;
      }

      cbreak(); /* don't buffer input until the enter key is pressed */
      noecho(); /* don't echo user input to the screen */
      keypad(stdscr, TRUE); /* allow the use of arrow keys */
      clear();
      refresh();

      maxopt = count_categories() - 1;
      
      /* We have two windows - the title window at the top, and the menu window gets the rest */
      title = newwin(TITLE_HEIGHT, max_x, 0, 0);
      menu = newwin(max_y - TITLE_HEIGHT, max_x, TITLE_HEIGHT, 0);
      draw_title_window(title);     
      draw_main_menu(menu, curopt);
      
      while ((c = getch())) {
            switch (c) {
            case KEY_UP:
                  if (curopt > 0)
                        curopt--;
                  break;
            case KEY_DOWN:
                  if (curopt < maxopt)
                        curopt++;
                  break;
            case KEY_HOME:
                  curopt = 0;
                  break;
            case KEY_END:
                  curopt = maxopt;
                  break;
            case KEY_RIGHT:
            case KEY_ENTER:
            case '\n':
            case ' ':
                  c = run_category_menu(menu, curopt);
                  break;
            case 'h':
            case 'H':
                  show_help(menu);
                  break;
            case 'i':
            case 'I':
                  play_space();
                  draw_title_window(title);
            default:
                  break;      
            }
            if (c == 'q' || c == 'Q' || c == 27 || c == 3) {
                  if (changes_made) {
                        c = really_quit(menu);
                        if (c == 'q') {
                              res = -1;
                              break;
                        }
                  } else {
                        res = -1;
                        break;
                  }
            }
            if (c == 'x' || c == 'X' || c == 's' || c == 'S')
                  break;      
            draw_main_menu(menu, curopt);
      }

      endwin();

      return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index