menu.priv.h revision 1.5
1/*	$OpenBSD: menu.priv.h,v 1.5 1999/01/22 03:45:06 millert Exp $	*/
2
3/****************************************************************************
4 * Copyright (c) 1998 Free Software Foundation, Inc.                        *
5 *                                                                          *
6 * Permission is hereby granted, free of charge, to any person obtaining a  *
7 * copy of this software and associated documentation files (the            *
8 * "Software"), to deal in the Software without restriction, including      *
9 * without limitation the rights to use, copy, modify, merge, publish,      *
10 * distribute, distribute with modifications, sublicense, and/or sell       *
11 * copies of the Software, and to permit persons to whom the Software is    *
12 * furnished to do so, subject to the following conditions:                 *
13 *                                                                          *
14 * The above copyright notice and this permission notice shall be included  *
15 * in all copies or substantial portions of the Software.                   *
16 *                                                                          *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24 *                                                                          *
25 * Except as contained in this notice, the name(s) of the above copyright   *
26 * holders shall not be used in advertising or otherwise to promote the     *
27 * sale, use or other dealings in this Software without prior written       *
28 * authorization.                                                           *
29 ****************************************************************************/
30
31/****************************************************************************
32 *   Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997        *
33 ****************************************************************************/
34
35/***************************************************************************
36* Module menu.priv.h                                                       *
37* Top level private header file for all libnmenu modules                   *
38***************************************************************************/
39
40#include "mf_common.h"
41#include "menu.h"
42
43/* Backspace code */
44#define BS (8)
45
46extern ITEM _nc_Default_Item;
47extern MENU _nc_Default_Menu;
48
49/* Normalize item to default if none was given */
50#define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
51
52/* Normalize menu to default if none was given */
53#define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
54
55/* Get the user defined (framing) window of the menu */
56#define Get_Menu_UserWin(menu) ((menu)->userwin ? (menu)->userwin : stdscr)
57
58/* Normalize menu window */
59#define Get_Menu_Window(  menu ) \
60   ((menu)->usersub  ? (menu)->usersub  : Get_Menu_UserWin(menu))
61
62/* menu specific status flags */
63#define _LINK_NEEDED    (0x04)
64#define _MARK_ALLOCATED (0x08)
65
66#define ALL_MENU_OPTS (                 \
67		       O_ONEVALUE     | \
68		       O_SHOWDESC     | \
69		       O_ROWMAJOR     | \
70		       O_IGNORECASE   | \
71		       O_SHOWMATCH    | \
72		       O_NONCYCLIC    )
73
74#define ALL_ITEM_OPTS (O_SELECTABLE)
75
76/* Move to the window position of an item and draw it */
77#define Move_And_Post_Item(menu,item) \
78  {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
79   _nc_Post_Item((menu),(item));}
80
81#define Move_To_Current_Item(menu,item) \
82  if ( (item) != (menu)->curitem)\
83    {\
84      Move_And_Post_Item(menu,item);\
85      Move_And_Post_Item(menu,(menu)->curitem);\
86    }
87
88/* This macro ensures, that the item becomes visible, if possible with the
89   specified row as the top row of the window. If this is not possible,
90   the top row will be adjusted and the value is stored in the row argument.
91*/
92#define Adjust_Current_Item(menu,row,item) \
93  { if ((item)->y < row) \
94      row = (item)->y;\
95    if ( (item)->y >= (row + (menu)->arows) )\
96      row = ( (item)->y < ((menu)->rows - row) ) ? \
97            (item)->y : (menu)->rows - (menu)->arows;\
98    _nc_New_TopRow_and_CurrentItem(menu,row,item); }
99
100/* Reset the match pattern buffer */
101#define Reset_Pattern(menu) \
102  { (menu)->pindex = 0; \
103    (menu)->pattern[0] = '\0'; }
104
105/* Internal functions. */
106extern void _nc_Draw_Menu(const MENU *);
107extern void _nc_Show_Menu(const MENU *);
108extern void _nc_Calculate_Item_Length_and_Width(MENU *);
109extern void _nc_Post_Item(const MENU *, const ITEM *);
110extern bool _nc_Connect_Items(MENU *, ITEM **);
111extern void _nc_Disconnect_Items(MENU *);
112extern void _nc_New_TopRow_and_CurrentItem(MENU *,int, ITEM *);
113extern void _nc_Link_Items(MENU *);
114extern int  _nc_Match_Next_Character_In_Item_Name(MENU*,int,ITEM**);
115extern int  _nc_menu_cursor_pos(const MENU* menu, const ITEM* item,
116				int* pY, int* pX);
117