]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - menu/m_post.c
ncurses 6.5 - patch 20240504
[ncurses.git] / menu / m_post.c
index b4b1bc14eb77fc32cb3c72425dd3b116b146333c..cb80230433d5c7efd09b3cd756e01d6b86ca49f1 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2021 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  *
@@ -38,7 +38,7 @@
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_post.c,v 1.35 2021/03/27 23:46:29 tom Exp $")
+MODULE_ID("$Id: m_post.c,v 1.38 2022/09/24 09:38:44 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -203,7 +203,6 @@ _nc_Draw_Menu(const MENU *menu)
   ITEM *item = menu->items[0];
   ITEM *lastvert;
   ITEM *hitem;
-  int y = 0;
   chtype s_bkgd;
 
   assert(item && menu->win);
@@ -215,45 +214,50 @@ _nc_Draw_Menu(const MENU *menu)
 
   lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *)0 : item;
 
-  do
+  if (item != NULL)
     {
-      ITEM *lasthor;
-
-      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));
 }
 
 /*---------------------------------------------------------------------------