Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for ep/src/menu.c between version 1.5 and 1.6

version 1.5, 2002/02/20 16:59:57 version 1.6, 2002/02/21 02:22:00
Line 1 
Line 1 
 /*  /*
    VIMGCC -DSELFTEST -ggdb -Wall -pedantic -lncurses     VIMGCC -DSELFTEST -ggdb -Wall -pedantic -lncurses
    VIMGCC -DSELFTEST -ggdb -Wall -pedantic -lncurses -lefence     VIMGCC -DSELFTEST -ggdb -Wall -pedantic -lncurses -lefence
  */     */
 /*  /*
  * $Id$   * $Id$
  */   */
Line 38 
Line 38 
 #endif  #endif
   
 #if defined(SELF) || defined(SELFTEST)  #if defined(SELF) || defined(SELFTEST)
 #  define HAVE_MENU 1  #  define MENU 1
 #  define PACKAGE "ep-selftest module"  #  define PACKAGE "ep-selftest module"
 #  define VERSION "1.0"  #  define VERSION "1.0"
 #  include <stdlib.h>  #  include <stdlib.h>
Line 59 
Line 59 
 #  include "m_proctable.h"  #  include "m_proctable.h"
 #endif  #endif
   
 #if HAVE_MENU  #if MENU
 #  include <curses.h>  #  include <curses.h>
   
 #include "menu.h"  #include "menu.h"
Line 109  free_menu(menu *m)
Line 109  free_menu(menu *m)
 //      touchwin(win);  //      touchwin(win);
 delwin(win);  delwin(win);
 }  }
  */  */
   
         static int          static int
 confirm_args(char *prompt, char *format, va_list args)  confirm_args(char *prompt, char *format, va_list args)
Line 163  menu_print_option(menu *m, int n, int se
Line 163  menu_print_option(menu *m, int n, int se
                                 waddch(m->win, s[k]);                                  waddch(m->win, s[k]);
                         waddstr(m->win, (s+k+1));                          waddstr(m->win, (s+k+1));
                         wprintw(m->win, "%*s %s",                          wprintw(m->win, "%*s %s",
                                                                         (  m->width -                                          (  m->width -
                                                                            strlen(o->rtext) -                                             strlen(o->rtext) -
                                                                            strlen(o->text) - M_EXTRA + 3),                                             strlen(o->text) - M_EXTRA + 3),
                                                                         "",                                          "",
                                                                         o->rtext);                                          o->rtext);
                 }                  }
                 else{                  else{
                         mvwprintw(m->win, n + 1, 1, " %-s %*s %s ",                          mvwprintw(m->win, n + 1, 1, " %-s %*s %s ",
                                                                         o->text,                                          o->text,
                                                                         (  m->width -                                          (  m->width -
                                                                            strlen(o->rtext) -                                             strlen(o->rtext) -
                                                                            strlen(o->text) - M_EXTRA),                                             strlen(o->text) - M_EXTRA),
                                                                         "",                                          "",
                                                                         o->rtext);                                          o->rtext);
                 }                  }
                 wstandout(m->win);                  wstandout(m->win);
         }          }
Line 191  menu_print_option(menu *m, int n, int se
Line 191  menu_print_option(menu *m, int n, int se
                         wstandout(m->win);                          wstandout(m->win);
                         waddstr(m->win, (s+k+1));                          waddstr(m->win, (s+k+1));
                         wprintw(m->win, "%*s %s",                          wprintw(m->win, "%*s %s",
                                                                         (  m->width -                                          (  m->width -
                                                                            strlen(o->rtext) -                                             strlen(o->rtext) -
                                                                            strlen(o->text) - M_EXTRA + 3),                                             strlen(o->text) - M_EXTRA + 3),
                                                                         "",                                          "",
                                                                         o->rtext);                                          o->rtext);
                 }                  }
                 else {                  else {
                         mvwprintw(m->win, n + 1, 1, " %-s %*s %s ",                          mvwprintw(m->win, n + 1, 1, " %-s %*s %s ",
                                                                         o->text,                                          o->text,
                                                                         (  m->width -                                          (  m->width -
                                                                            strlen(o->rtext) -                                             strlen(o->rtext) -
                                                                            strlen(o->text) - M_EXTRA),                                             strlen(o->text) - M_EXTRA),
                                                                         "",                                          "",
                                                                         o->rtext);                                          o->rtext);
                 }                  }
         }          }
         wmove(m->win, m->selected+1, 1);          wmove(m->win, m->selected+1, 1);
