]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/menu_driver.3x
ncurses 6.1 - patch 20190803
[ncurses.git] / man / menu_driver.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2018,2019 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: menu_driver.3x,v 1.25 2019/01/20 20:32:23 tom Exp $
30 .TH menu_driver 3X ""
31 .de bP
32 .ie n  .IP \(bu 4
33 .el    .IP \(bu 2
34 ..
35 .SH NAME
36 \fBmenu_driver\fR \- command-processing loop of the menu system
37 .SH SYNOPSIS
38 \fB#include <menu.h>\fR
39 .br
40 int menu_driver(MENU *menu, int c);
41 .br
42 .SH DESCRIPTION
43 Once a menu has been posted (displayed), you should funnel input events to it
44 through \fBmenu_driver\fR.  This routine has three major input cases:
45 .bP
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).
50 .bP
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.
54 .bP
55 The input is the KEY_MOUSE special key associated with an mouse event.
56 .PP
57 The menu driver requests are as follows:
58 .TP 5
59 REQ_LEFT_ITEM
60 Move left to an item.
61 .TP 5
62 REQ_RIGHT_ITEM
63 Move right to an item.
64 .TP 5
65 REQ_UP_ITEM
66 Move up to an item.
67 .TP 5
68 REQ_DOWN_ITEM
69 Move down to an item.
70 .TP 5
71 REQ_SCR_ULINE
72 Scroll up a line.
73 .TP 5
74 REQ_SCR_DLINE
75 Scroll down a line.
76 .TP 5
77 REQ_SCR_DPAGE
78 Scroll down a page.
79 .TP 5
80 REQ_SCR_UPAGE
81 Scroll up a page.
82 .TP 5
83 REQ_FIRST_ITEM
84 Move to the first item.
85 .TP 5
86 REQ_LAST_ITEM
87 Move to the last item.
88 .TP 5
89 REQ_NEXT_ITEM
90 Move to the next item.
91 .TP 5
92 REQ_PREV_ITEM
93 Move to the previous item.
94 .TP 5
95 REQ_TOGGLE_ITEM
96 Select/deselect an item.
97 .TP 5
98 REQ_CLEAR_PATTERN
99 Clear the menu pattern buffer.
100 .TP 5
101 REQ_BACK_PATTERN
102 Delete the previous character from the pattern buffer.
103 .TP 5
104 REQ_NEXT_MATCH
105 Move to the next item matching the pattern match.
106 .TP 5
107 REQ_PREV_MATCH
108 Move to the previous item matching the pattern match.
109 .PP
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
112 the new pattern.
113 If there is no such match, \fBmenu_driver\fR returns
114 \fBE_NO_MATCH\fR and deletes the appended character from the buffer.
115 .PP
116 If the second argument is one of the above pre-defined requests, the
117 corresponding action is performed.
118 .SS MOUSE HANDLING
119 .PP
120 If the second argument is the KEY_MOUSE special key, the associated
121 mouse event is translated into one of the above pre-defined requests.
122 Currently only clicks in the user window (e.g., inside the menu display
123 area or the decoration window) are handled.
124 .PP
125 If you click above the display region of the menu:
126 .bP
127 a REQ_SCR_ULINE is generated for a single click,
128 .bP
129 a REQ_SCR_UPAGE is generated for a double-click and
130 .bP
131 a REQ_FIRST_ITEM is generated for a triple-click.
132 .PP
133 If you click below the display region of the menu:
134 .bP
135 a REQ_SCR_DLINE is generated for a single click,
136 .bP
137 a REQ_SCR_DPAGE is generated for a double-click and
138 .bP
139 a REQ_LAST_ITEM is generated for a triple-click.
140 .PP
141 If you click at an item inside the display area of the menu:
142 .bP
143 the menu cursor is positioned to that item.
144 .bP
145 If you double-click an item a REQ_TOGGLE_ITEM
146 is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
147 This return value makes sense,
148 because a double click usually means that an item-specific action should
149 be returned.
150 It is exactly the purpose of this return value to signal that an
151 application specific command should be executed.
152 .bP
153 If a translation
154 into a request was done, \fBmenu_driver\fR returns the result of this request.
155 .PP
156 If you clicked outside the user window
157 or the mouse event could not be translated
158 into a menu request an \fBE_REQUEST_DENIED\fR is returned.
159 .SS APPLICATION-DEFINED COMMANDS
160 .PP
161 If the second argument is neither printable nor one of the above
162 pre-defined menu requests or KEY_MOUSE,
163 the drive assumes it is an application-specific
164 command and returns \fBE_UNKNOWN_COMMAND\fR.  Application-defined commands
165 should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
166 pre-defined requests.
167 .SH RETURN VALUE
168 \fBmenu_driver\fR return one of the following error codes:
169 .TP 5
170 .B E_OK
171 The routine succeeded.
172 .TP 5
173 .B E_SYSTEM_ERROR
174 System error occurred (see \fBerrno\fR(3)).
175 .TP 5
176 .B E_BAD_ARGUMENT
177 Routine detected an incorrect or out-of-range argument.
178 .TP 5
179 .B E_BAD_STATE
180 Routine was called from an initialization or termination function.
181 .TP 5
182 .B E_NOT_POSTED
183 The menu has not been posted.
184 .TP 5
185 .B E_UNKNOWN_COMMAND
186 The menu driver code saw an unknown request code.
187 .TP 5
188 .B E_NO_MATCH
189 Character failed to match.
190 .TP 5
191 .B E_REQUEST_DENIED
192 The menu driver could not process the request.
193 .SH SEE ALSO
194 \fBcurses\fR(3X),
195 \fBmenu\fR(3X),
196 \fBgetch\fR(3X).
197 .SH NOTES
198 The header file \fB<menu.h>\fR automatically includes the header files
199 \fB<curses.h>\fR.
200 .SH PORTABILITY
201 These routines emulate the System V menu library.
202 They were not supported on
203 Version 7 or BSD versions.
204 The support for mouse events is ncurses specific.
205 .SH AUTHORS
206 Juergen Pfeifer.
207 Manual pages and adaptation for new curses by Eric S. Raymond.