/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020-2021,2022 Thomas E. Dickey *
* Copyright 1998-2010,2012 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#include "menu.priv.h"
-MODULE_ID("$Id: m_post.c,v 1.33 2020/05/24 01:40:20 anonymous.maarten Exp $")
+MODULE_ID("$Id: m_post.c,v 1.38 2022/09/24 09:38:44 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnmenu
| Return Values : -
+--------------------------------------------------------------------------*/
MENU_EXPORT(void)
-_nc_Post_Item(const MENU * menu, const ITEM * item)
+_nc_Post_Item(const MENU *menu, const ITEM *item)
{
int i;
chtype ch;
int count = 0;
bool isfore = FALSE, isback = FALSE, isgrey = FALSE;
int name_len;
- int desc_len;
assert(menu->win);
{
int m = menu->spc_desc / 2;
int cy = -1, cx = -1;
+ int desc_len;
for (ch = ' ', i = 0; i < menu->spc_desc; i++)
{
| Return Values : -
+--------------------------------------------------------------------------*/
MENU_EXPORT(void)
-_nc_Draw_Menu(const MENU * menu)
+_nc_Draw_Menu(const MENU *menu)
{
ITEM *item = menu->items[0];
- ITEM *lasthor, *lastvert;
+ ITEM *lastvert;
ITEM *hitem;
- int y = 0;
chtype s_bkgd;
assert(item && menu->win);
werase(menu->win);
wbkgdset(menu->win, s_bkgd);
- lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;
+ lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
- do
+ if (item != NULL)
{
- wmove(menu->win, y, 0);
-
- hitem = item;
- lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;
+ int y = 0;
do
{
- _nc_Post_Item(menu, hitem);
+ ITEM *lasthor;
- wattron(menu->win, (int)menu->back);
- if (((hitem = hitem->right) != lasthor) && hitem)
+ wmove(menu->win, y, 0);
+
+ hitem = item;
+ lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem;
+
+ do
{
- int i, j, cy, cx;
- chtype ch = ' ';
+ _nc_Post_Item(menu, hitem);
- getyx(menu->win, cy, cx);
- for (j = 0; j < menu->spc_rows; j++)
+ wattron(menu->win, (int)menu->back);
+ if (((hitem = hitem->right) != lasthor) && hitem)
{
- wmove(menu->win, cy + j, cx);
- for (i = 0; i < menu->spc_cols; i++)
+ int i, j, cy, cx;
+ chtype ch = ' ';
+
+ getyx(menu->win, cy, cx);
+ for (j = 0; j < menu->spc_rows; j++)
{
- waddch(menu->win, ch);
+ wmove(menu->win, cy + j, cx);
+ for (i = 0; i < menu->spc_cols; i++)
+ {
+ waddch(menu->win, ch);
+ }
}
+ wmove(menu->win, cy, cx + menu->spc_cols);
}
- wmove(menu->win, cy, cx + menu->spc_cols);
}
- }
- while (hitem && (hitem != lasthor));
- wattroff(menu->win, (int)menu->back);
+ while (hitem && (hitem != lasthor));
+ wattroff(menu->win, (int)menu->back);
- item = item->down;
- y += menu->spc_rows;
+ item = item->down;
+ y += menu->spc_rows;
+ }
+ while (item && (item != lastvert));
}
- while (item && (item != lastvert));
}
/*---------------------------------------------------------------------------
| E_POSTED - Menu already posted
+--------------------------------------------------------------------------*/
MENU_EXPORT(int)
-post_menu(MENU * menu)
+post_menu(MENU *menu)
{
T((T_CALLED("post_menu(%p)"), (void *)menu));
if (menu->items && *(menu->items))
{
- int y;
int h = 1 + menu->spc_rows * (menu->rows - 1);
WINDOW *win = Get_Menu_Window(menu);
if ((menu->win = newpad(h, menu->width)))
{
- y = (maxy >= h) ? h : maxy;
+ int y = (maxy >= h) ? h : maxy;
+
if (y >= menu->height)
y = menu->height;
if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0)))
| E_NOT_POSTED - menu is not posted
+--------------------------------------------------------------------------*/
MENU_EXPORT(int)
-unpost_menu(MENU * menu)
+unpost_menu(MENU *menu)
{
WINDOW *win;