]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - menu/m_item_top.c
ncurses 6.2 - patch 20210619
[ncurses.git] / menu / m_item_top.c
index cbe092afbbc1870494ccbdc92104815da9fcbcc8..68303c7676b5e6b2395d64c27391dc9998d10da7 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright 2020,2021 Thomas E. Dickey                                     *
+ * Copyright 1998-2004,2010 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            *
@@ -27,7 +28,7 @@
  ****************************************************************************/
 
 /****************************************************************************
  ****************************************************************************/
 
 /****************************************************************************
- *   Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
+ *   Author:  Juergen Pfeifer, 1995,1997                                    *
  ****************************************************************************/
 
 /***************************************************************************
  ****************************************************************************/
 
 /***************************************************************************
 
 #include "menu.priv.h"
 
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_item_top.c,v 1.4 1999/05/16 17:26:01 juergen Exp $")
+MODULE_ID("$Id: m_item_top.c,v 1.16 2021/06/17 21:11:08 tom Exp $")
 
 /*---------------------------------------------------------------------------
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int set_top_row(MENU *menu, int row)
 |   Function      :  int set_top_row(MENU *menu, int row)
-|   
-|   Description   :  Makes the speified row the top row in the menu
+|
+|   Description   :  Makes the specified row the top row in the menu
 |
 |   Return Values :  E_OK             - success
 |                    E_BAD_ARGUMENT   - not a menu pointer or invalid row
 |                    E_NOT_CONNECTED  - there are no items for the menu
 +--------------------------------------------------------------------------*/
 |
 |   Return Values :  E_OK             - success
 |                    E_BAD_ARGUMENT   - not a menu pointer or invalid row
 |                    E_NOT_CONNECTED  - there are no items for the menu
 +--------------------------------------------------------------------------*/
-int set_top_row(MENU * menu, int row)
+MENU_EXPORT(int)
+set_top_row(MENU *menu, int row)
 {
 {
-  ITEM *item;
-  
+  T((T_CALLED("set_top_row(%p,%d)"), (void *)menu, row));
+
   if (menu)
     {
   if (menu)
     {
-      if ( menu->status & _IN_DRIVER )
+      if (menu->status & _IN_DRIVER)
        RETURN(E_BAD_STATE);
       if (menu->items == (ITEM **)0)
        RETURN(E_NOT_CONNECTED);
        RETURN(E_BAD_STATE);
       if (menu->items == (ITEM **)0)
        RETURN(E_NOT_CONNECTED);
-      
-      if ((row<0) || (row > (menu->rows - menu->arows)))
+
+      if ((row < 0) || (row > (menu->rows - menu->arows)))
        RETURN(E_BAD_ARGUMENT);
     }
   else
     RETURN(E_BAD_ARGUMENT);
        RETURN(E_BAD_ARGUMENT);
     }
   else
     RETURN(E_BAD_ARGUMENT);
-  
+
   if (row != menu->toprow)
     {
   if (row != menu->toprow)
     {
-      if (menu->status & _LINK_NEEDED) 
+      ITEM *item;
+
+      if (menu->status & _LINK_NEEDED)
        _nc_Link_Items(menu);
        _nc_Link_Items(menu);
-      
-      item = menu->items[ (menu->opt&O_ROWMAJOR) ? (row*menu->cols) : row ];
+
+      item = menu->items[(menu->opt & O_ROWMAJOR) ? (row * menu->cols) : row];
       assert(menu->pattern);
       Reset_Pattern(menu);
       _nc_New_TopRow_and_CurrentItem(menu, row, item);
     }
       assert(menu->pattern);
       Reset_Pattern(menu);
       _nc_New_TopRow_and_CurrentItem(menu, row, item);
     }
-  
-    RETURN(E_OK);
+
+  RETURN(E_OK);
 }
 
 /*---------------------------------------------------------------------------
 }
 
 /*---------------------------------------------------------------------------
-|   Facility      :  libnmenu  
+|   Facility      :  libnmenu
 |   Function      :  int top_row(const MENU *)
 |   Function      :  int top_row(const MENU *)
-|   
+|
 |   Description   :  Return the top row of the menu
 |
 |   Return Values :  The row number or ERR if there is no row
 +--------------------------------------------------------------------------*/
 |   Description   :  Return the top row of the menu
 |
 |   Return Values :  The row number or ERR if there is no row
 +--------------------------------------------------------------------------*/
-int top_row(const MENU * menu)
+MENU_EXPORT(int)
+top_row(const MENU *menu)
 {
 {
+  T((T_CALLED("top_row(%p)"), (const void *)menu));
   if (menu && menu->items && *(menu->items))
     {
   if (menu && menu->items && *(menu->items))
     {
-      assert( (menu->toprow>=0) && (menu->toprow < menu->rows) );
-      return menu->toprow;
+      assert((menu->toprow >= 0) && (menu->toprow < menu->rows));
+      returnCode(menu->toprow);
     }
   else
     }
   else
-    return(ERR);
+    returnCode(ERR);
 }
 
 /* m_item_top.c ends here */
 }
 
 /* m_item_top.c ends here */