man(1) Manual page archive


     MENUHIT(9.3)                                         MENUHIT(9.3)

     NAME
          menuhit - present user with menu and get selection

     SYNOPSIS
          #include <jerq.h>

          int menuhit(m, n)
          Menu *m; int n;

     DESCRIPTION
          Menuhit presents the user with a menu specified by the Menu
          pointer m and returns an integer indicating the selection
          made, or -1 for no selection.  The integer n specifies which
          button to use for the interaction: 1, 2 or 3.  Menuhit
          assumes that the button is already depressed when it is
          called.  The user makes a selection by lifting the button
          when the cursor points at the desired selection; lifting the
          button outside the menu indicates no selection.

          Menus can be built in two ways, either as an array of
          strings or with a generator function:

               char *menutext[]={"Item 0", "Item 1", "Item 2", 0};
               Menu stringsmenu={ menutext };

          or

               char *menugen();
               Menu genmenu={ (char **)0, menugen };

          The generator function is passed an integer parameter n, and
          must return the string for the n'th menu entry, or 0 if n is
          beyond the number of entries in the menu.

          Regardless of the method of generation, characters with the
          0200 bit set are regarded as fill characters.  For example,
          the string "\240X" will appear in the menu as a right-
          justified X.  Menu strings without fill characters are drawn
          centered in the menu.

          Here is an example, using the list-of-strings menu defined
          above:

               switch(menuhit(&stringsmenu, 3)){  /* Use right button */
                    case 0:
                         item_0();
                         break;
                    case 1:
                         item_1();
                         break;

     MENUHIT(9.3)                                         MENUHIT(9.3)

                    case 2:
                         item_2();
                         break;
                    case -1:
                         noselection();
                         break;
               }