1 |
|
|
/* $OpenBSD: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $ */ |
2 |
|
|
|
3 |
|
|
/**************************************************************************** |
4 |
|
|
* Copyright (c) 1998-2003,2004 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, 1995,1997 * |
33 |
|
|
****************************************************************************/ |
34 |
|
|
|
35 |
|
|
/*************************************************************************** |
36 |
|
|
* Module m_hook * |
37 |
|
|
* Assign application specific routines for automatic invocation by menus * |
38 |
|
|
***************************************************************************/ |
39 |
|
|
|
40 |
|
|
#include "menu.priv.h" |
41 |
|
|
|
42 |
|
|
MODULE_ID("$Id: m_hook.c,v 1.7 2010/01/12 23:22:08 nicm Exp $") |
43 |
|
|
|
44 |
|
|
/* "Template" macro to generate function to set application specific hook */ |
45 |
|
|
#define GEN_HOOK_SET_FUNCTION( typ, name ) \ |
46 |
|
|
NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (MENU *menu, Menu_Hook func )\ |
47 |
|
|
{\ |
48 |
|
|
T((T_CALLED("set_" #typ "_" #name "(%p,%p)"), menu, func));\ |
49 |
|
|
(Normalize_Menu(menu) -> typ ## name = func );\ |
50 |
|
|
RETURN(E_OK);\ |
51 |
|
|
} |
52 |
|
|
|
53 |
|
|
/* "Template" macro to generate function to get application specific hook */ |
54 |
|
|
#define GEN_HOOK_GET_FUNCTION( typ, name ) \ |
55 |
|
|
NCURSES_IMPEXP Menu_Hook NCURSES_API typ ## _ ## name ( const MENU *menu )\ |
56 |
|
|
{\ |
57 |
|
|
T((T_CALLED(#typ "_" #name "(%p)"), menu));\ |
58 |
|
|
returnMenuHook(Normalize_Menu(menu) -> typ ## name);\ |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
/*--------------------------------------------------------------------------- |
62 |
|
|
| Facility : libnmenu |
63 |
|
|
| Function : int set_menu_init(MENU *menu, void (*f)(MENU *)) |
64 |
|
|
| |
65 |
|
|
| Description : Set user-exit which is called when menu is posted |
66 |
|
|
| or just after the top row changes. |
67 |
|
|
| |
68 |
|
|
| Return Values : E_OK - success |
69 |
|
|
+--------------------------------------------------------------------------*/ |
70 |
|
|
GEN_HOOK_SET_FUNCTION(menu, init) |
71 |
|
|
|
72 |
|
|
/*--------------------------------------------------------------------------- |
73 |
|
|
| Facility : libnmenu |
74 |
|
|
| Function : void (*)(MENU *) menu_init(const MENU *menu) |
75 |
|
|
| |
76 |
|
|
| Description : Return address of user-exit function which is called |
77 |
|
|
| when a menu is posted or just after the top row |
78 |
|
|
| changes. |
79 |
|
|
| |
80 |
|
|
| Return Values : Menu init function address or NULL |
81 |
|
|
+--------------------------------------------------------------------------*/ |
82 |
|
|
GEN_HOOK_GET_FUNCTION(menu, init) |
83 |
|
|
|
84 |
|
|
/*--------------------------------------------------------------------------- |
85 |
|
|
| Facility : libnmenu |
86 |
|
|
| Function : int set_menu_term (MENU *menu, void (*f)(MENU *)) |
87 |
|
|
| |
88 |
|
|
| Description : Set user-exit which is called when menu is unposted |
89 |
|
|
| or just before the top row changes. |
90 |
|
|
| |
91 |
|
|
| Return Values : E_OK - success |
92 |
|
|
+--------------------------------------------------------------------------*/ |
93 |
|
|
GEN_HOOK_SET_FUNCTION(menu, term) |
94 |
|
|
|
95 |
|
|
/*--------------------------------------------------------------------------- |
96 |
|
|
| Facility : libnmenu |
97 |
|
|
| Function : void (*)(MENU *) menu_term(const MENU *menu) |
98 |
|
|
| |
99 |
|
|
| Description : Return address of user-exit function which is called |
100 |
|
|
| when a menu is unposted or just before the top row |
101 |
|
|
| changes. |
102 |
|
|
| |
103 |
|
|
| Return Values : Menu finalization function address or NULL |
104 |
|
|
+--------------------------------------------------------------------------*/ |
105 |
|
|
GEN_HOOK_GET_FUNCTION(menu, term) |
106 |
|
|
|
107 |
|
|
/*--------------------------------------------------------------------------- |
108 |
|
|
| Facility : libnmenu |
109 |
|
|
| Function : int set_item_init (MENU *menu, void (*f)(MENU *)) |
110 |
|
|
| |
111 |
|
|
| Description : Set user-exit which is called when menu is posted |
112 |
|
|
| or just after the current item changes. |
113 |
|
|
| |
114 |
|
|
| Return Values : E_OK - success |
115 |
|
|
+--------------------------------------------------------------------------*/ |
116 |
|
|
GEN_HOOK_SET_FUNCTION(item, init) |
117 |
|
|
|
118 |
|
|
/*--------------------------------------------------------------------------- |
119 |
|
|
| Facility : libnmenu |
120 |
|
|
| Function : void (*)(MENU *) item_init (const MENU *menu) |
121 |
|
|
| |
122 |
|
|
| Description : Return address of user-exit function which is called |
123 |
|
|
| when a menu is posted or just after the current item |
124 |
|
|
| changes. |
125 |
|
|
| |
126 |
|
|
| Return Values : Item init function address or NULL |
127 |
|
|
+--------------------------------------------------------------------------*/ |
128 |
|
|
GEN_HOOK_GET_FUNCTION(item, init) |
129 |
|
|
|
130 |
|
|
/*--------------------------------------------------------------------------- |
131 |
|
|
| Facility : libnmenu |
132 |
|
|
| Function : int set_item_term (MENU *menu, void (*f)(MENU *)) |
133 |
|
|
| |
134 |
|
|
| Description : Set user-exit which is called when menu is unposted |
135 |
|
|
| or just before the current item changes. |
136 |
|
|
| |
137 |
|
|
| Return Values : E_OK - success |
138 |
|
|
+--------------------------------------------------------------------------*/ |
139 |
|
|
GEN_HOOK_SET_FUNCTION(item, term) |
140 |
|
|
|
141 |
|
|
/*--------------------------------------------------------------------------- |
142 |
|
|
| Facility : libnmenu |
143 |
|
|
| Function : void (*)(MENU *) item_init (const MENU *menu) |
144 |
|
|
| |
145 |
|
|
| Description : Return address of user-exit function which is called |
146 |
|
|
| when a menu is unposted or just before the current item |
147 |
|
|
| changes. |
148 |
|
|
| |
149 |
|
|
| Return Values : Item finalization function address or NULL |
150 |
|
|
+--------------------------------------------------------------------------*/ |
151 |
|
|
GEN_HOOK_GET_FUNCTION(item, term) |
152 |
|
|
|
153 |
|
|
/* m_hook.c ends here */ |