Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2020-2021,2022 Thomas E. Dickey * |
| 3 | * Copyright 1998-2010,2012 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | * copy of this software and associated documentation files (the * |
| 7 | * "Software"), to deal in the Software without restriction, including * |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | * copies of the Software, and to permit persons to whom the Software is * |
| 11 | * furnished to do so, subject to the following conditions: * |
| 12 | * * |
| 13 | * The above copyright notice and this permission notice shall be included * |
| 14 | * in all copies or substantial portions of the Software. * |
| 15 | * * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | * * |
| 24 | * Except as contained in this notice, the name(s) of the above copyright * |
| 25 | * holders shall not be used in advertising or otherwise to promote the * |
| 26 | * sale, use or other dealings in this Software without prior written * |
| 27 | * authorization. * |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Author: Juergen Pfeifer, 1995,1997 * |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | /*************************************************************************** |
| 35 | * Module m_post * |
| 36 | * Write or erase menus from associated subwindows * |
| 37 | ***************************************************************************/ |
| 38 | |
| 39 | #include "menu.priv.h" |
| 40 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 41 | MODULE_ID("$Id: m_post.c,v 1.38 2022/09/24 09:38:44 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 42 | |
| 43 | /*--------------------------------------------------------------------------- |
| 44 | | Facility : libnmenu |
| 45 | | Function : void _nc_Post_Item(MENU *menu, ITEM *item) |
| 46 | | |
| 47 | | Description : Draw the item in the menus window at the current |
| 48 | | window position |
| 49 | | |
| 50 | | Return Values : - |
| 51 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 52 | MENU_EXPORT(void) |
| 53 | _nc_Post_Item(const MENU *menu, const ITEM *item) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 54 | { |
| 55 | int i; |
| 56 | chtype ch; |
| 57 | int item_x, item_y; |
| 58 | int count = 0; |
| 59 | bool isfore = FALSE, isback = FALSE, isgrey = FALSE; |
| 60 | int name_len; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 61 | |
| 62 | assert(menu->win); |
| 63 | |
| 64 | getyx(menu->win, item_y, item_x); |
| 65 | |
| 66 | /* We need a marker iff |
| 67 | - it is a onevalued menu and it is the current item |
| 68 | - or it has a selection value |
| 69 | */ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 70 | wattron(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 71 | if (item->value || (item == menu->curitem)) |
| 72 | { |
| 73 | if (menu->marklen) |
| 74 | { |
| 75 | /* In a multi selection menu we use the fore attribute |
| 76 | for a selected marker that is not the current one. |
| 77 | This improves visualization of the menu, because now |
| 78 | always the 'normal' marker denotes the current |
| 79 | item. */ |
| 80 | if (!(menu->opt & O_ONEVALUE) && item->value && item != menu->curitem) |
| 81 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 82 | wattron(menu->win, (int)menu->fore); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 83 | isfore = TRUE; |
| 84 | } |
| 85 | waddstr(menu->win, menu->mark); |
| 86 | if (isfore) |
| 87 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 88 | wattron(menu->win, (int)menu->fore); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 89 | isfore = FALSE; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | else /* otherwise we have to wipe out the marker area */ |
| 94 | for (ch = ' ', i = menu->marklen; i > 0; i--) |
| 95 | waddch(menu->win, ch); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 96 | wattroff(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 97 | count += menu->marklen; |
| 98 | |
| 99 | /* First we have to calculate the attribute depending on selectability |
| 100 | and selection status |
| 101 | */ |
| 102 | if (!(item->opt & O_SELECTABLE)) |
| 103 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 104 | wattron(menu->win, (int)menu->grey); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 105 | isgrey = TRUE; |
| 106 | } |
| 107 | else |
| 108 | { |
| 109 | if (item->value || item == menu->curitem) |
| 110 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 111 | wattron(menu->win, (int)menu->fore); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 112 | isfore = TRUE; |
| 113 | } |
| 114 | else |
| 115 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 116 | wattron(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 117 | isback = TRUE; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | waddnstr(menu->win, item->name.str, item->name.length); |
| 122 | name_len = _nc_Calculate_Text_Width(&(item->name)); |
| 123 | for (ch = ' ', i = menu->namelen - name_len; i > 0; i--) |
| 124 | { |
| 125 | waddch(menu->win, ch); |
| 126 | } |
| 127 | count += menu->namelen; |
| 128 | |
| 129 | /* Show description if required and available */ |
| 130 | if ((menu->opt & O_SHOWDESC) && menu->desclen > 0) |
| 131 | { |
| 132 | int m = menu->spc_desc / 2; |
| 133 | int cy = -1, cx = -1; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 134 | int desc_len; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 135 | |
| 136 | for (ch = ' ', i = 0; i < menu->spc_desc; i++) |
| 137 | { |
| 138 | if (i == m) |
| 139 | { |
| 140 | waddch(menu->win, menu->pad); |
| 141 | getyx(menu->win, cy, cx); |
| 142 | } |
| 143 | else |
| 144 | waddch(menu->win, ch); |
| 145 | } |
| 146 | if (item->description.length) |
| 147 | waddnstr(menu->win, item->description.str, item->description.length); |
| 148 | desc_len = _nc_Calculate_Text_Width(&(item->description)); |
| 149 | for (ch = ' ', i = menu->desclen - desc_len; i > 0; i--) |
| 150 | { |
| 151 | waddch(menu->win, ch); |
| 152 | } |
| 153 | count += menu->desclen + menu->spc_desc; |
| 154 | |
| 155 | if (menu->spc_rows > 1) |
| 156 | { |
| 157 | int j, k, ncy, ncx; |
| 158 | |
| 159 | assert(cx >= 0 && cy >= 0); |
| 160 | getyx(menu->win, ncy, ncx); |
| 161 | if (isgrey) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 162 | wattroff(menu->win, (int)menu->grey); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 163 | else if (isfore) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 164 | wattroff(menu->win, (int)menu->fore); |
| 165 | wattron(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 166 | for (j = 1; j < menu->spc_rows; j++) |
| 167 | { |
| 168 | if ((item_y + j) < getmaxy(menu->win)) |
| 169 | { |
| 170 | wmove(menu->win, item_y + j, item_x); |
| 171 | for (k = 0; k < count; k++) |
| 172 | waddch(menu->win, ' '); |
| 173 | } |
| 174 | if ((cy + j) < getmaxy(menu->win)) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 175 | (void)mvwaddch(menu->win, cy + j, cx - 1, menu->pad); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 176 | } |
| 177 | wmove(menu->win, ncy, ncx); |
| 178 | if (!isback) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 179 | wattroff(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
| 183 | /* Remove attributes */ |
| 184 | if (isfore) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 185 | wattroff(menu->win, (int)menu->fore); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 186 | if (isback) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 187 | wattroff(menu->win, (int)menu->back); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 188 | if (isgrey) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 189 | wattroff(menu->win, (int)menu->grey); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /*--------------------------------------------------------------------------- |
| 193 | | Facility : libnmenu |
| 194 | | Function : void _nc_Draw_Menu(const MENU *) |
| 195 | | |
| 196 | | Description : Display the menu in its windows |
| 197 | | |
| 198 | | Return Values : - |
| 199 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 200 | MENU_EXPORT(void) |
| 201 | _nc_Draw_Menu(const MENU *menu) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 202 | { |
| 203 | ITEM *item = menu->items[0]; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 204 | ITEM *lastvert; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 205 | ITEM *hitem; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 206 | chtype s_bkgd; |
| 207 | |
| 208 | assert(item && menu->win); |
| 209 | |
| 210 | s_bkgd = getbkgd(menu->win); |
| 211 | wbkgdset(menu->win, menu->back); |
| 212 | werase(menu->win); |
| 213 | wbkgdset(menu->win, s_bkgd); |
| 214 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 215 | lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 216 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 217 | if (item != NULL) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 218 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 219 | int y = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 220 | |
| 221 | do |
| 222 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 223 | ITEM *lasthor; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 224 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 225 | wmove(menu->win, y, 0); |
| 226 | |
| 227 | hitem = item; |
| 228 | lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem; |
| 229 | |
| 230 | do |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 231 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 232 | _nc_Post_Item(menu, hitem); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 233 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 234 | wattron(menu->win, (int)menu->back); |
| 235 | if (((hitem = hitem->right) != lasthor) && hitem) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 236 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 237 | int i, j, cy, cx; |
| 238 | chtype ch = ' '; |
| 239 | |
| 240 | getyx(menu->win, cy, cx); |
| 241 | for (j = 0; j < menu->spc_rows; j++) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 242 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 243 | wmove(menu->win, cy + j, cx); |
| 244 | for (i = 0; i < menu->spc_cols; i++) |
| 245 | { |
| 246 | waddch(menu->win, ch); |
| 247 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 248 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 249 | wmove(menu->win, cy, cx + menu->spc_cols); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 250 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 251 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 252 | while (hitem && (hitem != lasthor)); |
| 253 | wattroff(menu->win, (int)menu->back); |
| 254 | |
| 255 | item = item->down; |
| 256 | y += menu->spc_rows; |
| 257 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 258 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 259 | while (item && (item != lastvert)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 260 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | /*--------------------------------------------------------------------------- |
| 264 | | Facility : libnmenu |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 265 | | Function : int post_menu(MENU* menu) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 266 | | |
| 267 | | Description : Post a menu to the screen. This makes it visible. |
| 268 | | |
| 269 | | Return Values : E_OK - success |
| 270 | | E_BAD_ARGUMENT - not a valid menu pointer |
| 271 | | E_SYSTEM_ERROR - error in lower layers |
| 272 | | E_NOT_CONNECTED - No items connected to menu |
| 273 | | E_BAD_STATE - Menu in userexit routine |
| 274 | | E_POSTED - Menu already posted |
| 275 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 276 | MENU_EXPORT(int) |
| 277 | post_menu(MENU *menu) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 278 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 279 | T((T_CALLED("post_menu(%p)"), (void *)menu)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 280 | |
| 281 | if (!menu) |
| 282 | RETURN(E_BAD_ARGUMENT); |
| 283 | |
| 284 | if (menu->status & _IN_DRIVER) |
| 285 | RETURN(E_BAD_STATE); |
| 286 | |
| 287 | if (menu->status & _POSTED) |
| 288 | RETURN(E_POSTED); |
| 289 | |
| 290 | if (menu->items && *(menu->items)) |
| 291 | { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 292 | int h = 1 + menu->spc_rows * (menu->rows - 1); |
| 293 | |
| 294 | WINDOW *win = Get_Menu_Window(menu); |
| 295 | int maxy = getmaxy(win); |
| 296 | |
| 297 | if ((menu->win = newpad(h, menu->width))) |
| 298 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 299 | int y = (maxy >= h) ? h : maxy; |
| 300 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 301 | if (y >= menu->height) |
| 302 | y = menu->height; |
| 303 | if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0))) |
| 304 | RETURN(E_SYSTEM_ERROR); |
| 305 | } |
| 306 | else |
| 307 | RETURN(E_SYSTEM_ERROR); |
| 308 | |
| 309 | if (menu->status & _LINK_NEEDED) |
| 310 | _nc_Link_Items(menu); |
| 311 | } |
| 312 | else |
| 313 | RETURN(E_NOT_CONNECTED); |
| 314 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 315 | SetStatus(menu, _POSTED); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 316 | |
| 317 | if (!(menu->opt & O_ONEVALUE)) |
| 318 | { |
| 319 | ITEM **items; |
| 320 | |
| 321 | for (items = menu->items; *items; items++) |
| 322 | { |
| 323 | (*items)->value = FALSE; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | _nc_Draw_Menu(menu); |
| 328 | |
| 329 | Call_Hook(menu, menuinit); |
| 330 | Call_Hook(menu, iteminit); |
| 331 | |
| 332 | _nc_Show_Menu(menu); |
| 333 | |
| 334 | RETURN(E_OK); |
| 335 | } |
| 336 | |
| 337 | /*--------------------------------------------------------------------------- |
| 338 | | Facility : libnmenu |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 339 | | Function : int unpost_menu(MENU*) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 340 | | |
| 341 | | Description : Detach menu from screen |
| 342 | | |
| 343 | | Return Values : E_OK - success |
| 344 | | E_BAD_ARGUMENT - not a valid menu pointer |
| 345 | | E_BAD_STATE - menu in userexit routine |
| 346 | | E_NOT_POSTED - menu is not posted |
| 347 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 348 | MENU_EXPORT(int) |
| 349 | unpost_menu(MENU *menu) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 350 | { |
| 351 | WINDOW *win; |
| 352 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 353 | T((T_CALLED("unpost_menu(%p)"), (void *)menu)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 354 | |
| 355 | if (!menu) |
| 356 | RETURN(E_BAD_ARGUMENT); |
| 357 | |
| 358 | if (menu->status & _IN_DRIVER) |
| 359 | RETURN(E_BAD_STATE); |
| 360 | |
| 361 | if (!(menu->status & _POSTED)) |
| 362 | RETURN(E_NOT_POSTED); |
| 363 | |
| 364 | Call_Hook(menu, itemterm); |
| 365 | Call_Hook(menu, menuterm); |
| 366 | |
| 367 | win = Get_Menu_Window(menu); |
| 368 | werase(win); |
| 369 | wsyncup(win); |
| 370 | |
| 371 | assert(menu->sub); |
| 372 | delwin(menu->sub); |
| 373 | menu->sub = (WINDOW *)0; |
| 374 | |
| 375 | assert(menu->win); |
| 376 | delwin(menu->win); |
| 377 | menu->win = (WINDOW *)0; |
| 378 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 379 | ClrStatus(menu, _POSTED); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 380 | |
| 381 | RETURN(E_OK); |
| 382 | } |
| 383 | |
| 384 | /* m_post.c ends here */ |