]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/menu_driver.3x
ncurses 6.2 - patch 20210710
[ncurses.git] / man / menu_driver.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2019,2020 Thomas E. Dickey                                *
3 .\" Copyright 1998-2010,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
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.                               *
23 .\"                                                                          *
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       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: menu_driver.3x,v 1.28 2020/12/19 21:33:37 tom Exp $
31 .TH menu_driver 3X ""
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fBmenu_driver\fR \- command-processing loop of the menu system
38 .SH SYNOPSIS
39 \fB#include <menu.h>\fR
40 .sp
41 \fBint menu_driver(MENU *\fP\fImenu\fP\fB, int \fP\fIc\fP\fB);\fP
42 .br
43 .SH DESCRIPTION
44 Once a menu has been posted (displayed), you should funnel input events to it
45 through \fBmenu_driver\fR.  This routine has three major input cases:
46 .bP
47 The input is a form navigation request.
48 Navigation request codes are constants defined in \fB<form.h>\fP,
49 which are distinct from the key- and character codes
50 returned by \fBwgetch\fP(3X).
51 .bP
52 The input is a printable character.
53 Printable characters (which must be positive, less than 256) are
54 checked according to the program's locale settings.
55 .bP
56 The input is the KEY_MOUSE special key associated with an mouse event.
57 .PP
58 The menu driver requests are as follows:
59 .TP 5
60 REQ_LEFT_ITEM
61 Move left to an item.
62 .TP 5
63 REQ_RIGHT_ITEM
64 Move right to an item.
65 .TP 5
66 REQ_UP_ITEM
67 Move up to an item.
68 .TP 5
69 REQ_DOWN_ITEM
70 Move down to an item.
71 .TP 5
72 REQ_SCR_ULINE
73 Scroll up a line.
74 .TP 5
75 REQ_SCR_DLINE
76 Scroll down a line.
77 .TP 5
78 REQ_SCR_DPAGE
79 Scroll down a page.
80 .TP 5
81 REQ_SCR_UPAGE
82 Scroll up a page.
83 .TP 5
84 REQ_FIRST_ITEM
85 Move to the first item.
86 .TP 5
87 REQ_LAST_ITEM
88 Move to the last item.
89 .TP 5
90 REQ_NEXT_ITEM
91 Move to the next item.
92 .TP 5
93 REQ_PREV_ITEM
94 Move to the previous item.
95 .TP 5
96 REQ_TOGGLE_ITEM
97 Select/deselect an item.
98 .TP 5
99 REQ_CLEAR_PATTERN
100 Clear the menu pattern buffer.
101 .TP 5
102 REQ_BACK_PATTERN
103 Delete the previous character from the pattern buffer.
104 .TP 5
105 REQ_NEXT_MATCH
106 Move to the next item matching the pattern match.
107 .TP 5
108 REQ_PREV_MATCH
109 Move to the previous item matching the pattern match.
110 .PP
111 If the second argument is a printable character, the code appends
112 it to the pattern buffer and attempts to move to the next item matching
113 the new pattern.
114 If there is no such match, \fBmenu_driver\fR returns
115 \fBE_NO_MATCH\fR and deletes the appended character from the buffer.
116 .PP
117 If the second argument is one of the above pre-defined requests, the
118 corresponding action is performed.
119 .SS MOUSE HANDLING
120 .PP
121 If the second argument is the KEY_MOUSE special key, the associated
122 mouse event is translated into one of the above pre-defined requests.
123 Currently only clicks in the user window (e.g., inside the menu display
124 area or the decoration window) are handled.
125 .PP
126 If you click above the display region of the menu:
127 .bP
128 a REQ_SCR_ULINE is generated for a single click,
129 .bP
130 a REQ_SCR_UPAGE is generated for a double-click and
131 .bP
132 a REQ_FIRST_ITEM is generated for a triple-click.
133 .PP
134 If you click below the display region of the menu:
135 .bP
136 a REQ_SCR_DLINE is generated for a single click,
137 .bP
138 a REQ_SCR_DPAGE is generated for a double-click and
139 .bP
140 a REQ_LAST_ITEM is generated for a triple-click.
141 .PP
142 If you click at an item inside the display area of the menu:
143 .bP
144 the menu cursor is positioned to that item.
145 .bP
146 If you double-click an item a REQ_TOGGLE_ITEM
147 is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
148 This return value makes sense,
149 because a double click usually means that an item-specific action should
150 be returned.
151 It is exactly the purpose of this return value to signal that an
152 application specific command should be executed.
153 .bP
154 If a translation
155 into a request was done, \fBmenu_driver\fR returns the result of this request.
156 .PP
157 If you clicked outside the user window
158 or the mouse event could not be translated
159 into a menu request an \fBE_REQUEST_DENIED\fR is returned.
160 .SS APPLICATION-DEFINED COMMANDS
161 .PP
162 If the second argument is neither printable nor one of the above
163 pre-defined menu requests or KEY_MOUSE,
164 the drive assumes it is an application-specific
165 command and returns \fBE_UNKNOWN_COMMAND\fR.  Application-defined commands
166 should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
167 pre-defined requests.
168 .SH RETURN VALUE
169 \fBmenu_driver\fR return one of the following error codes:
170 .TP 5
171 .B E_OK
172 The routine succeeded.
173 .TP 5
174 .B E_SYSTEM_ERROR
175 System error occurred (see \fBerrno\fR(3)).
176 .TP 5
177 .B E_BAD_ARGUMENT
178 Routine detected an incorrect or out-of-range argument.
179 .TP 5
180 .B E_BAD_STATE
181 Routine was called from an initialization or termination function.
182 .TP 5
183 .B E_NOT_POSTED
184 The menu has not been posted.
185 .TP 5
186 .B E_UNKNOWN_COMMAND
187 The menu driver code saw an unknown request code.
188 .TP 5
189 .B E_NO_MATCH
190 Character failed to match.
191 .TP 5
192 .B E_REQUEST_DENIED
193 The menu driver could not process the request.
194 .SH SEE ALSO
195 \fBcurses\fR(3X),
196 \fBgetch\fR(3X),
197 \fBmenu\fR(3X).
198 .SH NOTES
199 The header file \fB<menu.h>\fR automatically includes the header files
200 \fB<curses.h>\fR.
201 .SH PORTABILITY
202 These routines emulate the System V menu library.
203 They were not supported on
204 Version 7 or BSD versions.
205 The support for mouse events is ncurses specific.
206 .SH AUTHORS
207 Juergen Pfeifer.
208 Manual pages and adaptation for new curses by Eric S. Raymond.