1*b618a1eeSThomas Cort.\" $NetBSD: menu_driver.3,v 1.8 2003/04/16 13:35:10 wiz Exp $ 2*b618a1eeSThomas Cort.\" 3*b618a1eeSThomas Cort.\" Copyright (c) 1999 4*b618a1eeSThomas Cort.\" Brett Lymn - blymn@baea.com.au, brett_lymn@yahoo.com.au 5*b618a1eeSThomas Cort.\" 6*b618a1eeSThomas Cort.\" This code is donated to The NetBSD Foundation by the author. 7*b618a1eeSThomas Cort.\" 8*b618a1eeSThomas Cort.\" Redistribution and use in source and binary forms, with or without 9*b618a1eeSThomas Cort.\" modification, are permitted provided that the following conditions 10*b618a1eeSThomas Cort.\" are met: 11*b618a1eeSThomas Cort.\" 1. Redistributions of source code must retain the above copyright 12*b618a1eeSThomas Cort.\" notice, this list of conditions and the following disclaimer. 13*b618a1eeSThomas Cort.\" 2. Redistributions in binary form must reproduce the above copyright 14*b618a1eeSThomas Cort.\" notice, this list of conditions and the following disclaimer in the 15*b618a1eeSThomas Cort.\" documentation and/or other materials provided with the distribution. 16*b618a1eeSThomas Cort.\" 3. The name of the Author may not be used to endorse or promote 17*b618a1eeSThomas Cort.\" products derived from this software without specific prior written 18*b618a1eeSThomas Cort.\" permission. 19*b618a1eeSThomas Cort.\" 20*b618a1eeSThomas Cort.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 21*b618a1eeSThomas Cort.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22*b618a1eeSThomas Cort.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23*b618a1eeSThomas Cort.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 24*b618a1eeSThomas Cort.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25*b618a1eeSThomas Cort.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26*b618a1eeSThomas Cort.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27*b618a1eeSThomas Cort.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28*b618a1eeSThomas Cort.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29*b618a1eeSThomas Cort.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30*b618a1eeSThomas Cort.\" SUCH DAMAGE. 31*b618a1eeSThomas Cort.\" 32*b618a1eeSThomas Cort.Dd September 10, 1999 33*b618a1eeSThomas Cort.Dt MENU_DRIVER 3 34*b618a1eeSThomas Cort.Os 35*b618a1eeSThomas Cort.Sh NAME 36*b618a1eeSThomas Cort.Nm menu_driver 37*b618a1eeSThomas Cort.Nd main menu handling function 38*b618a1eeSThomas Cort.Sh LIBRARY 39*b618a1eeSThomas Cort.Lb libmenu 40*b618a1eeSThomas Cort.Sh SYNOPSIS 41*b618a1eeSThomas Cort.In menu.h 42*b618a1eeSThomas Cort.Ft int 43*b618a1eeSThomas Cort.Fn menu_driver "MENU *menu" "int c" 44*b618a1eeSThomas Cort.Sh DESCRIPTION 45*b618a1eeSThomas CortThe 46*b618a1eeSThomas Cort.Fn menu_driver 47*b618a1eeSThomas Cortfunction is the guts of the menu system. 48*b618a1eeSThomas CortIt takes the commands passed 49*b618a1eeSThomas Cortby c parameter and performs the requested action on the menu given. 50*b618a1eeSThomas CortThe following commands may be given to the menu driver: 51*b618a1eeSThomas Cort.Pp 52*b618a1eeSThomas Cort.Bl -tag -width REQ_CLEAR_PATTERN -compact 53*b618a1eeSThomas Cort.It Command 54*b618a1eeSThomas CortAction 55*b618a1eeSThomas Cort.It REQ_LEFT_ITEM 56*b618a1eeSThomas CortSets the new current item to be the item to the left of the current 57*b618a1eeSThomas Cortitem. 58*b618a1eeSThomas Cort.It REQ_RIGHT_ITEM 59*b618a1eeSThomas CortSets the new current item to be the item to the rights of the current 60*b618a1eeSThomas Cortitem. 61*b618a1eeSThomas Cort.It REQ_UP_ITEM 62*b618a1eeSThomas CortSets the new current item to be the item above the current item. 63*b618a1eeSThomas Cort.It REQ_DOWN_ITEM 64*b618a1eeSThomas CortSets the new current item to be the item below the current item. 65*b618a1eeSThomas Cort.It REQ_SCR_ULINE 66*b618a1eeSThomas CortScroll the menu one line towards the bottom of the menu window. 67*b618a1eeSThomas CortThe new current item becomes the item immediately above the current item. 68*b618a1eeSThomas Cort.It REQ_SCR_DLINE 69*b618a1eeSThomas CortScroll the menu one line towards the top of the menu window. 70*b618a1eeSThomas CortThe new current item becomes the item immediately below the current item. 71*b618a1eeSThomas Cort.It REQ_SCR_DPAGE 72*b618a1eeSThomas CortScroll the menu one page towards the bottom of the menu window. 73*b618a1eeSThomas Cort.It REQ_SCR_UPAGE 74*b618a1eeSThomas CortScroll the menu one page towards the top of the menu window. 75*b618a1eeSThomas Cort.It REQ_FIRST_ITEM 76*b618a1eeSThomas CortSet the current item to be the first item in the menu. 77*b618a1eeSThomas Cort.It REQ_LAST_ITEM 78*b618a1eeSThomas CortSet the current item to be the last item in the menu. 79*b618a1eeSThomas Cort.It REQ_NEXT_ITEM 80*b618a1eeSThomas CortSet the new current item to be the next item in the item array after 81*b618a1eeSThomas Cortthe current item. 82*b618a1eeSThomas Cort.It REQ_PREV_ITEM 83*b618a1eeSThomas CortSet the new current item to be the item before the current item in the 84*b618a1eeSThomas Cortitems array. 85*b618a1eeSThomas Cort.It REQ_TOGGLE_ITEM 86*b618a1eeSThomas CortIf the item is selectable then toggle the item's value. 87*b618a1eeSThomas Cort.It REQ_CLEAR_PATTERN 88*b618a1eeSThomas CortClear all the characters currently in the menu's pattern buffer. 89*b618a1eeSThomas Cort.It REQ_BACK_PATTERN 90*b618a1eeSThomas CortRemove the last character from the pattern buffer. 91*b618a1eeSThomas Cort.It REQ_NEXT_MATCH 92*b618a1eeSThomas CortAttempt to find the next item that matches the pattern buffer. 93*b618a1eeSThomas Cort.It REQ_PREV_MATCH 94*b618a1eeSThomas CortAttempt to find the previous item that matches the pattern buffer. 95*b618a1eeSThomas Cort.El 96*b618a1eeSThomas CortIf 97*b618a1eeSThomas Cort.Fn menu_driver 98*b618a1eeSThomas Cortis passed a command that is greater than MAX_COMMAND then the command 99*b618a1eeSThomas Cortpassed is assumed to be a user defined command and 100*b618a1eeSThomas Cort.Fn menu_driver 101*b618a1eeSThomas Cortreturns E_UNKNOWN_COMMAND. 102*b618a1eeSThomas CortOtherwise if the command is a printable 103*b618a1eeSThomas Cortcharacter then the character represented by the command is placed at 104*b618a1eeSThomas Cortthe end of the pattern buffer and an attempt is made to match the 105*b618a1eeSThomas Cortpattern buffer against the items in the menu. 106*b618a1eeSThomas Cort.Sh RETURN VALUES 107*b618a1eeSThomas CortThe functions return one of the following error values: 108*b618a1eeSThomas Cort.Pp 109*b618a1eeSThomas Cort.Bl -tag -width E_UNKNOWN_COMMAND -compact 110*b618a1eeSThomas Cort.It Er E_OK 111*b618a1eeSThomas CortThe function was successful. 112*b618a1eeSThomas Cort.It Er E_SYSTEM_ERROR 113*b618a1eeSThomas CortThere was a system error during the call. 114*b618a1eeSThomas Cort.It Er E_BAD_ARGUMENT 115*b618a1eeSThomas CortOne or more of the arguments passed to the function was incorrect. 116*b618a1eeSThomas Cort.It Er E_NOT_POSTED 117*b618a1eeSThomas CortThe menu is not posted. 118*b618a1eeSThomas Cort.It Er E_UNKNOWN_COMMAND 119*b618a1eeSThomas CortThe menu driver does not recognize the request passed to it. 120*b618a1eeSThomas Cort.It Er E_NO_MATCH 121*b618a1eeSThomas CortThe character search failed to find a match. 122*b618a1eeSThomas Cort.It Er E_NOT_CONNECTED 123*b618a1eeSThomas CortThe item is not connected to a menu. 124*b618a1eeSThomas Cort.It Er E_REQUEST_DENIED 125*b618a1eeSThomas CortThe menu driver could not process the request. 126*b618a1eeSThomas Cort.El 127*b618a1eeSThomas Cort.Sh SEE ALSO 128*b618a1eeSThomas Cort.Xr curses 3 , 129*b618a1eeSThomas Cort.Xr menus 3 130*b618a1eeSThomas Cort.Sh NOTES 131*b618a1eeSThomas CortThe header 132*b618a1eeSThomas Cort.Pa \*[Lt]menu.h\*[Gt] 133*b618a1eeSThomas Cortautomatically includes both 134*b618a1eeSThomas Cort.Pa \*[Lt]curses.h\*[Gt] 135*b618a1eeSThomas Cortand 136*b618a1eeSThomas Cort.Pa \*[Lt]eti.h\*[Gt] . 137