1*c7ef0cfcSnicm /* $OpenBSD: panel.c,v 1.12 2023/10/17 09:52:10 nicm Exp $ */
25ccab619Stholo
3d5238b59Smillert /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey *
5*c7ef0cfcSnicm * Copyright 1998-2010,2012 Free Software Foundation, Inc. *
65ccab619Stholo * *
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: *
145ccab619Stholo * *
15d5238b59Smillert * The above copyright notice and this permission notice shall be included *
16d5238b59Smillert * in all copies or substantial portions of the Software. *
175ccab619Stholo * *
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. *
255ccab619Stholo * *
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 1996-1999,2008 *
36*c7ef0cfcSnicm * and: Thomas E. Dickey *
37d5238b59Smillert ****************************************************************************/
385ccab619Stholo
3915fe46beSmillert /* panel.c -- implementation of panels library, some core routines */
4086c209c0Smillert #include "panel.priv.h"
4186c209c0Smillert
42*c7ef0cfcSnicm MODULE_ID("$Id: panel.c,v 1.12 2023/10/17 09:52:10 nicm Exp $")
435ccab619Stholo
4481d8c4e1Snicm /*+-------------------------------------------------------------------------
4581d8c4e1Snicm _nc_retrace_panel (pan)
4681d8c4e1Snicm --------------------------------------------------------------------------*/
4781d8c4e1Snicm #ifdef TRACE
PANEL_EXPORT(PANEL *)48*c7ef0cfcSnicm PANEL_EXPORT(PANEL *)
4981d8c4e1Snicm _nc_retrace_panel(PANEL * pan)
5081d8c4e1Snicm {
51*c7ef0cfcSnicm T((T_RETURN("%p"), (void *)pan));
5281d8c4e1Snicm return pan;
5381d8c4e1Snicm }
5481d8c4e1Snicm #endif
5581d8c4e1Snicm
5681d8c4e1Snicm /*+-------------------------------------------------------------------------
5781d8c4e1Snicm _nc_my_visbuf(ptr)
5881d8c4e1Snicm --------------------------------------------------------------------------*/
595ccab619Stholo #ifdef TRACE
6015fe46beSmillert #ifndef TRACE_TXT
61*c7ef0cfcSnicm PANEL_EXPORT(const char *)
_nc_my_visbuf(const void * ptr,int n)62*c7ef0cfcSnicm _nc_my_visbuf(const void *ptr, int n)
6386c209c0Smillert {
6483791aa2Smillert char temp[32];
6581d8c4e1Snicm
6686c209c0Smillert if (ptr != 0)
67*c7ef0cfcSnicm _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%p", ptr);
6886c209c0Smillert else
69*c7ef0cfcSnicm _nc_STRCPY(temp, "<null>", sizeof(temp));
70*c7ef0cfcSnicm return _nc_visbuf2(n, temp);
7186c209c0Smillert }
725ccab619Stholo #endif
7386c209c0Smillert #endif
7486c209c0Smillert
755ccab619Stholo /*+-------------------------------------------------------------------------
765ccab619Stholo dPanel(text,pan)
775ccab619Stholo --------------------------------------------------------------------------*/
7886c209c0Smillert #ifdef TRACE
79*c7ef0cfcSnicm PANEL_EXPORT(void)
_nc_dPanel(const char * text,const PANEL * pan)8081d8c4e1Snicm _nc_dPanel(const char *text, const PANEL * pan)
815ccab619Stholo {
825ccab619Stholo _tracef("%s id=%s b=%s a=%s y=%d x=%d",
83*c7ef0cfcSnicm text, USER_PTR(pan->user, 1),
84*c7ef0cfcSnicm (pan->below) ? USER_PTR(pan->below->user, 2) : "--",
85*c7ef0cfcSnicm (pan->above) ? USER_PTR(pan->above->user, 3) : "--",
869ee63291Smillert PSTARTY(pan), PSTARTX(pan));
8715fe46beSmillert }
885ccab619Stholo #endif
895ccab619Stholo
905ccab619Stholo /*+-------------------------------------------------------------------------
915ccab619Stholo dStack(fmt,num,pan)
925ccab619Stholo --------------------------------------------------------------------------*/
9386c209c0Smillert #ifdef TRACE
94*c7ef0cfcSnicm PANEL_EXPORT(void)
_nc_dStack(const char * fmt,int num,const PANEL * pan)9581d8c4e1Snicm _nc_dStack(const char *fmt, int num, const PANEL * pan)
965ccab619Stholo {
975ccab619Stholo char s80[80];
985ccab619Stholo
99*c7ef0cfcSnicm GetPanelHook(pan);
100*c7ef0cfcSnicm
101*c7ef0cfcSnicm _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) fmt, num, pan);
1025ccab619Stholo _tracef("%s b=%s t=%s", s80,
103*c7ef0cfcSnicm (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user, 1) : "--",
104*c7ef0cfcSnicm (_nc_top_panel) ? USER_PTR(_nc_top_panel->user, 2) : "--");
1055ccab619Stholo if (pan)
106*c7ef0cfcSnicm _tracef("pan id=%s", USER_PTR(pan->user, 1));
10715fe46beSmillert pan = _nc_bottom_panel;
1085ccab619Stholo while (pan)
1095ccab619Stholo {
1105ccab619Stholo dPanel("stk", pan);
1115ccab619Stholo pan = pan->above;
1125ccab619Stholo }
11315fe46beSmillert }
1145ccab619Stholo #endif
1155ccab619Stholo
1165ccab619Stholo /*+-------------------------------------------------------------------------
1175ccab619Stholo Wnoutrefresh(pan) - debugging hook for wnoutrefresh
1185ccab619Stholo --------------------------------------------------------------------------*/
11986c209c0Smillert #ifdef TRACE
120*c7ef0cfcSnicm PANEL_EXPORT(void)
_nc_Wnoutrefresh(const PANEL * pan)12115fe46beSmillert _nc_Wnoutrefresh(const PANEL * pan)
1225ccab619Stholo {
1235ccab619Stholo dPanel("wnoutrefresh", pan);
1245ccab619Stholo wnoutrefresh(pan->win);
12515fe46beSmillert }
1265ccab619Stholo #endif
1275ccab619Stholo
1285ccab619Stholo /*+-------------------------------------------------------------------------
1295ccab619Stholo Touchpan(pan)
1305ccab619Stholo --------------------------------------------------------------------------*/
13186c209c0Smillert #ifdef TRACE
132*c7ef0cfcSnicm PANEL_EXPORT(void)
_nc_Touchpan(const PANEL * pan)13315fe46beSmillert _nc_Touchpan(const PANEL * pan)
1345ccab619Stholo {
1355ccab619Stholo dPanel("Touchpan", pan);
1365ccab619Stholo touchwin(pan->win);
13715fe46beSmillert }
1385ccab619Stholo #endif
1395ccab619Stholo
1405ccab619Stholo /*+-------------------------------------------------------------------------
1415ccab619Stholo Touchline(pan,start,count)
1425ccab619Stholo --------------------------------------------------------------------------*/
14386c209c0Smillert #ifdef TRACE
144*c7ef0cfcSnicm PANEL_EXPORT(void)
_nc_Touchline(const PANEL * pan,int start,int count)14581d8c4e1Snicm _nc_Touchline(const PANEL * pan, int start, int count)
1465ccab619Stholo {
1475ccab619Stholo char s80[80];
14881d8c4e1Snicm
149*c7ef0cfcSnicm _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) "Touchline s=%d c=%d", start, count);
1505ccab619Stholo dPanel(s80, pan);
1515ccab619Stholo touchline(pan->win, start, count);
15215fe46beSmillert }
1535ccab619Stholo #endif
1545ccab619Stholo
1559ee63291Smillert #ifndef TRACE
1569ee63291Smillert # ifndef __GNUC__
1579ee63291Smillert /* Some C compilers need something defined in a source file */
15881d8c4e1Snicm extern void _nc_dummy_panel(void);
15981d8c4e1Snicm void
_nc_dummy_panel(void)16081d8c4e1Snicm _nc_dummy_panel(void)
16181d8c4e1Snicm {
16281d8c4e1Snicm }
1635ccab619Stholo # endif
1649ee63291Smillert #endif
165