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