X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=menu%2Fm_post.c;h=b4b1bc14eb77fc32cb3c72425dd3b116b146333c;hp=bfe6ebb3cbd3114d2dc2a7a299aa494de9965d5c;hb=b661daf1160a873609d70843999cd46eff25d1f0;hpb=ba39fbc2e0cee4681395df4079d9e61c27262132 diff --git a/menu/m_post.c b/menu/m_post.c index bfe6ebb3..b4b1bc14 100644 --- a/menu/m_post.c +++ b/menu/m_post.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc. * + * Copyright 2020,2021 Thomas E. Dickey * + * Copyright 1998-2010,2012 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -37,7 +38,7 @@ #include "menu.priv.h" -MODULE_ID("$Id: m_post.c,v 1.30 2012/03/10 23:43:41 tom Exp $") +MODULE_ID("$Id: m_post.c,v 1.35 2021/03/27 23:46:29 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnmenu @@ -48,8 +49,8 @@ MODULE_ID("$Id: m_post.c,v 1.30 2012/03/10 23:43:41 tom Exp $") | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Post_Item(const MENU * menu, const ITEM * item) +MENU_EXPORT(void) +_nc_Post_Item(const MENU *menu, const ITEM *item) { int i; chtype ch; @@ -57,7 +58,6 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) int count = 0; bool isfore = FALSE, isback = FALSE, isgrey = FALSE; int name_len; - int desc_len; assert(menu->win); @@ -131,6 +131,7 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) { int m = menu->spc_desc / 2; int cy = -1, cx = -1; + int desc_len; for (ch = ' ', i = 0; i < menu->spc_desc; i++) { @@ -196,11 +197,11 @@ _nc_Post_Item(const MENU * menu, const ITEM * item) | | Return Values : - +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(void) -_nc_Draw_Menu(const MENU * menu) +MENU_EXPORT(void) +_nc_Draw_Menu(const MENU *menu) { ITEM *item = menu->items[0]; - ITEM *lasthor, *lastvert; + ITEM *lastvert; ITEM *hitem; int y = 0; chtype s_bkgd; @@ -212,14 +213,16 @@ _nc_Draw_Menu(const MENU * menu) 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 { + ITEM *lasthor; + wmove(menu->win, y, 0); hitem = item; - lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem; + lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : hitem; do { @@ -266,8 +269,8 @@ _nc_Draw_Menu(const MENU * menu) | E_BAD_STATE - Menu in userexit routine | E_POSTED - Menu already posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -post_menu(MENU * menu) +MENU_EXPORT(int) +post_menu(MENU *menu) { T((T_CALLED("post_menu(%p)"), (void *)menu)); @@ -282,7 +285,6 @@ post_menu(MENU * menu) if (menu->items && *(menu->items)) { - int y; int h = 1 + menu->spc_rows * (menu->rows - 1); WINDOW *win = Get_Menu_Window(menu); @@ -290,7 +292,8 @@ post_menu(MENU * 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))) @@ -305,7 +308,7 @@ post_menu(MENU * menu) else RETURN(E_NOT_CONNECTED); - menu->status |= _POSTED; + SetStatus(menu, _POSTED); if (!(menu->opt & O_ONEVALUE)) { @@ -338,8 +341,8 @@ post_menu(MENU * menu) | E_BAD_STATE - menu in userexit routine | E_NOT_POSTED - menu is not posted +--------------------------------------------------------------------------*/ -NCURSES_EXPORT(int) -unpost_menu(MENU * menu) +MENU_EXPORT(int) +unpost_menu(MENU *menu) { WINDOW *win; @@ -369,7 +372,7 @@ unpost_menu(MENU * menu) delwin(menu->win); menu->win = (WINDOW *)0; - menu->status &= (unsigned short)(~_POSTED); + ClrStatus(menu, _POSTED); RETURN(E_OK); }