xref: /netbsd/lib/libmenu/menus.3 (revision bf9ec67e)
1.\"	$NetBSD: menus.3,v 1.8 2002/02/20 17:49:14 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 MENUS 3
34.Os
35.Sh NAME
36.Nm menus
37.Nd menu library
38.Sh LIBRARY
39.Lb libmenu
40.Sh SYNOPSIS
41.Fd #include \*[Lt]menu.h\*[Gt]
42.Sh DESCRIPTION
43The
44.Nm
45library provides a terminal independent menu system using the
46.Xr curses 3
47library.  Before using the
48.Nm
49functions the terminal must be set up by
50.Xr curses 3
51using the
52.Fn initscr
53function or similar.  Programs using
54.Nm
55functions must be linked with the
56.Xr curses 3
57library.
58.Pp
59The
60.Nm
61library provides facilities for defining menu items, placing a menu on the
62terminal screen, assign pre- and post-change operations and setting the
63attributes of both the menu and its items.
64.Ss Defining default attributes for menus and items
65The
66.Nm
67library allows any settable attribute or option of both the menu and item
68objects to be defined such that any new menu or item automatically inherits
69the value as default.  Setting the default value will not affect any item or
70menu that has already been created but will be applied to subsequent objects.
71To set the default attribute or option the set routine is passed a NULL
72pointer in the item or menu parameter when calling the set routine.  The
73current default value can be retrieved by calling the get routine with a
74NULL pointer for the item or menu parameter.
75.Pp
76.Bl -tag -width item_description -compact
77.It function name
78manual page name
79.It current_item
80.Xr menu_item_current 3
81.It free_item
82.Xr menu_item_new 3
83.It free_menu
84.Xr menu_new 3
85.It item_count
86.Xr menu_items 3
87.It item_description
88.Xr menu_item_name 3
89.It item_index
90.Xr menu_item_current 3
91.It item_init
92.Xr menu_hook 3
93.It item_name
94.Xr menu_item_name 3
95.It item_opts
96.Xr menu_item_opts 3
97.It item_opts_off
98.Xr menu_item_opts 3
99.It item_opts_on
100.Xr menu_item_opts 3
101.It item_term
102.Xr menu_hook 3
103.It item_userptr
104.Xr menu_item_userptr 3
105.It item_value
106.Xr menu_item_value 3
107.It item_visible
108.Xr menu_item_visible 3
109.It menu_back
110.Xr menu_attributes 3
111.It menu_driver
112.Xr menu_driver 3
113.It menu_fore
114.Xr menu_attributes 3
115.It menu_format
116.Xr menu_format 3
117.It menu_grey
118.Xr menu_attributes 3
119.It menu_init
120.Xr menu_hook 3
121.It menu_items
122.Xr menu_items 3
123.It menu_mark
124.Xr menu_mark 3
125.It menu_opts
126.Xr menu_opts 3
127.It menu_opts_off
128.Xr menu_opts 3
129.It menu_opts_on
130.Xr menu_opts 3
131.It menu_pad
132.Xr menu_attributes 3
133.It menu_pattern
134.Xr menu_pattern 3
135.It menu_sub
136.Xr menu_win 3
137.It menu_term
138.Xr menu_hook 3
139.It menu_unmark
140.Xr menu_mark 3
141.It menu_userptr
142.Xr menu_userptr 3
143.It men_win
144.Xr menu_win 3
145.It new_item
146.Xr menu_item_new 3
147.It new_menu
148.Xr menu_new 3
149.It pos_menu_cursor
150.Xr menu_cursor 3
151.It post_menu
152.Xr menu_post 3
153.It scale_window
154.Xr menu_win 3
155.It set_current_item
156.Xr menu_item_current 3
157.It set_item_init
158.Xr menu_hook 3
159.It set_item_opts
160.Xr menu_item_opts 3
161.It set_item_term
162.Xr menu_hook 3
163.It set_item_userptr
164.Xr menu_item_userptr 3
165.It set_item_value
166.Xr menu_item_value 3
167.It set_menu_back
168.Xr menu_attributes 3
169.It set_menu_fore
170.Xr menu_attributes 3
171.It set_menu_format
172.Xr menu_format 3
173.It set_menu_grey
174.Xr menu_attributes 3
175.It set_menu_init
176.Xr menu_hook 3
177.It set_menu_items
178.Xr menu_items 3
179.It set_menu_mark
180.Xr menu_mark 3
181.It set_menu_opts
182.Xr menu_opts 3
183.It set_menu_pad
184.Xr menu_attributes 3
185.It set_menu_pattern
186.Xr menu_pattern 3
187.It set_menu_sub
188.Xr menu_win 3
189.It set_menu_term
190.Xr menu_hook 3
191.It set_menu_unmark
192.Xr menu_mark 3
193.It set_menu_userptr
194.Xr menu_userptr 3
195.It set_menu_win
196.Xr menu_win 3
197.It set_top_row
198.Xr menu_item_current 3
199.It top_row
200.Xr menu_item_current 3
201.It unpost_menu
202.Xr menu_post 3
203.El
204.Sh RETURN VALUES
205Any function returning a string pointer will return NULL if an error
206occurs.  Functions returning an integer will return one of the
207following:
208.Pp
209.Bl -tag -width E_UNKNOWN_COMMAND -compact
210.It Er E_OK
211The function was successful.
212.It Er E_SYSTEM_ERROR
213There was a system error during the call.
214.It Er E_BAD_ARGUMENT
215One or more of the arguments passed to the function was incorrect.
216.It Er E_POSTED
217The menu is already posted.
218.It Er E_CONNECTED
219An item was already connected to a menu.
220.It Er E_BAD_STATE
221The function was called from within an initialisation or termination
222routine.
223.It Er E_NO_ROOM
224The menu does not fit within the subwindow.
225.It Er E_NOT_POSTED
226The menu is not posted.
227.It Er E_UNKNOWN_COMMAND
228The menu driver does not recognise the request passed to it.
229.It Er E_NO_MATCH
230The character search failed to find a match.
231.It Er E_NOT_SELECTABLE
232The item could not be selected.
233.It Er E_NOT_CONNECTED
234The item is not connected to a menu.
235.It Er E_REQUEST_DENIED
236The menu driver could not process the request.
237.El
238.Sh SEE ALSO
239.Xr curses 3 ,
240.Xr menu_attributes 3 ,
241.Xr menu_cursor 3 ,
242.Xr menu_driver 3 ,
243.Xr menu_format 3 ,
244.Xr menu_hook 3 ,
245.Xr menu_item_current 3 ,
246.Xr menu_item_name 3 ,
247.Xr menu_item_new 3 ,
248.Xr menu_item_opts 3 ,
249.Xr menu_item_userptr 3 ,
250.Xr menu_item_value 3 ,
251.Xr menu_item_visible 3 ,
252.Xr menu_items 3 ,
253.Xr menu_mark 3 ,
254.Xr menu_new 3 ,
255.Xr menu_opts 3 ,
256.Xr menu_pattern 3 ,
257.Xr menu_post 3 ,
258.Xr menu_userptr 3 ,
259.Xr menu_win 3
260