blob: 1fe5001fec056e8cb6a362fb2fb0caf53283f868 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002.\" Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303.\" *
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.\"
Steve Kondikae271bc2015-11-15 02:50:53 +010029.\" $Id: menu_driver.3x,v 1.20 2010/12/04 18:38:55 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053030.TH menu_driver 3X ""
Steve Kondikae271bc2015-11-15 02:50:53 +010031.de bP
32.IP \(bu 4
33..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053034.SH NAME
Steve Kondikae271bc2015-11-15 02:50:53 +010035\fBmenu_driver\fR \- command-processing loop of the menu system
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053036.SH SYNOPSIS
37\fB#include <menu.h>\fR
38.br
39int menu_driver(MENU *menu, int c);
40.br
41.SH DESCRIPTION
42Once a menu has been posted (displayed), you should funnel input events to it
43through \fBmenu_driver\fR. This routine has three major input cases:
Steve Kondikae271bc2015-11-15 02:50:53 +010044.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053045The input is a form navigation request.
46Navigation request codes are constants defined in \fB<form.h>\fP,
47which are distinct from the key- and character codes returned by \fBwgetch\fP.
Steve Kondikae271bc2015-11-15 02:50:53 +010048.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049The input is a printable character.
50Printable characters (which must be positive, less than 256) are
51checked according to the program's locale settings.
Steve Kondikae271bc2015-11-15 02:50:53 +010052.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053053The input is the KEY_MOUSE special key associated with an mouse event.
54.PP
55The menu driver requests are as follows:
56.TP 5
57REQ_LEFT_ITEM
58Move left to an item.
59.TP 5
60REQ_RIGHT_ITEM
61Move right to an item.
62.TP 5
63REQ_UP_ITEM
64Move up to an item.
65.TP 5
66REQ_DOWN_ITEM
67Move down to an item.
68.TP 5
69REQ_SCR_ULINE
70Scroll up a line.
71.TP 5
72REQ_SCR_DLINE
73Scroll down a line.
74.TP 5
75REQ_SCR_DPAGE
76Scroll down a page.
77.TP 5
78REQ_SCR_UPAGE
79Scroll up a page.
80.TP 5
81REQ_FIRST_ITEM
82Move to the first item.
83.TP 5
84REQ_LAST_ITEM
85Move to the last item.
86.TP 5
87REQ_NEXT_ITEM
88Move to the next item.
89.TP 5
90REQ_PREV_ITEM
91Move to the previous item.
92.TP 5
93REQ_TOGGLE_ITEM
94Select/deselect an item.
95.TP 5
96REQ_CLEAR_PATTERN
97Clear the menu pattern buffer.
98.TP 5
99REQ_BACK_PATTERN
100Delete the previous character from the pattern buffer.
101.TP 5
102REQ_NEXT_MATCH
103Move to the next item matching the pattern match.
104.TP 5
105REQ_PREV_MATCH
106Move to the previous item matching the pattern match.
107.PP
108If the second argument is a printable character, the code appends
109it to the pattern buffer and attempts to move to the next item matching
110the new pattern. If there is no such match, \fBmenu_driver\fR returns
111\fBE_NO_MATCH\fR and deletes the appended character from the buffer.
112.PP
113If the second argument is one of the above pre-defined requests, the
114corresponding action is performed.
115.SS MOUSE HANDLING
116.PP
117If the second argument is the KEY_MOUSE special key, the associated
118mouse event is translated into one of the above pre-defined requests.
Steve Kondikae271bc2015-11-15 02:50:53 +0100119Currently only clicks in the user window (e.g., inside the menu display
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530120area or the decoration window) are handled.
121.PP
122If you click above the display region of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100123.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124a REQ_SCR_ULINE is generated for a single click,
Steve Kondikae271bc2015-11-15 02:50:53 +0100125.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530126a REQ_SCR_UPAGE is generated for a double-click and
Steve Kondikae271bc2015-11-15 02:50:53 +0100127.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530128a REQ_FIRST_ITEM is generated for a triple-click.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530129.PP
130If you click below the display region of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100131.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530132a REQ_SCR_DLINE is generated for a single click,
Steve Kondikae271bc2015-11-15 02:50:53 +0100133.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530134a REQ_SCR_DPAGE is generated for a double-click and
Steve Kondikae271bc2015-11-15 02:50:53 +0100135.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530136a REQ_LAST_ITEM is generated for a triple-click.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137.PP
138If you click at an item inside the display area of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100139.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530140the menu cursor is positioned to that item.
Steve Kondikae271bc2015-11-15 02:50:53 +0100141.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530142If you double-click an item a REQ_TOGGLE_ITEM
143is generated and \fBE_UNKNOWN_COMMAND\fR is returned.
144This return value makes sense,
145because a double click usually means that an item-specific action should
146be returned.
147It is exactly the purpose of this return value to signal that an
148application specific command should be executed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100149.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530150If a translation
151into a request was done, \fBmenu_driver\fR returns the result of this request.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530152.PP
153If you clicked outside the user window or the mouse event could not be translated
154into a menu request an \fBE_REQUEST_DENIED\fR is returned.
155.SS APPLICATION-DEFINED COMMANDS
156.PP
157If the second argument is neither printable nor one of the above
158pre-defined menu requests or KEY_MOUSE, the drive assumes it is an application-specific
159command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
160should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
161pre-defined requests.
162.SH RETURN VALUE
163\fBmenu_driver\fR return one of the following error codes:
164.TP 5
165.B E_OK
166The routine succeeded.
167.TP 5
168.B E_SYSTEM_ERROR
169System error occurred (see \fBerrno\fR).
170.TP 5
171.B E_BAD_ARGUMENT
172Routine detected an incorrect or out-of-range argument.
173.TP 5
174.B E_BAD_STATE
175Routine was called from an initialization or termination function.
176.TP 5
177.B E_NOT_POSTED
178The menu has not been posted.
179.TP 5
180.B E_UNKNOWN_COMMAND
181The menu driver code saw an unknown request code.
182.TP 5
183.B E_NO_MATCH
184Character failed to match.
185.TP 5
186.B E_REQUEST_DENIED
187The menu driver could not process the request.
188.SH SEE ALSO
189\fBcurses\fR(3X),
190\fBmenu\fR(3X),
Steve Kondikae271bc2015-11-15 02:50:53 +0100191\fBgetch\fR(3X).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530192.SH NOTES
193The header file \fB<menu.h>\fR automatically includes the header files
194\fB<curses.h>\fR.
195.SH PORTABILITY
196These routines emulate the System V menu library. They were not supported on
197Version 7 or BSD versions. The support for mouse events is ncurses specific.
198.SH AUTHORS
199Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
200S. Raymond.