]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - menu/m_format.c
ncurses 6.2 - patch 20210508
[ncurses.git] / menu / m_format.c
index 8e68a036ee2eff08d4f683d3c0f3ecc1b5616acf..65adfc6bfcb0827b4263340f49e2507073e7cc3e 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998-2004,2010 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            *
  *                                                                          *
  * 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"
 
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_format.c,v 1.16 2010/01/23 21:20:10 tom Exp $")
+MODULE_ID("$Id: m_format.c,v 1.22 2021/03/27 23:46:29 tom Exp $")
 
 #define minimum(a,b) ((a)<(b) ? (a): (b))
 
 
 #define minimum(a,b) ((a)<(b) ? (a): (b))
 
@@ -55,10 +56,9 @@ MODULE_ID("$Id: m_format.c,v 1.16 2010/01/23 21:20:10 tom Exp $")
 |                    E_NOT_CONNECTED        - there are no items connected
 |                    E_POSTED               - the menu is already posted
 +--------------------------------------------------------------------------*/
 |                    E_NOT_CONNECTED        - there are no items connected
 |                    E_POSTED               - the menu is already posted
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
-set_menu_format(MENU * menu, int rows, int cols)
+MENU_EXPORT(int)
+set_menu_format(MENU *menu, int rows, int cols)
 {
 {
-  int total_rows, total_cols;
 
   T((T_CALLED("set_menu_format(%p,%d,%d)"), (void *)menu, rows, cols));
 
 
   T((T_CALLED("set_menu_format(%p,%d,%d)"), (void *)menu, rows, cols));
 
@@ -67,6 +67,8 @@ set_menu_format(MENU * menu, int rows, int cols)
 
   if (menu)
     {
 
   if (menu)
     {
+      int total_rows, total_cols;
+
       if (menu->status & _POSTED)
        RETURN(E_POSTED);
 
       if (menu->status & _POSTED)
        RETURN(E_POSTED);
 
@@ -81,8 +83,8 @@ set_menu_format(MENU * menu, int rows, int cols)
       if (menu->pattern)
        Reset_Pattern(menu);
 
       if (menu->pattern)
        Reset_Pattern(menu);
 
-      menu->frows = rows;
-      menu->fcols = cols;
+      menu->frows = (short)rows;
+      menu->fcols = (short)cols;
 
       assert(rows > 0 && cols > 0);
       total_rows = (menu->nitems - 1) / cols + 1;
 
       assert(rows > 0 && cols > 0);
       total_rows = (menu->nitems - 1) / cols + 1;
@@ -90,21 +92,21 @@ set_menu_format(MENU * menu, int rows, int cols)
        minimum(menu->nitems, cols) :
        (menu->nitems - 1) / total_rows + 1;
 
        minimum(menu->nitems, cols) :
        (menu->nitems - 1) / total_rows + 1;
 
-      menu->rows = total_rows;
-      menu->cols = total_cols;
-      menu->arows = minimum(total_rows, rows);
+      menu->rows = (short)total_rows;
+      menu->cols = (short)total_cols;
+      menu->arows = (short)minimum(total_rows, rows);
       menu->toprow = 0;
       menu->curitem = *(menu->items);
       assert(menu->curitem);
       menu->toprow = 0;
       menu->curitem = *(menu->items);
       assert(menu->curitem);
-      menu->status |= _LINK_NEEDED;
+      SetStatus(menu, _LINK_NEEDED);
       _nc_Calculate_Item_Length_and_Width(menu);
     }
   else
     {
       if (rows > 0)
       _nc_Calculate_Item_Length_and_Width(menu);
     }
   else
     {
       if (rows > 0)
-       _nc_Default_Menu.frows = rows;
+       _nc_Default_Menu.frows = (short)rows;
       if (cols > 0)
       if (cols > 0)
-       _nc_Default_Menu.fcols = cols;
+       _nc_Default_Menu.fcols = (short)cols;
     }
 
   RETURN(E_OK);
     }
 
   RETURN(E_OK);
@@ -119,8 +121,8 @@ set_menu_format(MENU * menu, int rows, int cols)
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
 |
 |   Return Values :  -
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(void)
-menu_format(const MENU * menu, int *rows, int *cols)
+MENU_EXPORT(void)
+menu_format(const MENU *menu, int *rows, int *cols)
 {
   if (rows)
     *rows = Normalize_Menu(menu)->frows;
 {
   if (rows)
     *rows = Normalize_Menu(menu)->frows;