]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/menu_driver.3x
ncurses 6.4 - patch 20231223
[ncurses.git] / man / menu_driver.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.45 2023/12/23 16:08:25 tom Exp $
31 .TH menu_driver 3X 2023-12-23 "ncurses 6.4" "Library calls"
32 .de bP
33 .ie n  .IP \(bu 4
34 .el    .IP \(bu 2
35 ..
36 .SH NAME
37 \fBmenu_driver\fP \-
38 command-processing loop of the menu system
39 .SH SYNOPSIS
40 .nf
41 \fB#include <menu.h>
42 .PP
43 \fBint menu_driver(MENU *\fImenu\fP, int \fIc\fP);
44 .fi
45 .SH DESCRIPTION
46 Once a menu has been posted (displayed), you should funnel input events to it
47 through \fBmenu_driver\fP.  This routine has three major input cases:
48 .bP
49 The input is a form navigation request.
50 Navigation request codes are constants defined in \fB<form.h>\fP,
51 which are distinct from the key- and character codes
52 returned by \fBwgetch\fP(3X).
53 .bP
54 The input is a printable character.
55 Printable characters (which must be positive, less than 256) are
56 checked according to the program's locale settings.
57 .bP
58 The input is the KEY_MOUSE special key associated with an mouse event.
59 .PP
60 The menu driver requests are as follows:
61 .TP 5
62 REQ_LEFT_ITEM
63 Move left to an item.
64 .TP 5
65 REQ_RIGHT_ITEM
66 Move right to an item.
67 .TP 5
68 REQ_UP_ITEM
69 Move up to an item.
70 .TP 5
71 REQ_DOWN_ITEM
72 Move down to an item.
73 .TP 5
74 REQ_SCR_ULINE
75 Scroll up a line.
76 .TP 5
77 REQ_SCR_DLINE
78 Scroll down a line.
79 .TP 5
80 REQ_SCR_DPAGE
81 Scroll down a page.
82 .TP 5
83 REQ_SCR_UPAGE
84 Scroll up a page.
85 .TP 5
86 REQ_FIRST_ITEM
87 Move to the first item.
88 .TP 5
89 REQ_LAST_ITEM
90 Move to the last item.
91 .TP 5
92 REQ_NEXT_ITEM
93 Move to the next item.
94 .TP 5
95 REQ_PREV_ITEM
96 Move to the previous item.
97 .TP 5
98 REQ_TOGGLE_ITEM
99 Select/deselect an item.
100 .TP 5
101 REQ_CLEAR_PATTERN
102 Clear the menu pattern buffer.
103 .TP 5
104 REQ_BACK_PATTERN
105 Delete the previous character from the pattern buffer.
106 .TP 5
107 REQ_NEXT_MATCH
108 Move to the next item matching the pattern match.
109 .TP 5
110 REQ_PREV_MATCH
111 Move to the previous item matching the pattern match.
112 .PP
113 If the second argument is a printable character, the code appends
114 it to the pattern buffer and attempts to move to the next item matching
115 the new pattern.
116 If there is no such match, \fBmenu_driver\fP returns
117 \fBE_NO_MATCH\fP and deletes the appended character from the buffer.
118 .PP
119 If the second argument is one of the above pre-defined requests, the
120 corresponding action is performed.
121 .SS "Mouse Handling"
122 If the second argument is the KEY_MOUSE special key, the associated
123 mouse event is translated into one of the above pre-defined requests.
124 Currently only clicks in the user window (e.g., inside the menu display
125 area or the decoration window) are handled.
126 .PP
127 If you click above the display region of the menu:
128 .bP
129 a REQ_SCR_ULINE is generated for a single click,
130 .bP
131 a REQ_SCR_UPAGE is generated for a double-click and
132 .bP
133 a REQ_FIRST_ITEM is generated for a triple-click.
134 .PP
135 If you click below the display region of the menu:
136 .bP
137 a REQ_SCR_DLINE is generated for a single click,
138 .bP
139 a REQ_SCR_DPAGE is generated for a double-click and
140 .bP
141 a REQ_LAST_ITEM is generated for a triple-click.
142 .PP
143 If you click at an item inside the display area of the menu:
144 .bP
145 the menu cursor is positioned to that item.
146 .bP
147 If you double-click an item a REQ_TOGGLE_ITEM
148 is generated and \fBE_UNKNOWN_COMMAND\fP is returned.
149 This return value makes sense,
150 because a double click usually means that an item-specific action should
151 be returned.
152 It is exactly the purpose of this return value to signal that an
153 application specific command should be executed.
154 .bP
155 If a translation
156 into a request was done, \fBmenu_driver\fP returns the result of this request.
157 .PP
158 If you clicked outside the user window
159 or the mouse event could not be translated
160 into a menu request an \fBE_REQUEST_DENIED\fP is returned.
161 .SS "Application-defined Commands"
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\fP.  Application-defined commands
166 should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
167 pre-defined requests.
168 .SH RETURN VALUE
169 \fBmenu_driver\fP 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\fP(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 PORTABILITY
195 These routines emulate the System V menu library.
196 They were not supported on
197 Version 7 or BSD versions.
198 The support for mouse events is \fI\%ncurses\fP specific.
199 .SH AUTHORS
200 Juergen Pfeifer.
201 Manual pages and adaptation for new curses by Eric S. Raymond.
202 .SH SEE ALSO
203 \fB\%curses\fP(3X),
204 \fB\%getch\fP(3X),
205 \fB\%menu\fP(3X)