xref: /openbsd-src/lib/libpanel/panel.c (revision 1fc27e414118cd8922c6b93fbaeb7a5246bfd593)
1 /*	$OpenBSD: panel.c,v 1.7 1999/11/28 17:49:19 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1998 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("$From: panel.c,v 1.18 1999/09/29 15:22:32 juergen Exp $")
40 
41 #ifdef TRACE
42 #ifndef TRACE_TXT
43 const char *_nc_my_visbuf(const void *ptr)
44 {
45 	char temp[32];
46 	if (ptr != 0)
47 		snprintf(temp, sizeof(temp), "ptr:%p", ptr);
48 	else
49 		strcpy(temp, "<null>");
50 	return _nc_visbuf(temp);
51 }
52 #endif
53 #endif
54 
55 
56 /*+-------------------------------------------------------------------------
57 	dPanel(text,pan)
58 --------------------------------------------------------------------------*/
59 #ifdef TRACE
60 void
61 _nc_dPanel(const char *text, const PANEL *pan)
62 {
63 	_tracef("%s id=%s b=%s a=%s y=%d x=%d",
64 		text, USER_PTR(pan->user),
65 		(pan->below) ?  USER_PTR(pan->below->user) : "--",
66 		(pan->above) ?  USER_PTR(pan->above->user) : "--",
67 		PSTARTY(pan), PSTARTX(pan));
68 }
69 #endif
70 
71 /*+-------------------------------------------------------------------------
72 	dStack(fmt,num,pan)
73 --------------------------------------------------------------------------*/
74 #ifdef TRACE
75 void
76 _nc_dStack(const char *fmt, int num, const PANEL *pan)
77 {
78   char s80[80];
79 
80   snprintf(s80,sizeof(s80),fmt,num,pan);
81   _tracef("%s b=%s t=%s",s80,
82 	  (_nc_bottom_panel) ?  USER_PTR(_nc_bottom_panel->user) : "--",
83 	  (_nc_top_panel)    ?  USER_PTR(_nc_top_panel->user)    : "--");
84   if(pan)
85     _tracef("pan id=%s", USER_PTR(pan->user));
86   pan = _nc_bottom_panel;
87   while(pan)
88     {
89       dPanel("stk",pan);
90       pan = pan->above;
91     }
92 }
93 #endif
94 
95 /*+-------------------------------------------------------------------------
96 	Wnoutrefresh(pan) - debugging hook for wnoutrefresh
97 --------------------------------------------------------------------------*/
98 #ifdef TRACE
99 void
100 _nc_Wnoutrefresh(const PANEL *pan)
101 {
102   dPanel("wnoutrefresh",pan);
103   wnoutrefresh(pan->win);
104 }
105 #endif
106 
107 /*+-------------------------------------------------------------------------
108 	Touchpan(pan)
109 --------------------------------------------------------------------------*/
110 #ifdef TRACE
111 void
112 _nc_Touchpan(const PANEL *pan)
113 {
114   dPanel("Touchpan",pan);
115   touchwin(pan->win);
116 }
117 #endif
118 
119 /*+-------------------------------------------------------------------------
120 	Touchline(pan,start,count)
121 --------------------------------------------------------------------------*/
122 #ifdef TRACE
123 void
124 _nc_Touchline(const PANEL *pan, int start, int count)
125 {
126   char s80[80];
127   snprintf(s80,sizeof(s80),"Touchline s=%d c=%d",start,count);
128   dPanel(s80,pan);
129   touchline(pan->win,start,count);
130 }
131 #endif
132 
133 #ifndef TRACE
134 #  ifndef __GNUC__
135      /* Some C compilers need something defined in a source file */
136      static char GCC_UNUSED dummy;
137 #  endif
138 #endif
139