1menu_driver(3X)                                                menu_driver(3X)
2
3
4

NAME

6       menu_driver - command-processing loop of the menu system
7

SYNOPSIS

9       #include <menu.h>
10       int menu_driver(MENU *menu, int c);
11

DESCRIPTION

13       Once a menu has been posted (displayed), you should funnel input events
14       to it through menu_driver.  This routine has three major input cases:
15
16       -  The input is a form navigation request.   Navigation  request  codes
17          are  constants defined in <form.h>, which are distinct from the key-
18          and character codes returned by wgetch.
19
20       -  The input is a printable  character.   Printable  characters  (which
21          must  be  positive, less than 256) are checked according to the pro‐
22          gram's locale settings.
23
24       -  The input is the KEY_MOUSE special  key  associated  with  an  mouse
25          event.
26
27       The menu driver requests are as follows:
28
29       REQ_LEFT_ITEM
30            Move left to an item.
31
32       REQ_RIGHT_ITEM
33            Move right to an item.
34
35       REQ_UP_ITEM
36            Move up to an item.
37
38       REQ_DOWN_ITEM
39            Move down to an item.
40
41       REQ_SCR_ULINE
42            Scroll up a line.
43
44       REQ_SCR_DLINE
45            Scroll down a line.
46
47       REQ_SCR_DPAGE
48            Scroll down a page.
49
50       REQ_SCR_UPAGE
51            Scroll up a page.
52
53       REQ_FIRST_ITEM
54            Move to the first item.
55
56       REQ_LAST_ITEM
57            Move to the last item.
58
59       REQ_NEXT_ITEM
60            Move to the next item.
61
62       REQ_PREV_ITEM
63            Move to the previous item.
64
65       REQ_TOGGLE_ITEM
66            Select/deselect an item.
67
68       REQ_CLEAR_PATTERN
69            Clear the menu pattern buffer.
70
71       REQ_BACK_PATTERN
72            Delete the previous character from the pattern buffer.
73
74       REQ_NEXT_MATCH
75            Move to the next item matching the pattern match.
76
77       REQ_PREV_MATCH
78            Move to the previous item matching the pattern match.
79
80       If the second argument is a printable character, the code appends it to
81       the pattern buffer and attempts to move to the next item  matching  the
82       new pattern.  If there is no such match, menu_driver returns E_NO_MATCH
83       and deletes the appended character from the buffer.
84
85       If the second argument is one of the above  pre-defined  requests,  the
86       corresponding action is performed.
87
88   MOUSE HANDLING
89       If  the  second  argument  is the KEY_MOUSE special key, the associated
90       mouse event is translated into one of the above  pre-defined  requests.
91       Currently only clicks in the user window (e.g., inside the menu display
92       area or the decoration window) are handled.
93
94       If you click above the display region of the menu:
95
96              a REQ_SCR_ULINE is generated for a single click,
97
98              a REQ_SCR_UPAGE is generated for a double-click and
99
100              a REQ_FIRST_ITEM is generated for a triple-click.
101
102       If you click below the display region of the menu:
103
104              a REQ_SCR_DLINE is generated for a single click,
105
106              a REQ_SCR_DPAGE is generated for a double-click and
107
108              a REQ_LAST_ITEM is generated for a triple-click.
109
110       If you click at an item inside the display area of the menu:
111
112              -  the menu cursor is positioned to that item.
113
114              -  If you double-click an item a  REQ_TOGGLE_ITEM  is  generated
115                 and  E_UNKNOWN_COMMAND  is returned.  This return value makes
116                 sense, because a double click usually means that an item-spe‐
117                 cific  action  should be returned.  It is exactly the purpose
118                 of this return value to signal that an  application  specific
119                 command should be executed.
120
121              -  If a translation into a request was done, menu_driver returns
122                 the result of this request.
123
124       If you clicked outside the user window or the mouse event could not  be
125       translated into a menu request an E_REQUEST_DENIED is returned.
126
127   APPLICATION-DEFINED COMMANDS
128       If  the  second argument is neither printable nor one of the above pre-
129       defined menu requests or KEY_MOUSE, the drive assumes it is an applica‐
130       tion-specific  command  and  returns  E_UNKNOWN_COMMAND.   Application-
131       defined commands should be defined relative to MAX_COMMAND, the maximum
132       value of these pre-defined requests.
133

RETURN VALUE

135       menu_driver return one of the following error codes:
136
137       E_OK The routine succeeded.
138
139       E_SYSTEM_ERROR
140            System error occurred (see errno).
141
142       E_BAD_ARGUMENT
143            Routine detected an incorrect or out-of-range argument.
144
145       E_BAD_STATE
146            Routine was called from an initialization or termination function.
147
148       E_NOT_POSTED
149            The menu has not been posted.
150
151       E_UNKNOWN_COMMAND
152            The menu driver code saw an unknown request code.
153
154       E_NO_MATCH
155            Character failed to match.
156
157       E_REQUEST_DENIED
158            The menu driver could not process the request.
159

SEE ALSO

161       curses(3X), menu(3X), wgetch(3X).
162

NOTES

164       The  header  file  <menu.h>  automatically  includes  the  header files
165       <curses.h>.
166

PORTABILITY

168       These routines emulate the System V menu library.  They were  not  sup‐
169       ported  on  Version  7 or BSD versions. The support for mouse events is
170       ncurses specific.
171

AUTHORS

173       Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
174       Raymond.
175
176
177
178                                                               menu_driver(3X)
Impressum