]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - menu/m_cursor.c
ncurses 6.2 - patch 20210213
[ncurses.git] / menu / m_cursor.c
index 9f127aa5c2d4f054fbb87452078b796b33b53e8f..8cf15ce513358e9b0265450d405dffff390fa5e3 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 1998-2009,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            *
 
 /***************************************************************************
 * Module m_cursor                                                          *
-* Correctly position a menus cursor                                        *
+* Correctly position a menu's cursor                                       *
 ***************************************************************************/
 
 #include "menu.priv.h"
 
-MODULE_ID("$Id: m_cursor.c,v 1.19 2004/12/25 22:03:00 tom Exp $")
+MODULE_ID("$Id: m_cursor.c,v 1.25 2020/12/12 00:38:02 tom Exp $")
 
 /*---------------------------------------------------------------------------
 |   Facility      :  libnmenu
@@ -49,16 +50,16 @@ MODULE_ID("$Id: m_cursor.c,v 1.19 2004/12/25 22:03:00 tom Exp $")
 |                    E_BAD_ARGUMENT  - invalid menu
 |                    E_NOT_POSTED    - Menu is not posted
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
-_nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
+MENU_EXPORT(int)
+_nc_menu_cursor_pos(const MENU *menu, const ITEM *item, int *pY, int *pX)
 {
   if (!menu || !pX || !pY)
     return (E_BAD_ARGUMENT);
   else
     {
-      if ((ITEM *) 0 == item)
+      if ((ITEM *)0 == item)
        item = menu->curitem;
-      assert(item != (ITEM *) 0);
+      assert(item != (ITEM *)0);
 
       if (!(menu->status & _POSTED))
        return (E_NOT_POSTED);
@@ -79,18 +80,18 @@ _nc_menu_cursor_pos(const MENU * menu, const ITEM * item, int *pY, int *pX)
 |                    E_BAD_ARGUMENT  - invalid menu
 |                    E_NOT_POSTED    - Menu is not posted
 +--------------------------------------------------------------------------*/
-NCURSES_EXPORT(int)
-pos_menu_cursor(const MENU * menu)
+MENU_EXPORT(int)
+pos_menu_cursor(const MENU *menu)
 {
   WINDOW *win, *sub;
-  int x, y;
-  int err = _nc_menu_cursor_pos(menu, (ITEM *) 0, &y, &x);
+  int x = 0, y = 0;
+  int err = _nc_menu_cursor_pos(menu, (ITEM *)0, &y, &x);
 
-  T((T_CALLED("pos_menu_cursor(%p)"), menu));
+  T((T_CALLED("pos_menu_cursor(%p)"), (const void *)menu));
 
   if (E_OK == err)
     {
-      win = menu->userwin ? menu->userwin : stdscr;
+      win = Get_Menu_UserWin(menu);
       sub = menu->usersub ? menu->usersub : win;
       assert(win && sub);