xref: /freebsd-src/contrib/ncurses/panel/p_show.c (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
10e3d5408SPeter Wemm /****************************************************************************
2*21817992SBaptiste Daroussin  * Copyright 2020,2021 Thomas E. Dickey                                     *
3e1865124SBaptiste Daroussin  * Copyright 1998-2009,2010 Free Software Foundation, Inc.                  *
40e3d5408SPeter Wemm  *                                                                          *
50e3d5408SPeter Wemm  * Permission is hereby granted, free of charge, to any person obtaining a  *
60e3d5408SPeter Wemm  * copy of this software and associated documentation files (the            *
70e3d5408SPeter Wemm  * "Software"), to deal in the Software without restriction, including      *
80e3d5408SPeter Wemm  * without limitation the rights to use, copy, modify, merge, publish,      *
90e3d5408SPeter Wemm  * distribute, distribute with modifications, sublicense, and/or sell       *
100e3d5408SPeter Wemm  * copies of the Software, and to permit persons to whom the Software is    *
110e3d5408SPeter Wemm  * furnished to do so, subject to the following conditions:                 *
120e3d5408SPeter Wemm  *                                                                          *
130e3d5408SPeter Wemm  * The above copyright notice and this permission notice shall be included  *
140e3d5408SPeter Wemm  * in all copies or substantial portions of the Software.                   *
150e3d5408SPeter Wemm  *                                                                          *
160e3d5408SPeter Wemm  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
170e3d5408SPeter Wemm  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
180e3d5408SPeter Wemm  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
190e3d5408SPeter Wemm  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
200e3d5408SPeter Wemm  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
210e3d5408SPeter Wemm  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
220e3d5408SPeter Wemm  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
230e3d5408SPeter Wemm  *                                                                          *
240e3d5408SPeter Wemm  * Except as contained in this notice, the name(s) of the above copyright   *
250e3d5408SPeter Wemm  * holders shall not be used in advertising or otherwise to promote the     *
260e3d5408SPeter Wemm  * sale, use or other dealings in this Software without prior written       *
270e3d5408SPeter Wemm  * authorization.                                                           *
280e3d5408SPeter Wemm  ****************************************************************************/
290e3d5408SPeter Wemm 
300e3d5408SPeter Wemm /****************************************************************************
310e3d5408SPeter Wemm  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
320e3d5408SPeter Wemm  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
330e3d5408SPeter Wemm  ****************************************************************************/
340e3d5408SPeter Wemm 
350e3d5408SPeter Wemm /* p_show.c
360e3d5408SPeter Wemm  * Place a panel on top of the stack; may already be in the stack
370e3d5408SPeter Wemm  */
380e3d5408SPeter Wemm #include "panel.priv.h"
390e3d5408SPeter Wemm 
40*21817992SBaptiste Daroussin MODULE_ID("$Id: p_show.c,v 1.17 2021/06/17 21:20:30 tom Exp $")
410e3d5408SPeter Wemm 
PANEL_EXPORT(int)427a656419SBaptiste Daroussin PANEL_EXPORT(int)
430e3d5408SPeter Wemm show_panel(PANEL * pan)
440e3d5408SPeter Wemm {
4506bfebdeSXin LI   int err = ERR;
4615589c42SPeter Wemm 
4706bfebdeSXin LI   T((T_CALLED("show_panel(%p)"), (void *)pan));
484a1a9510SRong-En Fan 
4906bfebdeSXin LI   if (pan)
5006bfebdeSXin LI     {
5106bfebdeSXin LI       GetHook(pan);
521759abf3SPeter Wemm 
531759abf3SPeter Wemm       if (Is_Top(pan))
544a1a9510SRong-En Fan 	returnCode(OK);
551759abf3SPeter Wemm 
567a656419SBaptiste Daroussin       dBug(("--> show_panel %s", USER_PTR(pan->user, 1)));
571759abf3SPeter Wemm 
587a69bbfbSPeter Wemm       HIDE_PANEL(pan, err, OK);
591759abf3SPeter Wemm 
6015589c42SPeter Wemm       dStack("<lt%d>", 1, pan);
6115589c42SPeter Wemm       assert(_nc_bottom_panel == _nc_stdscr_pseudo_panel);
6215589c42SPeter Wemm 
6315589c42SPeter Wemm       _nc_top_panel->above = pan;
6415589c42SPeter Wemm       pan->below = _nc_top_panel;
6515589c42SPeter Wemm       pan->above = (PANEL *) 0;
6615589c42SPeter Wemm       _nc_top_panel = pan;
6715589c42SPeter Wemm 
6806bfebdeSXin LI       err = OK;
691759abf3SPeter Wemm 
7006bfebdeSXin LI       dStack("<lt%d>", 9, pan);
7106bfebdeSXin LI     }
7206bfebdeSXin LI   returnCode(err);
730e3d5408SPeter Wemm }
74