blob: 6a117283705f138a3a95bbdf81ffaf47a82ce101 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2010,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: menu_driver.3x,v 1.47 2024/03/16 15:35:01 tom Exp $
31.TH menu_driver 3X 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
Steve Kondikae271bc2015-11-15 02:50:53 +010032.de bP
micky3879b9f5e72025-07-08 18:04:53 -040033.ie n .IP \(bu 4
34.el .IP \(bu 2
Steve Kondikae271bc2015-11-15 02:50:53 +010035..
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053036.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040037\fBmenu_driver\fP \-
38command-processing loop of the menu system
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053039.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040040.nf
41\fB#include <menu.h>
42.PP
43\fBint menu_driver(MENU *\fImenu\fP, int \fIc\fP);
44.fi
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053045.SH DESCRIPTION
46Once a menu has been posted (displayed), you should funnel input events to it
micky3879b9f5e72025-07-08 18:04:53 -040047through \fBmenu_driver\fP. This routine has three major input cases:
Steve Kondikae271bc2015-11-15 02:50:53 +010048.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049The input is a form navigation request.
50Navigation request codes are constants defined in \fB<form.h>\fP,
micky3879b9f5e72025-07-08 18:04:53 -040051which are distinct from the key- and character codes
52returned by \fBwgetch\fP(3X).
Steve Kondikae271bc2015-11-15 02:50:53 +010053.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053054The input is a printable character.
55Printable characters (which must be positive, less than 256) are
56checked according to the program's locale settings.
Steve Kondikae271bc2015-11-15 02:50:53 +010057.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053058The input is the KEY_MOUSE special key associated with an mouse event.
59.PP
60The menu driver requests are as follows:
61.TP 5
62REQ_LEFT_ITEM
63Move left to an item.
64.TP 5
65REQ_RIGHT_ITEM
66Move right to an item.
67.TP 5
68REQ_UP_ITEM
69Move up to an item.
70.TP 5
71REQ_DOWN_ITEM
72Move down to an item.
73.TP 5
74REQ_SCR_ULINE
75Scroll up a line.
76.TP 5
77REQ_SCR_DLINE
78Scroll down a line.
79.TP 5
80REQ_SCR_DPAGE
81Scroll down a page.
82.TP 5
83REQ_SCR_UPAGE
84Scroll up a page.
85.TP 5
86REQ_FIRST_ITEM
87Move to the first item.
88.TP 5
89REQ_LAST_ITEM
90Move to the last item.
91.TP 5
92REQ_NEXT_ITEM
93Move to the next item.
94.TP 5
95REQ_PREV_ITEM
96Move to the previous item.
97.TP 5
98REQ_TOGGLE_ITEM
99Select/deselect an item.
100.TP 5
101REQ_CLEAR_PATTERN
102Clear the menu pattern buffer.
103.TP 5
104REQ_BACK_PATTERN
105Delete the previous character from the pattern buffer.
106.TP 5
107REQ_NEXT_MATCH
108Move to the next item matching the pattern match.
109.TP 5
110REQ_PREV_MATCH
111Move to the previous item matching the pattern match.
112.PP
113If the second argument is a printable character, the code appends
114it to the pattern buffer and attempts to move to the next item matching
micky3879b9f5e72025-07-08 18:04:53 -0400115the new pattern.
116If there is no such match, \fBmenu_driver\fP returns
117\fBE_NO_MATCH\fP and deletes the appended character from the buffer.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530118.PP
119If the second argument is one of the above pre-defined requests, the
120corresponding action is performed.
micky3879b9f5e72025-07-08 18:04:53 -0400121.SS "Mouse Handling"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530122If the second argument is the KEY_MOUSE special key, the associated
123mouse event is translated into one of the above pre-defined requests.
Steve Kondikae271bc2015-11-15 02:50:53 +0100124Currently only clicks in the user window (e.g., inside the menu display
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530125area or the decoration window) are handled.
126.PP
127If you click above the display region of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100128.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530129a REQ_SCR_ULINE is generated for a single click,
Steve Kondikae271bc2015-11-15 02:50:53 +0100130.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131a REQ_SCR_UPAGE is generated for a double-click and
Steve Kondikae271bc2015-11-15 02:50:53 +0100132.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530133a REQ_FIRST_ITEM is generated for a triple-click.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530134.PP
135If you click below the display region of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100136.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530137a REQ_SCR_DLINE is generated for a single click,
Steve Kondikae271bc2015-11-15 02:50:53 +0100138.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530139a REQ_SCR_DPAGE is generated for a double-click and
Steve Kondikae271bc2015-11-15 02:50:53 +0100140.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530141a REQ_LAST_ITEM is generated for a triple-click.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530142.PP
143If you click at an item inside the display area of the menu:
Steve Kondikae271bc2015-11-15 02:50:53 +0100144.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530145the menu cursor is positioned to that item.
Steve Kondikae271bc2015-11-15 02:50:53 +0100146.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530147If you double-click an item a REQ_TOGGLE_ITEM
micky3879b9f5e72025-07-08 18:04:53 -0400148is generated and \fBE_UNKNOWN_COMMAND\fP is returned.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530149This return value makes sense,
150because a double click usually means that an item-specific action should
151be returned.
152It is exactly the purpose of this return value to signal that an
153application specific command should be executed.
Steve Kondikae271bc2015-11-15 02:50:53 +0100154.bP
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530155If a translation
micky3879b9f5e72025-07-08 18:04:53 -0400156into a request was done, \fBmenu_driver\fP returns the result of this request.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530157.PP
micky3879b9f5e72025-07-08 18:04:53 -0400158If you clicked outside the user window
159or the mouse event could not be translated
160into a menu request an \fBE_REQUEST_DENIED\fP is returned.
161.SS "Application-defined Commands"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530162If the second argument is neither printable nor one of the above
micky3879b9f5e72025-07-08 18:04:53 -0400163pre-defined menu requests or KEY_MOUSE,
164the drive assumes it is an application-specific
165command and returns \fBE_UNKNOWN_COMMAND\fP. Application-defined commands
166should be defined relative to \fBMAX_COMMAND\fP, the maximum value of these
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530167pre-defined requests.
168.SH RETURN VALUE
micky3879b9f5e72025-07-08 18:04:53 -0400169\fBmenu_driver\fP return one of the following error codes:
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530170.TP 5
171.B E_OK
172The routine succeeded.
173.TP 5
174.B E_SYSTEM_ERROR
micky3879b9f5e72025-07-08 18:04:53 -0400175System error occurred (see \fBerrno\fP(3)).
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530176.TP 5
177.B E_BAD_ARGUMENT
178Routine detected an incorrect or out-of-range argument.
179.TP 5
180.B E_BAD_STATE
181Routine was called from an initialization or termination function.
182.TP 5
183.B E_NOT_POSTED
184The menu has not been posted.
185.TP 5
186.B E_UNKNOWN_COMMAND
187The menu driver code saw an unknown request code.
188.TP 5
189.B E_NO_MATCH
190Character failed to match.
191.TP 5
192.B E_REQUEST_DENIED
193The menu driver could not process the request.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530194.SH PORTABILITY
micky3879b9f5e72025-07-08 18:04:53 -0400195These routines emulate the System V menu library.
196They were not supported on
197Version 7 or BSD versions.
198The support for mouse events is \fI\%ncurses\fP specific.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530199.SH AUTHORS
micky3879b9f5e72025-07-08 18:04:53 -0400200Juergen Pfeifer.
201Manual 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)