blob: 1b2d6e8349a0106e1a99a4771694a5e2f2dac703 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002 * Copyright 2020 Thomas E. Dickey *
3 * Copyright 1998-2010,2012 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304 * *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
12 * *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
15 * *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
27 * authorization. *
28 ****************************************************************************/
29
30/****************************************************************************
31 * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 *
32 * and: Eric S. Raymond <esr@snark.thyrsus.com> *
Steve Kondikae271bc2015-11-15 02:50:53 +010033 * and: Juergen Pfeifer 1996-1999,2008 *
34 * and: Thomas E. Dickey *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053035 ****************************************************************************/
36
37/* panel.c -- implementation of panels library, some core routines */
38#include "panel.priv.h"
39
micky3879b9f5e72025-07-08 18:04:53 -040040MODULE_ID("$Id: panel.c,v 1.30 2020/09/26 18:05:17 tom Exp $")
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053041
42/*+-------------------------------------------------------------------------
43 _nc_retrace_panel (pan)
44--------------------------------------------------------------------------*/
45#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -040046PANEL_EXPORT(PANEL *)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047_nc_retrace_panel(PANEL * pan)
48{
Steve Kondikae271bc2015-11-15 02:50:53 +010049 T((T_RETURN("%p"), (void *)pan));
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053050 return pan;
51}
52#endif
53
54/*+-------------------------------------------------------------------------
55 _nc_my_visbuf(ptr)
56--------------------------------------------------------------------------*/
57#ifdef TRACE
58#ifndef TRACE_TXT
micky3879b9f5e72025-07-08 18:04:53 -040059PANEL_EXPORT(const char *)
60_nc_my_visbuf(const void *ptr, int n)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053061{
62 char temp[32];
63
64 if (ptr != 0)
micky3879b9f5e72025-07-08 18:04:53 -040065 _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%p", ptr);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053066 else
Steve Kondikae271bc2015-11-15 02:50:53 +010067 _nc_STRCPY(temp, "<null>", sizeof(temp));
micky3879b9f5e72025-07-08 18:04:53 -040068 return _nc_visbuf2(n, temp);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053069}
70#endif
71#endif
72
73/*+-------------------------------------------------------------------------
74 dPanel(text,pan)
75--------------------------------------------------------------------------*/
76#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -040077PANEL_EXPORT(void)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053078_nc_dPanel(const char *text, const PANEL * pan)
79{
80 _tracef("%s id=%s b=%s a=%s y=%d x=%d",
micky3879b9f5e72025-07-08 18:04:53 -040081 text, USER_PTR(pan->user, 1),
82 (pan->below) ? USER_PTR(pan->below->user, 2) : "--",
83 (pan->above) ? USER_PTR(pan->above->user, 3) : "--",
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053084 PSTARTY(pan), PSTARTX(pan));
85}
86#endif
87
88/*+-------------------------------------------------------------------------
89 dStack(fmt,num,pan)
90--------------------------------------------------------------------------*/
91#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -040092PANEL_EXPORT(void)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053093_nc_dStack(const char *fmt, int num, const PANEL * pan)
94{
95 char s80[80];
96
Steve Kondikae271bc2015-11-15 02:50:53 +010097 GetPanelHook(pan);
98
99 _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) fmt, num, pan);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530100 _tracef("%s b=%s t=%s", s80,
micky3879b9f5e72025-07-08 18:04:53 -0400101 (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user, 1) : "--",
102 (_nc_top_panel) ? USER_PTR(_nc_top_panel->user, 2) : "--");
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530103 if (pan)
micky3879b9f5e72025-07-08 18:04:53 -0400104 _tracef("pan id=%s", USER_PTR(pan->user, 1));
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530105 pan = _nc_bottom_panel;
106 while (pan)
107 {
108 dPanel("stk", pan);
109 pan = pan->above;
110 }
111}
112#endif
113
114/*+-------------------------------------------------------------------------
115 Wnoutrefresh(pan) - debugging hook for wnoutrefresh
116--------------------------------------------------------------------------*/
117#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -0400118PANEL_EXPORT(void)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530119_nc_Wnoutrefresh(const PANEL * pan)
120{
121 dPanel("wnoutrefresh", pan);
122 wnoutrefresh(pan->win);
123}
124#endif
125
126/*+-------------------------------------------------------------------------
127 Touchpan(pan)
128--------------------------------------------------------------------------*/
129#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -0400130PANEL_EXPORT(void)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530131_nc_Touchpan(const PANEL * pan)
132{
133 dPanel("Touchpan", pan);
134 touchwin(pan->win);
135}
136#endif
137
138/*+-------------------------------------------------------------------------
139 Touchline(pan,start,count)
140--------------------------------------------------------------------------*/
141#ifdef TRACE
micky3879b9f5e72025-07-08 18:04:53 -0400142PANEL_EXPORT(void)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530143_nc_Touchline(const PANEL * pan, int start, int count)
144{
145 char s80[80];
146
Steve Kondikae271bc2015-11-15 02:50:53 +0100147 _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) "Touchline s=%d c=%d", start, count);
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530148 dPanel(s80, pan);
149 touchline(pan->win, start, count);
150}
151#endif
152
153#ifndef TRACE
154# ifndef __GNUC__
155 /* Some C compilers need something defined in a source file */
156extern void _nc_dummy_panel(void);
157void
158_nc_dummy_panel(void)
159{
160}
161# endif
162#endif