doelz@urz.unibas.ch (04/13/91)
I want to show a menu on the screen which is similar to the one you get from SMG$. The curses package available on VAX C gives the problem that the cursor key is read as terminator instead of a cursor key. On ultrix, I cannot even compile it poroperly (it does not matter whether I use curses.h or cursesX.h). On another Unix box, I can compile it and it looks shown below. The cursor key is readily interpreted as <ESC>[A as it should. I would be grateful if someone in netland could explain me what goes wrong on the VMS side or even get me a piece of code which builds a menu and selects an item. Regards Reinhard ************************************************************************ Dr. Reinhard Doelz * EAN doelz@urz.unibas.ch Biocomputing * DECNET 48130::doelz Biozentrum der Universitaet * X25 psi%46211142::embnet Klingelbergstrasse 70 * FAX x41 61 256760 CH 4056 Basel * TEL x41 61 253880 ext 888 ************************************************************************ modl [/biology/code] % ./test l-----------------------------------------------------------------------------k |hello 1 hello 2 hello 3 hello 1 hello 5 | | | |hello 6 hello 7 | | | | | Input character was: 27 | | | second Input character was: 91-----------------------------------------------j third Input character was: 68 give any key to stop Source code: /* */ #include <curses.h> #include <stdio.h> /* globals */ WINDOW *window_window; /* the array declaration for manu items*/ char *menu_def[15]; static void doCreateWindows( ); static void doMapWindows( ); static void read_menu_items( ); static void display_menu_items( ); static void doHandleEvents( ); static void end_of_program( ); static void doInitialize( ); /********************** The main program *******************************/ main() { doInitialize( ); display_menu_items( ); doHandleEvents( ); end_of_program( ); } /***************** doInitialize **************************/ static void doInitialize( ) { doCreateWindows( ); doMapWindows( ); read_menu_items( ); } /******* doCreateWindows *********/ static void doCreateWindows( ) { int window_windowX = 0; int window_windowY = 0; int window_windowW = 80; int window_windowH = 9; /* Create the main window */ initscr(); noecho(); window_window = newwin(window_windowH, window_windowW, window_windowY, window_windowX) ; box (window_window,'|','-') ; } /******** doMapWindows ***********/ static void doMapWindows( ) { refresh (); wrefresh(window_window); } /********************** reading menu items *****************************/ static void read_menu_items ( ) { menu_def[1]="hello 1" ; menu_def[2]="hello 2" ; menu_def[3]="hello 3" ; menu_def[4]="hello 4" ; menu_def[5]="hello 5" ; menu_def[6]="hello 6" ; menu_def[7]="hello 7" ; } /********************** display menu items *****************************/ static void display_menu_items( ) { mvwaddstr(window_window,1,1,menu_def[1]); mvwaddstr(window_window,1,15,menu_def[2]); mvwaddstr(window_window,1,30,menu_def[3]); mvwaddstr(window_window,1,45,menu_def[4]); mvwaddstr(window_window,1,60,menu_def[5]); mvwaddstr(window_window,3,1,menu_def[6]); mvwaddstr(window_window,3,15,menu_def[7]); wrefresh (window_window); } typedef unsigned char uc; /****************** doHandleEvents ***********************/ static void doHandleEvents( ) { # define CURSOR_UP 1 int input_character; wstandout (window_window); mvwaddstr(window_window,1,45,menu_def[1]); wstandend (window_window); /* gag */ crmode(); input_character= wgetch(window_window); printf ("\n\n\n\n\n Input character was: %d \n",input_character); input_character= wgetch(window_window); printf ("\n second Input character was: %d \n",input_character); input_character= wgetch(window_window); printf ("\n third Input character was: %d \n",input_character); /* switch (input_character) { case CURSOR_UP: { }; break; default: { }; break; } */ } /***************** doShutdown ***************************/ static void end_of_program () { printf ("\n\n\n give any key to stop "); wgetch(window_window); endwin(); exit(1); }