xref: /dflybsd-src/contrib/ncurses/panel/p_below.c (revision 3468e90c2a982d2508ffab3b87946f66bebe4d03)
1fdd4e1e0SJan Lentfer /****************************************************************************
2*3468e90cSJohn Marino  * Copyright (c) 1998-2010,2012 Free Software Foundation, Inc.              *
3fdd4e1e0SJan Lentfer  *                                                                          *
4fdd4e1e0SJan Lentfer  * Permission is hereby granted, free of charge, to any person obtaining a  *
5fdd4e1e0SJan Lentfer  * copy of this software and associated documentation files (the            *
6fdd4e1e0SJan Lentfer  * "Software"), to deal in the Software without restriction, including      *
7fdd4e1e0SJan Lentfer  * without limitation the rights to use, copy, modify, merge, publish,      *
8fdd4e1e0SJan Lentfer  * distribute, distribute with modifications, sublicense, and/or sell       *
9fdd4e1e0SJan Lentfer  * copies of the Software, and to permit persons to whom the Software is    *
10fdd4e1e0SJan Lentfer  * furnished to do so, subject to the following conditions:                 *
11fdd4e1e0SJan Lentfer  *                                                                          *
12fdd4e1e0SJan Lentfer  * The above copyright notice and this permission notice shall be included  *
13fdd4e1e0SJan Lentfer  * in all copies or substantial portions of the Software.                   *
14fdd4e1e0SJan Lentfer  *                                                                          *
15fdd4e1e0SJan Lentfer  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16fdd4e1e0SJan Lentfer  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17fdd4e1e0SJan Lentfer  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18fdd4e1e0SJan Lentfer  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19fdd4e1e0SJan Lentfer  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20fdd4e1e0SJan Lentfer  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21fdd4e1e0SJan Lentfer  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22fdd4e1e0SJan Lentfer  *                                                                          *
23fdd4e1e0SJan Lentfer  * Except as contained in this notice, the name(s) of the above copyright   *
24fdd4e1e0SJan Lentfer  * holders shall not be used in advertising or otherwise to promote the     *
25fdd4e1e0SJan Lentfer  * sale, use or other dealings in this Software without prior written       *
26fdd4e1e0SJan Lentfer  * authorization.                                                           *
27fdd4e1e0SJan Lentfer  ****************************************************************************/
28fdd4e1e0SJan Lentfer 
29fdd4e1e0SJan Lentfer /****************************************************************************
30fdd4e1e0SJan Lentfer  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
31fdd4e1e0SJan Lentfer  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
3200d8f3c4SJohn Marino  *     and: Juergen Pfeifer                         1997-1999,2008          *
33fdd4e1e0SJan Lentfer  ****************************************************************************/
34fdd4e1e0SJan Lentfer 
35fdd4e1e0SJan Lentfer /* p_below.c
36fdd4e1e0SJan Lentfer  */
37fdd4e1e0SJan Lentfer #include "panel.priv.h"
38fdd4e1e0SJan Lentfer 
39*3468e90cSJohn Marino MODULE_ID("$Id: p_below.c,v 1.9 2012/03/10 23:43:41 tom Exp $")
40fdd4e1e0SJan Lentfer 
4100d8f3c4SJohn Marino #if NCURSES_SP_FUNCS
42fdd4e1e0SJan Lentfer NCURSES_EXPORT(PANEL *)
4300d8f3c4SJohn Marino ceiling_panel(SCREEN * sp)
44fdd4e1e0SJan Lentfer {
45*3468e90cSJohn Marino   T((T_CALLED("ceiling_panel(%p)"), (void *)sp));
4600d8f3c4SJohn Marino   if (sp)
47fdd4e1e0SJan Lentfer     {
4800d8f3c4SJohn Marino       struct panelhook *ph = NCURSES_SP_NAME(_nc_panelhook) (sp);
4900d8f3c4SJohn Marino 
50fdd4e1e0SJan Lentfer       /* if top and bottom are equal, we have no or only the pseudo panel */
511d102085SJan Lentfer       returnPanel(EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel);
52fdd4e1e0SJan Lentfer     }
53fdd4e1e0SJan Lentfer   else
54fdd4e1e0SJan Lentfer     {
5500d8f3c4SJohn Marino       if (0 == CURRENT_SCREEN)
5600d8f3c4SJohn Marino 	returnPanel(0);
5700d8f3c4SJohn Marino       else
5800d8f3c4SJohn Marino 	returnPanel(ceiling_panel(CURRENT_SCREEN));
59fdd4e1e0SJan Lentfer     }
60fdd4e1e0SJan Lentfer }
6100d8f3c4SJohn Marino #endif
6200d8f3c4SJohn Marino 
6300d8f3c4SJohn Marino NCURSES_EXPORT(PANEL *)
6400d8f3c4SJohn Marino panel_below(const PANEL * pan)
6500d8f3c4SJohn Marino {
6600d8f3c4SJohn Marino   PANEL *result;
6700d8f3c4SJohn Marino 
6800d8f3c4SJohn Marino   T((T_CALLED("panel_below(%p)"), (const void *)pan));
6900d8f3c4SJohn Marino   if (pan)
7000d8f3c4SJohn Marino     {
7100d8f3c4SJohn Marino       GetHook(pan);
7200d8f3c4SJohn Marino       /* we must not return the pseudo panel */
7300d8f3c4SJohn Marino       result = Is_Pseudo(pan->below) ? (PANEL *) 0 : pan->below;
7400d8f3c4SJohn Marino     }
7500d8f3c4SJohn Marino   else
7600d8f3c4SJohn Marino     {
7700d8f3c4SJohn Marino #if NCURSES_SP_FUNCS
7800d8f3c4SJohn Marino       result = ceiling_panel(CURRENT_SCREEN);
7900d8f3c4SJohn Marino #else
8000d8f3c4SJohn Marino       /* if top and bottom are equal, we have no or only the pseudo panel */
8100d8f3c4SJohn Marino       result = EMPTY_STACK()? (PANEL *) 0 : _nc_top_panel;
8200d8f3c4SJohn Marino #endif
8300d8f3c4SJohn Marino     }
8400d8f3c4SJohn Marino   returnPanel(result);
8500d8f3c4SJohn Marino }
86