xref: /openbsd/lib/libpanel/panel.c (revision 771fbea0)
1 /* $OpenBSD: panel.c,v 1.11 2019/10/08 17:52:37 deraadt Exp $ */
2 
3 /****************************************************************************
4  * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
5  *                                                                          *
6  * Permission is hereby granted, free of charge, to any person obtaining a  *
7  * copy of this software and associated documentation files (the            *
8  * "Software"), to deal in the Software without restriction, including      *
9  * without limitation the rights to use, copy, modify, merge, publish,      *
10  * distribute, distribute with modifications, sublicense, and/or sell       *
11  * copies of the Software, and to permit persons to whom the Software is    *
12  * furnished to do so, subject to the following conditions:                 *
13  *                                                                          *
14  * The above copyright notice and this permission notice shall be included  *
15  * in all copies or substantial portions of the Software.                   *
16  *                                                                          *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24  *                                                                          *
25  * Except as contained in this notice, the name(s) of the above copyright   *
26  * holders shall not be used in advertising or otherwise to promote the     *
27  * sale, use or other dealings in this Software without prior written       *
28  * authorization.                                                           *
29  ****************************************************************************/
30 
31 /****************************************************************************
32  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
33  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
34  ****************************************************************************/
35 
36 /* panel.c -- implementation of panels library, some core routines */
37 #include "panel.priv.h"
38 
39 MODULE_ID("$Id: panel.c,v 1.11 2019/10/08 17:52:37 deraadt Exp $")
40 
41 /*+-------------------------------------------------------------------------
42 	_nc_retrace_panel (pan)
43 --------------------------------------------------------------------------*/
44 #ifdef TRACE
45 NCURSES_EXPORT(PANEL *)
46 _nc_retrace_panel(PANEL * pan)
47 {
48   T((T_RETURN("%p"), pan));
49   return pan;
50 }
51 #endif
52 
53 /*+-------------------------------------------------------------------------
54 	_nc_my_visbuf(ptr)
55 --------------------------------------------------------------------------*/
56 #ifdef TRACE
57 #ifndef TRACE_TXT
58 NCURSES_EXPORT(const char *)
59 _nc_my_visbuf(const void *ptr)
60 {
61   char temp[32];
62 
63   if (ptr != 0)
64     snprintf(temp, sizeof temp, "ptr:%p", ptr);
65   else
66     strlcpy(temp, "<null>", sizeof temp);
67   return _nc_visbuf(temp);
68 }
69 #endif
70 #endif
71 
72 /*+-------------------------------------------------------------------------
73 	dPanel(text,pan)
74 --------------------------------------------------------------------------*/
75 #ifdef TRACE
76 NCURSES_EXPORT(void)
77 _nc_dPanel(const char *text, const PANEL * pan)
78 {
79   _tracef("%s id=%s b=%s a=%s y=%d x=%d",
80 	  text, USER_PTR(pan->user),
81 	  (pan->below) ? USER_PTR(pan->below->user) : "--",
82 	  (pan->above) ? USER_PTR(pan->above->user) : "--",
83 	  PSTARTY(pan), PSTARTX(pan));
84 }
85 #endif
86 
87 /*+-------------------------------------------------------------------------
88 	dStack(fmt,num,pan)
89 --------------------------------------------------------------------------*/
90 #ifdef TRACE
91 NCURSES_EXPORT(void)
92 _nc_dStack(const char *fmt, int num, const PANEL * pan)
93 {
94   char s80[80];
95 
96   snprintf(s80, sizeof s80, fmt, num, pan);
97   _tracef("%s b=%s t=%s", s80,
98 	  (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user) : "--",
99 	  (_nc_top_panel) ? USER_PTR(_nc_top_panel->user) : "--");
100   if (pan)
101     _tracef("pan id=%s", USER_PTR(pan->user));
102   pan = _nc_bottom_panel;
103   while (pan)
104     {
105       dPanel("stk", pan);
106       pan = pan->above;
107     }
108 }
109 #endif
110 
111 /*+-------------------------------------------------------------------------
112 	Wnoutrefresh(pan) - debugging hook for wnoutrefresh
113 --------------------------------------------------------------------------*/
114 #ifdef TRACE
115 NCURSES_EXPORT(void)
116 _nc_Wnoutrefresh(const PANEL * pan)
117 {
118   dPanel("wnoutrefresh", pan);
119   wnoutrefresh(pan->win);
120 }
121 #endif
122 
123 /*+-------------------------------------------------------------------------
124 	Touchpan(pan)
125 --------------------------------------------------------------------------*/
126 #ifdef TRACE
127 NCURSES_EXPORT(void)
128 _nc_Touchpan(const PANEL * pan)
129 {
130   dPanel("Touchpan", pan);
131   touchwin(pan->win);
132 }
133 #endif
134 
135 /*+-------------------------------------------------------------------------
136 	Touchline(pan,start,count)
137 --------------------------------------------------------------------------*/
138 #ifdef TRACE
139 NCURSES_EXPORT(void)
140 _nc_Touchline(const PANEL * pan, int start, int count)
141 {
142   char s80[80];
143 
144   snprintf(s80, sizeof s80, "Touchline s=%d c=%d", start, count);
145   dPanel(s80, pan);
146   touchline(pan->win, start, count);
147 }
148 #endif
149 
150 #ifndef TRACE
151 #  ifndef __GNUC__
152      /* Some C compilers need something defined in a source file */
153 extern void _nc_dummy_panel(void);
154 void
155 _nc_dummy_panel(void)
156 {
157 }
158 #  endif
159 #endif
160