1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey *
3 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc. *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
28 .\"***************************************************************************
30 .\" $Id: menu_driver.3x,v 1.35 2023/07/01 15:46:10 tom Exp $
31 .TH menu_driver 3X 2023-07-01 "ncurses 6.4" "Library calls"
37 \fBmenu_driver\fP \- command-processing loop of the menu system
39 \fB#include <menu.h>\fP
41 \fBint menu_driver(MENU *\fImenu\fB, int \fIc\fB);\fR
43 Once a menu has been posted (displayed), you should funnel input events to it
44 through \fBmenu_driver\fP. This routine has three major input cases:
46 The input is a form navigation request.
47 Navigation request codes are constants defined in \fB<form.h>\fP,
48 which are distinct from the key- and character codes
49 returned by \fBwgetch\fP(3X).
51 The input is a printable character.
52 Printable characters (which must be positive, less than 256) are
53 checked according to the program's locale settings.
55 The input is the KEY_MOUSE special key associated with an mouse event.
57 The menu driver requests are as follows:
63 Move right to an item.
84 Move to the first item.
87 Move to the last item.
90 Move to the next item.
93 Move to the previous item.
96 Select/deselect an item.
99 Clear the menu pattern buffer.
102 Delete the previous character from the pattern buffer.
105 Move to the next item matching the pattern match.
108 Move to the previous item matching the pattern match.
110 If the second argument is a printable character, the code appends
111 it to the pattern buffer and attempts to move to the next item matching
113 If there is no such match, \fBmenu_driver\fP returns
114 \fBE_NO_MATCH\fP and deletes the appended character from the buffer.
116 If the second argument is one of the above pre-defined requests, the
117 corresponding action is performed.
119 If the second argument is the KEY_MOUSE special key, the associated
120 mouse event is translated into one of the above pre-defined requests.
121 Currently only clicks in the user window (e.g., inside the menu display
122 area or the decoration window) are handled.
124 If you click above the display region of the menu:
126 a REQ_SCR_ULINE is generated for a single click,
128 a REQ_SCR_UPAGE is generated for a double-click and
130 a REQ_FIRST_ITEM is generated for a triple-click.
132 If you click below the display region of the menu:
134 a REQ_SCR_DLINE is generated for a single click,
136 a REQ_SCR_DPAGE is generated for a double-click and
138 a REQ_LAST_ITEM is generated for a triple-click.
140 If you click at an item inside the display area of the menu:
142 the menu cursor is positioned to that item.
144 If you double-click an item a REQ_TOGGLE_ITEM
145 is generated and \fBE_UNKNOWN_COMMAND\fP is returned.
146 This return value makes sense,
147 because a double click usually means that an item-specific action should
149 It is exactly the purpose of this return value to signal that an
150 application specific command should be executed.
153 into a request was done, \fBmenu_driver\fP returns the result of this request.
155 If you clicked outside the user window
156 or the mouse event could not be translated
157 into a menu request an \fBE_REQUEST_DENIED\fP is returned.
158 .SS APPLICATION-DEFINED COMMANDS
159 If the second argument is neither printable nor one of the above
160 pre-defined menu requests or KEY_MOUSE,
161 the drive assumes it is an application-specific
162 command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands
163 should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
164 pre-defined requests.
166 \fBmenu_driver\fP return one of the following error codes:
169 The routine succeeded.
172 System error occurred (see \fBerrno\fP(3)).
175 Routine detected an incorrect or out-of-range argument.
178 Routine was called from an initialization or termination function.
181 The menu has not been posted.
184 The menu driver code saw an unknown request code.
187 Character failed to match.
190 The menu driver could not process the request.
196 The header file \fB<menu.h>\fP automatically includes the header files
199 These routines emulate the System V menu library.
200 They were not supported on
201 Version 7 or BSD versions.
202 The support for mouse events is ncurses specific.
205 Manual pages and adaptation for new curses by Eric S. Raymond.