Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2020 Thomas E. Dickey * |
| 3 | * Copyright 1998-2010,2012 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 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 Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 33 | * and: Juergen Pfeifer 1996-1999,2008 * |
| 34 | * and: Thomas E. Dickey * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 35 | ****************************************************************************/ |
| 36 | |
| 37 | /* panel.c -- implementation of panels library, some core routines */ |
| 38 | #include "panel.priv.h" |
| 39 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 40 | MODULE_ID("$Id: panel.c,v 1.30 2020/09/26 18:05:17 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 41 | |
| 42 | /*+------------------------------------------------------------------------- |
| 43 | _nc_retrace_panel (pan) |
| 44 | --------------------------------------------------------------------------*/ |
| 45 | #ifdef TRACE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 46 | PANEL_EXPORT(PANEL *) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | _nc_retrace_panel(PANEL * pan) |
| 48 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 49 | T((T_RETURN("%p"), (void *)pan)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 50 | return pan; |
| 51 | } |
| 52 | #endif |
| 53 | |
| 54 | /*+------------------------------------------------------------------------- |
| 55 | _nc_my_visbuf(ptr) |
| 56 | --------------------------------------------------------------------------*/ |
| 57 | #ifdef TRACE |
| 58 | #ifndef TRACE_TXT |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 59 | PANEL_EXPORT(const char *) |
| 60 | _nc_my_visbuf(const void *ptr, int n) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 61 | { |
| 62 | char temp[32]; |
| 63 | |
| 64 | if (ptr != 0) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 65 | _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp)) "%p", ptr); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 66 | else |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 67 | _nc_STRCPY(temp, "<null>", sizeof(temp)); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 68 | return _nc_visbuf2(n, temp); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | } |
| 70 | #endif |
| 71 | #endif |
| 72 | |
| 73 | /*+------------------------------------------------------------------------- |
| 74 | dPanel(text,pan) |
| 75 | --------------------------------------------------------------------------*/ |
| 76 | #ifdef TRACE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 77 | PANEL_EXPORT(void) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 78 | _nc_dPanel(const char *text, const PANEL * pan) |
| 79 | { |
| 80 | _tracef("%s id=%s b=%s a=%s y=%d x=%d", |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 81 | 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 Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 84 | PSTARTY(pan), PSTARTX(pan)); |
| 85 | } |
| 86 | #endif |
| 87 | |
| 88 | /*+------------------------------------------------------------------------- |
| 89 | dStack(fmt,num,pan) |
| 90 | --------------------------------------------------------------------------*/ |
| 91 | #ifdef TRACE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 92 | PANEL_EXPORT(void) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 93 | _nc_dStack(const char *fmt, int num, const PANEL * pan) |
| 94 | { |
| 95 | char s80[80]; |
| 96 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 97 | GetPanelHook(pan); |
| 98 | |
| 99 | _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) fmt, num, pan); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 100 | _tracef("%s b=%s t=%s", s80, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 101 | (_nc_bottom_panel) ? USER_PTR(_nc_bottom_panel->user, 1) : "--", |
| 102 | (_nc_top_panel) ? USER_PTR(_nc_top_panel->user, 2) : "--"); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 103 | if (pan) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 104 | _tracef("pan id=%s", USER_PTR(pan->user, 1)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 105 | 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 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 118 | PANEL_EXPORT(void) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 119 | _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 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 130 | PANEL_EXPORT(void) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 131 | _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 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 142 | PANEL_EXPORT(void) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 143 | _nc_Touchline(const PANEL * pan, int start, int count) |
| 144 | { |
| 145 | char s80[80]; |
| 146 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 147 | _nc_SPRINTF(s80, _nc_SLIMIT(sizeof(s80)) "Touchline s=%d c=%d", start, count); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 148 | 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 */ |
| 156 | extern void _nc_dummy_panel(void); |
| 157 | void |
| 158 | _nc_dummy_panel(void) |
| 159 | { |
| 160 | } |
| 161 | # endif |
| 162 | #endif |