xref: /openbsd-src/lib/libpanel/p_bottom.c (revision c7ef0cfc17afcba97172c25e1e3a943e893bc632)
1*c7ef0cfcSnicm /* $OpenBSD: p_bottom.c,v 1.7 2023/10/17 09:52:10 nicm Exp $ */
215fe46beSmillert 
3d5238b59Smillert /****************************************************************************
4*c7ef0cfcSnicm  * Copyright 2020,2021 Thomas E. Dickey                                     *
5*c7ef0cfcSnicm  * Copyright 1998-2008,2010 Free Software Foundation, Inc.                  *
615fe46beSmillert  *                                                                          *
7d5238b59Smillert  * Permission is hereby granted, free of charge, to any person obtaining a  *
8d5238b59Smillert  * copy of this software and associated documentation files (the            *
9d5238b59Smillert  * "Software"), to deal in the Software without restriction, including      *
10d5238b59Smillert  * without limitation the rights to use, copy, modify, merge, publish,      *
11d5238b59Smillert  * distribute, distribute with modifications, sublicense, and/or sell       *
12d5238b59Smillert  * copies of the Software, and to permit persons to whom the Software is    *
13d5238b59Smillert  * furnished to do so, subject to the following conditions:                 *
1415fe46beSmillert  *                                                                          *
15d5238b59Smillert  * The above copyright notice and this permission notice shall be included  *
16d5238b59Smillert  * in all copies or substantial portions of the Software.                   *
1715fe46beSmillert  *                                                                          *
18d5238b59Smillert  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19d5238b59Smillert  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20d5238b59Smillert  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21d5238b59Smillert  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22d5238b59Smillert  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23d5238b59Smillert  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24d5238b59Smillert  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2515fe46beSmillert  *                                                                          *
26d5238b59Smillert  * Except as contained in this notice, the name(s) of the above copyright   *
27d5238b59Smillert  * holders shall not be used in advertising or otherwise to promote the     *
28d5238b59Smillert  * sale, use or other dealings in this Software without prior written       *
29d5238b59Smillert  * authorization.                                                           *
30d5238b59Smillert  ****************************************************************************/
31d5238b59Smillert 
32d5238b59Smillert /****************************************************************************
33d5238b59Smillert  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
34d5238b59Smillert  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
35*c7ef0cfcSnicm  *     and: Juergen Pfeifer                         1997-1999,2008          *
36d5238b59Smillert  ****************************************************************************/
3715fe46beSmillert 
3815fe46beSmillert /* p_bottom.c
3915fe46beSmillert  * Place a panel on bottom of the stack; may already be in the stack
4015fe46beSmillert  */
4115fe46beSmillert #include "panel.priv.h"
4215fe46beSmillert 
43*c7ef0cfcSnicm MODULE_ID("$Id: p_bottom.c,v 1.7 2023/10/17 09:52:10 nicm Exp $")
4415fe46beSmillert 
PANEL_EXPORT(int)45*c7ef0cfcSnicm PANEL_EXPORT(int)
4615fe46beSmillert bottom_panel(PANEL * pan)
4715fe46beSmillert {
489ee63291Smillert   int err = OK;
499ee63291Smillert 
50*c7ef0cfcSnicm   T((T_CALLED("bottom_panel(%p)"), (void *)pan));
5181d8c4e1Snicm   if (pan)
5281d8c4e1Snicm     {
53*c7ef0cfcSnicm       GetHook(pan);
5481d8c4e1Snicm       if (!Is_Bottom(pan))
5581d8c4e1Snicm 	{
569ee63291Smillert 
57*c7ef0cfcSnicm 	  dBug(("--> bottom_panel %s", USER_PTR(pan->user, 1)));
589ee63291Smillert 
592f4721ffSmillert 	  HIDE_PANEL(pan, err, OK);
609ee63291Smillert 	  assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
619ee63291Smillert 
629ee63291Smillert 	  dStack("<lb%d>", 1, pan);
639ee63291Smillert 
649ee63291Smillert 	  pan->below = _nc_bottom_panel;
659ee63291Smillert 	  pan->above = _nc_bottom_panel->above;
669ee63291Smillert 	  if (pan->above)
679ee63291Smillert 	    pan->above->below = pan;
689ee63291Smillert 	  _nc_bottom_panel->above = pan;
699ee63291Smillert 
709ee63291Smillert 	  dStack("<lb%d>", 9, pan);
719ee63291Smillert 	}
729ee63291Smillert     }
739ee63291Smillert   else
749ee63291Smillert     err = ERR;
759ee63291Smillert 
7681d8c4e1Snicm   returnCode(err);
7715fe46beSmillert }
78