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