1.\" $NetBSD: menu_driver.3,v 1.8 2003/04/16 13:35:10 wiz 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.In menu.h 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. 48It takes the commands passed 49by c parameter and performs the requested action on the menu given. 50The following commands may be given to the menu driver: 51.Pp 52.Bl -tag -width REQ_CLEAR_PATTERN -compact 53.It Command 54Action 55.It REQ_LEFT_ITEM 56Sets the new current item to be the item to the left of the current 57item. 58.It REQ_RIGHT_ITEM 59Sets the new current item to be the item to the rights of the current 60item. 61.It REQ_UP_ITEM 62Sets the new current item to be the item above the current item. 63.It REQ_DOWN_ITEM 64Sets the new current item to be the item below the current item. 65.It REQ_SCR_ULINE 66Scroll the menu one line towards the bottom of the menu window. 67The new current item becomes the item immediately above the current item. 68.It REQ_SCR_DLINE 69Scroll the menu one line towards the top of the menu window. 70The new current item becomes the item immediately below the current item. 71.It REQ_SCR_DPAGE 72Scroll the menu one page towards the bottom of the menu window. 73.It REQ_SCR_UPAGE 74Scroll the menu one page towards the top of the menu window. 75.It REQ_FIRST_ITEM 76Set the current item to be the first item in the menu. 77.It REQ_LAST_ITEM 78Set the current item to be the last item in the menu. 79.It REQ_NEXT_ITEM 80Set the new current item to be the next item in the item array after 81the current item. 82.It REQ_PREV_ITEM 83Set the new current item to be the item before the current item in the 84items array. 85.It REQ_TOGGLE_ITEM 86If the item is selectable then toggle the item's value. 87.It REQ_CLEAR_PATTERN 88Clear all the characters currently in the menu's pattern buffer. 89.It REQ_BACK_PATTERN 90Remove the last character from the pattern buffer. 91.It REQ_NEXT_MATCH 92Attempt to find the next item that matches the pattern buffer. 93.It REQ_PREV_MATCH 94Attempt to find the previous item that matches the pattern buffer. 95.El 96If 97.Fn menu_driver 98is passed a command that is greater than MAX_COMMAND then the command 99passed is assumed to be a user defined command and 100.Fn menu_driver 101returns E_UNKNOWN_COMMAND. 102Otherwise if the command is a printable 103character then the character represented by the command is placed at 104the end of the pattern buffer and an attempt is made to match the 105pattern buffer against the items in the menu. 106.Sh RETURN VALUES 107The functions return one of the following error values: 108.Pp 109.Bl -tag -width E_UNKNOWN_COMMAND -compact 110.It Er E_OK 111The function was successful. 112.It Er E_SYSTEM_ERROR 113There was a system error during the call. 114.It Er E_BAD_ARGUMENT 115One or more of the arguments passed to the function was incorrect. 116.It Er E_NOT_POSTED 117The menu is not posted. 118.It Er E_UNKNOWN_COMMAND 119The menu driver does not recognize the request passed to it. 120.It Er E_NO_MATCH 121The character search failed to find a match. 122.It Er E_NOT_CONNECTED 123The item is not connected to a menu. 124.It Er E_REQUEST_DENIED 125The menu driver could not process the request. 126.El 127.Sh SEE ALSO 128.Xr curses 3 , 129.Xr menus 3 130.Sh NOTES 131The header 132.Pa \*[Lt]menu.h\*[Gt] 133automatically includes both 134.Pa \*[Lt]curses.h\*[Gt] 135and 136.Pa \*[Lt]eti.h\*[Gt] . 137