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