xref: /illumos-gate/usr/src/lib/libeti/menu/inc/private.h (revision 1da57d551424de5a9d469760be7c4b4d4f10a755)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright (c) 1997, by Sun Mircrosystems, Inc.
28  * All rights reserved.
29  */
30 
31 #ifndef _MENU_PRIVATE_H
32 #define	_MENU_PRIVATE_H
33 
34 #include <menu.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* Menu macros to access menu structure */
41 
42 #define	Height(m)	(m)->height
43 #define	Width(m)	(m)->width
44 #define	Rows(m)		(m)->rows
45 #define	Cols(m)		(m)->cols
46 #define	FRows(m)	(m)->frows
47 #define	FCols(m)	(m)->fcols
48 #define	MaxName(m)	(m)->namelen
49 #define	MaxDesc(m)	(m)->desclen
50 #define	Marklen(m)	(m)->marklen
51 #define	Itemlen(m)	(m)->itemlen
52 #define	Pattern(m)	(m)->pattern
53 #define	Pindex(m)	(m)->pindex
54 #define	IthPattern(m, i)	(m)->pattern[i]
55 #define	Win(m)		(m)->win
56 #define	Sub(m)		(m)->sub
57 #define	UserWin(m)	(m)->userwin
58 #define	UserSub(m)	(m)->usersub
59 #define	UW(m)		(UserWin(m) ? UserWin(m) : stdscr)
60 #define	US(m)		(UserSub(m) ? UserSub(m) : UW(m))
61 #define	Items(m)	(m)->items
62 #define	IthItem(m, i)	(m)->items[i]
63 #define	Nitems(m)	(m)->nitems
64 #define	Current(m)	(m)->curitem
65 #define	Top(m)		(m)->toprow
66 #define	Pad(m)		(m)->pad
67 #define	Fore(m)		(m)->fore
68 #define	Back(m)		(m)->back
69 #define	Grey(m)		(m)->grey
70 #define	InvalidAttr(a)	(((a) & (chtype) A_ATTRIBUTES) != (a))
71 #define	Mhelp(m)	(m)->help
72 #define	Muserptr(m)	(m)->userptr
73 #define	Mopt(m)		(m)->opt
74 #define	Mark(m)		(m)->mark
75 #define	Mstatus(m)	(m)->status
76 #define	Posted(m)	(Mstatus(m) & _POSTED)
77 #define	Indriver(m)	(Mstatus(m) & _IN_DRIVER)
78 #define	LinkNeeded(m)	(Mstatus(m) & _LINK_NEEDED)
79 #define	SetPost(m)	(Mstatus(m) |= _POSTED)
80 #define	SetDriver(m)	(Mstatus(m) |= _IN_DRIVER)
81 #define	SetLink(m)	(Mstatus(m) |= _LINK_NEEDED)
82 #define	ResetPost(m)	(Mstatus(m) &= ~_POSTED)
83 #define	ResetDriver(m)	(Mstatus(m) &= ~_IN_DRIVER)
84 #define	ResetLink(m)	(Mstatus(m) &= ~_LINK_NEEDED)
85 #define	SMinit(m)	(m)->menuinit
86 #define	SMterm(m)	(m)->menuterm
87 #define	SIinit(m)	(m)->iteminit
88 #define	SIterm(m)	(m)->itemterm
89 #define	Minit(m)	if (m->menuinit) { \
90 			    SetDriver(m); \
91 			    (m)->menuinit(m); \
92 			    ResetDriver(m); \
93 			}
94 #define	Mterm(m)	if (m->menuterm) { \
95 			    SetDriver(m); \
96 			    (m)->menuterm(m); \
97 			    ResetDriver(m); \
98 			}
99 #define	Iinit(m)	if (m->iteminit) { \
100 			    SetDriver(m); \
101 			    (m)->iteminit(m); \
102 			    ResetDriver(m); \
103 			}
104 #define	Iterm(m)	if (m->itemterm) { \
105 			    SetDriver(m); \
106 			    (m)->itemterm(m); \
107 			    ResetDriver(m); \
108 			}
109 
110 /* Define access to Mopt */
111 
112 #define	OneValue(m)	(Mopt(m) & O_ONEVALUE)
113 #define	ShowDesc(m)	(Mopt(m) & O_SHOWDESC)
114 #define	RowMajor(m)	(Mopt(m) & O_ROWMAJOR)
115 #define	IgnoreCase(m)	(Mopt(m) & O_IGNORECASE)
116 #define	ShowMatch(m)	(Mopt(m) & O_SHOWMATCH)
117 #define	Cyclic(m)	(!(Mopt(m) & O_NONCYCLIC))
118 
119 /* Item macros to access item structure */
120 
121 #define	Name(i)		(i)->name.str
122 #define	NameLen(i)	(i)->name.length
123 #define	Description(i)	(i)->description.str
124 #define	DescriptionLen(i)	(i)->description.length
125 #define	Index(i)	(i)->index
126 #define	Y(i)		(i)->y
127 #define	X(i)		(i)->x
128 #define	Imenu(i)	(i)->imenu
129 #define	Value(i)	(i)->value
130 #define	Ihelp(i)	(i)->help
131 #define	Iuserptr(i)	(i)->userptr
132 #define	Iopt(i)		(i)->opt
133 #define	Istatus(i)	(i)->status
134 #define	Up(i)		(i)->up
135 #define	Down(i)		(i)->down
136 #define	Left(i)		(i)->left
137 #define	Right(i)	(i)->right
138 #define	Selectable(i)	(Iopt(i) & O_SELECTABLE)
139 
140 /* Default menu macros */
141 
142 #define	Dfl_Menu	(&_Default_Menu)
143 #define	Dfl_Item	(&_Default_Item)
144 
145 #define	max(a, b)	((a) > (b)) ? (a) : (b)
146 #define	min(a, b)	((a) < (b)) ? (a) : (b)
147 
148 extern MENU		_Default_Menu;
149 extern ITEM		_Default_Item;
150 
151 extern void		_affect_change(MENU *, int, ITEM *);
152 extern void		_chk_current(MENU *, int *, ITEM *);
153 extern void		_chk_top(MENU *, int *, ITEM *);
154 extern void		_disconnect(MENU *);
155 extern void		_draw(MENU *);
156 extern void		_link_items(MENU *);
157 extern void		_move_post_item(MENU *, ITEM *);
158 extern void		_movecurrent(MENU *, ITEM *);
159 extern void		_position_cursor(MENU *);
160 extern void		_scale(MENU *);
161 extern void		_show(MENU *);
162 extern int		_match(MENU *, char, ITEM **);
163 extern int		_connect(MENU *, ITEM **);
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif	/* _MENU_PRIVATE_H */
170