Debian Codegraph @

upstream/debian-unstable/man3/driver.3menu

raw
1 .\"***************************************************************************
2 .\" Copyright 2018-2024,2025 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.51 2025/10/04 20:59:08 tom Exp $
31 .TH driver 3MENU 2025-10-04 "ncurses 6.6" "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 menu navigation request.
50 Navigation request codes are constants defined in
51 .IR menu.h ","
52 which are distinct from the key- and character codes
53 returned by \fBwgetch\fP(3NCURSES).
54 .bP
55 The input is a printable character.
56 Printable characters (which must be positive, less than 256) are
57 checked according to the program's locale settings.
58 .bP
59 The input is the KEY_MOUSE special key associated with an mouse event.
60 .PP
61 The menu driver requests are as follows:
62 .TP 5
63 REQ_LEFT_ITEM
64 Move left to an item.
65 .TP 5
66 REQ_RIGHT_ITEM
67 Move right to an item.
68 .TP 5
69 REQ_UP_ITEM
70 Move up to an item.
71 .TP 5
72 REQ_DOWN_ITEM
73 Move down to an item.
74 .TP 5
75 REQ_SCR_ULINE
76 Scroll up a line.
77 .TP 5
78 REQ_SCR_DLINE
79 Scroll down a line.
80 .TP 5
81 REQ_SCR_DPAGE
82 Scroll down a page.
83 .TP 5
84 REQ_SCR_UPAGE
85 Scroll up a page.
86 .TP 5
87 REQ_FIRST_ITEM
88 Move to the first item.
89 .TP 5
90 REQ_LAST_ITEM
91 Move to the last item.
92 .TP 5
93 REQ_NEXT_ITEM
94 Move to the next item.
95 .TP 5
96 REQ_PREV_ITEM
97 Move to the previous item.
98 .TP 5
99 REQ_TOGGLE_ITEM
100 Select/deselect an item.
101 .TP 5
102 REQ_CLEAR_PATTERN
103 Clear the menu pattern buffer.
104 .TP 5
105 REQ_BACK_PATTERN
106 Delete the previous character from the pattern buffer.
107 .TP 5
108 REQ_NEXT_MATCH
109 Move to the next item matching the pattern match.
110 .TP 5
111 REQ_PREV_MATCH
112 Move to the previous item matching the pattern match.
113 .PP
114 If the second argument is a printable character, the code appends
115 it to the pattern buffer and attempts to move to the next item matching
116 the new pattern.
117 If there is no such match, \fBmenu_driver\fP returns
118 \fBE_NO_MATCH\fP and deletes the appended character from the buffer.
119 .PP
120 If the second argument is one of the above pre-defined requests, the
121 corresponding action is performed.
122 .SS "Mouse Handling"
123 If the second argument is the KEY_MOUSE special key, the associated
124 mouse event is translated into one of the above pre-defined requests.
125 Currently only clicks in the user window (e.g., inside the menu display
126 area or the decoration window) are handled.
127 .PP
128 If you click above the display region of the menu:
129 .bP
130 a REQ_SCR_ULINE is generated for a single click,
131 .bP
132 a REQ_SCR_UPAGE is generated for a double-click and
133 .bP
134 a REQ_FIRST_ITEM is generated for a triple-click.
135 .PP
136 If you click below the display region of the menu:
137 .bP
138 a REQ_SCR_DLINE is generated for a single click,
139 .bP
140 a REQ_SCR_DPAGE is generated for a double-click and
141 .bP
142 a REQ_LAST_ITEM is generated for a triple-click.
143 .PP
144 If you click at an item inside the display area of the menu:
145 .bP
146 the menu cursor is positioned to that item.
147 .bP
148 If you double-click an item a REQ_TOGGLE_ITEM
149 is generated and \fBE_UNKNOWN_COMMAND\fP is returned.
150 This return value makes sense,
151 because a double click usually means that an item-specific action should
152 be returned.
153 It is exactly the purpose of this return value to signal that an
154 application specific command should be executed.
155 .bP
156 If a translation
157 into a request was done, \fBmenu_driver\fP returns the result of this request.
158 .PP
159 If you clicked outside the user window
160 or the mouse event could not be translated
161 into a menu request an \fBE_REQUEST_DENIED\fP is returned.
162 .SS "Application-defined Commands"
163 If the second argument is neither printable nor one of the above
164 pre-defined menu requests or KEY_MOUSE,
165 the drive assumes it is an application-specific
166 command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands
167 should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
168 pre-defined requests.
169 .SH RETURN VALUE
170 \fBmenu_driver\fP return one of the following error codes:
171 .TP 5
172 .B E_OK
173 The routine succeeded.
174 .TP 5
175 .B E_SYSTEM_ERROR
176 System error occurred (see \fBerrno\fP(3)).
177 .TP 5
178 .B E_BAD_ARGUMENT
179 Routine detected an incorrect or out-of-range argument.
180 .TP 5
181 .B E_BAD_STATE
182 Routine was called from an initialization or termination function.
183 .TP 5
184 .B E_NOT_POSTED
185 The menu has not been posted.
186 .TP 5
187 .B E_UNKNOWN_COMMAND
188 The menu driver code saw an unknown request code.
189 .TP 5
190 .B E_NO_MATCH
191 Character failed to match.
192 .TP 5
193 .B E_REQUEST_DENIED
194 The menu driver could not process the request.
195 .SH PORTABILITY
196 These routines emulate the System V menu library.
197 They were not supported on
198 Version 7 or BSD versions.
199 The support for mouse events is \fI\%ncurses\fP specific.
200 .SH AUTHORS
201 Juergen Pfeifer.
202 Manual pages and adaptation for new curses by Eric S. Raymond.
203 .SH SEE ALSO
204 \fB\%ncurses\fP(3NCURSES),
205 \fB\%getch\fP(3NCURSES),
206 \fB\%menu\fP(3MENU)