Line 452  call_func:
Line 452  call_func:
                                                 else s = m->nitems - 1;                                                  else s = m->nitems - 1;
                                                 touchwin(stdscr);                                                  touchwin(stdscr);
                                                 refresh();                                                  refresh();
                         //                      touchwin(m->win);                                                  //                      touchwin(m->win);
                                                 wrefresh(m->win);                                                  wrefresh(m->win);
                                                 goto call_func;                                                  goto call_func;
                                         }                                          }
Line 465  call_func:
Line 465  call_func:
                                                 else s = 0;                                                  else s = 0;
                                                 touchwin(stdscr);                                                  touchwin(stdscr);
                                                 refresh();                                                  refresh();
                         //                      touchwin(m->win);                                                  //                      touchwin(m->win);
                                                 wrefresh(m->win);                                                  wrefresh(m->win);
                                                 goto call_func;                                                  goto call_func;
                                                 break;                                                  break;
Line 485  call_func:
Line 485  call_func:
         static int          static int
 void_exit(PROCTABLE *p_ptbl, int y, int x)  void_exit(PROCTABLE *p_ptbl, int y, int x)
 {  {
 //      touchwin(stdscr);          //      touchwin(stdscr);
         refresh();          refresh();
         switch (confirm("y/n", "Quit ?")) {          switch (confirm("y/n", "Quit ?")) {
                 case 'y':                  case 'y':
                 case 'Y':                  case 'Y':
                           clear();
                           refresh();
                           endwin();
                         exit(0);                          exit(0);
                         break;                          break;
                 default:                  default:
                         deleteln();                          deleteln();
                         break;                          break;
         }          }
         return(0);  
           return 0;
 }  }
   
 option menu_file_option[] = {  option menu_file_option[] = {
Line 582  int main(int argc, char *argv[])
Line 586  int main(int argc, char *argv[])
 {  {
         fd_set fds;          fd_set fds;
         int c;          int c;
           int quit = 0;
   
         menu_curses_init();          menu_curses_init();
   
         while (1) {          while (quit == 0) {
                 FD_ZERO(&fds);                  FD_ZERO(&fds);
                 FD_SET(0, &fds);                  FD_SET(0, &fds);
                 select(1, &fds, NULL, NULL, NULL);                  select(1, &fds, NULL, NULL, NULL);
                 if (FD_ISSET(0, &fds)) { // keybord pressed                  if (FD_ISSET(0, &fds)) { // keybord pressed
                         switch ((c = getch())) {                          switch ((c = getch())) {
                                 case 'q':                                  case 'q':
                                         exit(0);                                          quit = 1;
                                         break;                                          break;
                                 case '\033': // ESC                                  case '\033': // ESC
                                 case KEY_F(9):                                  case KEY_F(9):
Line 602  int main(int argc, char *argv[])
Line 607  int main(int argc, char *argv[])
                                         switch (confirm("y/n", "Quit ?")) {                                          switch (confirm("y/n", "Quit ?")) {
                                                 case 'y':                                                  case 'y':
                                                 case 'Y':                                                  case 'Y':
                                                         exit(0);                                                          quit = 1;
                                                         break;                                                          break;
   
                                                 default:                                                  default:
                                                         clear();                                                          clear();
                                                         refresh();                                                          refresh();
Line 618  int main(int argc, char *argv[])
Line 624  int main(int argc, char *argv[])
                         }                          }
                 }                  }
         }          }
   
         endwin();          endwin();
         exit(0);          return 0;
 }  }
   
 #endif /* #if defined(SELF) || defined(SELFTEST) */  #endif /* #if defined(SELF) || defined(SELFTEST) */
 #endif /* #if HAVE_MENU */  #endif /* #if MENU */
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top