]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - panel/p_below.c
ncurses 6.0 - patch 20150810
[ncurses.git] / panel / p_below.c
index a7eb4705789e87bb75fdeedcb8bad315f0ba1e07..913efa91390bf05fd37f0d6609efdf0ffcd26578 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc.                        *
+ * Copyright (c) 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            *
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Juergen Pfeifer                         1997-1999,2008          *
  ****************************************************************************/
 
 /* p_below.c
  */
 #include "panel.priv.h"
 
-MODULE_ID("$Id: p_below.c,v 1.3 1999/09/18 11:03:33 juergen Exp $")
+MODULE_ID("$Id: p_below.c,v 1.9 2012/03/10 23:43:41 tom Exp $")
 
-PANEL*
-panel_below(const PANEL *pan)
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(PANEL *)
+ceiling_panel(SCREEN * sp)
 {
-  if(!pan)
+  T((T_CALLED("ceiling_panel(%p)"), (void *)sp));
+  if (sp)
     {
+      struct panelhook *ph = NCURSES_SP_NAME(_nc_panelhook) (sp);
+
       /* if top and bottom are equal, we have no or only the pseudo panel */
-      return(EMPTY_STACK() ? (PANEL*)0 : _nc_top_panel);
+      returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
     }
   else
     {
+      if (0 == CURRENT_SCREEN)
+       returnPanel(0);
+      else
+       returnPanel(ceiling_panel(CURRENT_SCREEN));
+    }
+}
+#endif
+
+NCURSES_EXPORT(PANEL *)
+panel_below(const PANEL * pan)
+{
+  PANEL *result;
+
+  T((T_CALLED("panel_below(%p)"), (const void *)pan));
+  if (pan)
+    {
+      GetHook(pan);
       /* we must not return the pseudo panel */
-      return(Is_Pseudo(pan->below) ? (PANEL*) 0 : pan->below);
+      result = Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below;
+    }
+  else
+    {
+#if NCURSES_SP_FUNCS
+      result = ceiling_panel(CURRENT_SCREEN);
+#else
+      /* if top and bottom are equal, we have no or only the pseudo panel */
+      result = EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel;
+#endif
     }
+  returnPanel(result);
 }