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