1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
23*0Sstevel@tonic-gate /* All Rights Reserved */
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate * Copyright (c) 1997, by Sun Microsystems, Inc.
28*0Sstevel@tonic-gate * All rights reserved.
29*0Sstevel@tonic-gate */
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate /* A panels subsystem built on curses--Update the pile of panels */
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate /*LINTLIBRARY*/
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate #include <sys/types.h>
38*0Sstevel@tonic-gate #include <stdlib.h>
39*0Sstevel@tonic-gate #include <curses.h>
40*0Sstevel@tonic-gate #include "private.h"
41*0Sstevel@tonic-gate
42*0Sstevel@tonic-gate /*
43*0Sstevel@tonic-gate * touch_top - Touch the line in all windows
44*0Sstevel@tonic-gate * which is visible above a given line
45*0Sstevel@tonic-gate */
46*0Sstevel@tonic-gate static void
touch_top(PANEL * panel,int line,_obscured_list * obs,int start_x,int end_x)47*0Sstevel@tonic-gate touch_top(PANEL *panel, int line, _obscured_list *obs, int start_x, int end_x)
48*0Sstevel@tonic-gate {
49*0Sstevel@tonic-gate PANEL *pnl;
50*0Sstevel@tonic-gate _obscured_list *next_obs;
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate do {
53*0Sstevel@tonic-gate pnl = obs -> panel_p;
54*0Sstevel@tonic-gate if ((next_obs = obs->next) == panel -> obscured -> next)
55*0Sstevel@tonic-gate next_obs = 0;
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate if (line >= obs -> start && line <= obs -> end &&
58*0Sstevel@tonic-gate pnl->wstartx <= end_x && pnl->wendx >= start_x) {
59*0Sstevel@tonic-gate (void) touchline(pnl->win, line - pnl->wstarty, 1);
60*0Sstevel@tonic-gate if (pnl->wstartx > start_x && pnl->wendx < end_x) {
61*0Sstevel@tonic-gate if (next_obs)
62*0Sstevel@tonic-gate touch_top(panel, line, next_obs,
63*0Sstevel@tonic-gate pnl->wendx+1, end_x);
64*0Sstevel@tonic-gate end_x = pnl -> wstartx - 1;
65*0Sstevel@tonic-gate } else {
66*0Sstevel@tonic-gate if (pnl->wstartx <= start_x)
67*0Sstevel@tonic-gate start_x = pnl -> wendx + 1;
68*0Sstevel@tonic-gate if (pnl->wendx >= end_x)
69*0Sstevel@tonic-gate end_x = pnl -> wstartx - 1;
70*0Sstevel@tonic-gate if (start_x > end_x)
71*0Sstevel@tonic-gate return;
72*0Sstevel@tonic-gate }
73*0Sstevel@tonic-gate }
74*0Sstevel@tonic-gate }
75*0Sstevel@tonic-gate while ((obs = next_obs) != 0);
76*0Sstevel@tonic-gate }
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate /*
79*0Sstevel@tonic-gate * std_touch_top
80*0Sstevel@tonic-gate * Touch the line in all windows which is visible above a given line.
81*0Sstevel@tonic-gate * This routine is almost identical to touch_top, except that the "panel"
82*0Sstevel@tonic-gate * is stdscr in this case. The "obscured" list is the list of panels.
83*0Sstevel@tonic-gate */
84*0Sstevel@tonic-gate static void
std_touch_top(int line,PANEL * obs_pnl,int start_x,int end_x)85*0Sstevel@tonic-gate std_touch_top(int line, PANEL *obs_pnl, int start_x, int end_x)
86*0Sstevel@tonic-gate {
87*0Sstevel@tonic-gate PANEL *next_obs;
88*0Sstevel@tonic-gate
89*0Sstevel@tonic-gate do {
90*0Sstevel@tonic-gate next_obs = obs_pnl -> below;
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate if (line >= obs_pnl->wstarty && line <= obs_pnl->wendy &&
93*0Sstevel@tonic-gate obs_pnl->wstartx <= end_x && obs_pnl->wendx >= start_x) {
94*0Sstevel@tonic-gate (void) touchline(obs_pnl->win,
95*0Sstevel@tonic-gate line - obs_pnl->wstarty, 1);
96*0Sstevel@tonic-gate if (obs_pnl->wstartx > start_x &&
97*0Sstevel@tonic-gate obs_pnl->wendx < end_x) {
98*0Sstevel@tonic-gate if (next_obs)
99*0Sstevel@tonic-gate std_touch_top(line, next_obs,
100*0Sstevel@tonic-gate obs_pnl->wendx+1, end_x);
101*0Sstevel@tonic-gate end_x = obs_pnl -> wstartx - 1;
102*0Sstevel@tonic-gate } else {
103*0Sstevel@tonic-gate if (obs_pnl->wstartx <= start_x)
104*0Sstevel@tonic-gate start_x = obs_pnl -> wendx + 1;
105*0Sstevel@tonic-gate if (obs_pnl->wendx >= end_x)
106*0Sstevel@tonic-gate end_x = obs_pnl -> wstartx - 1;
107*0Sstevel@tonic-gate if (start_x > end_x)
108*0Sstevel@tonic-gate return;
109*0Sstevel@tonic-gate }
110*0Sstevel@tonic-gate }
111*0Sstevel@tonic-gate }
112*0Sstevel@tonic-gate while ((obs_pnl = next_obs) != 0);
113*0Sstevel@tonic-gate }
114*0Sstevel@tonic-gate
115*0Sstevel@tonic-gate /* touchup - Touch lines in obscuring panals as necessary */
116*0Sstevel@tonic-gate static void
touchup(PANEL * panel)117*0Sstevel@tonic-gate touchup(PANEL *panel)
118*0Sstevel@tonic-gate {
119*0Sstevel@tonic-gate int screen_y, i;
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate /*
122*0Sstevel@tonic-gate * for each line in the window which has been touched,
123*0Sstevel@tonic-gate * touch lines in panals above it.
124*0Sstevel@tonic-gate */
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gate screen_y = panel->wendy;
127*0Sstevel@tonic-gate
128*0Sstevel@tonic-gate for (i = panel->wendy - panel->wstarty; i >= 0; screen_y--, i--) {
129*0Sstevel@tonic-gate if (is_linetouched(panel -> win, i) == TRUE)
130*0Sstevel@tonic-gate touch_top(panel, screen_y, panel->obscured->next,
131*0Sstevel@tonic-gate panel->wstartx, panel->wendx);
132*0Sstevel@tonic-gate }
133*0Sstevel@tonic-gate }
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate /*
136*0Sstevel@tonic-gate * std_touchup
137*0Sstevel@tonic-gate * Touch lines in obscuring panals as necessary. This routine is
138*0Sstevel@tonic-gate * almost exactly like touchup, except that the "panel" is stdscr,
139*0Sstevel@tonic-gate * and the obscured list is the list of panels.
140*0Sstevel@tonic-gate */
141*0Sstevel@tonic-gate static void
std_touchup(void)142*0Sstevel@tonic-gate std_touchup(void)
143*0Sstevel@tonic-gate {
144*0Sstevel@tonic-gate int screen_y;
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gate /*
147*0Sstevel@tonic-gate * for each line in stdscr which has been touched,
148*0Sstevel@tonic-gate * touch lines in panals above it.
149*0Sstevel@tonic-gate */
150*0Sstevel@tonic-gate
151*0Sstevel@tonic-gate for (screen_y = LINES - 1; screen_y >= 0; screen_y--) {
152*0Sstevel@tonic-gate if (is_linetouched(stdscr, screen_y) == TRUE)
153*0Sstevel@tonic-gate std_touch_top(screen_y, _Top_panel, 0, COLS - 1);
154*0Sstevel@tonic-gate }
155*0Sstevel@tonic-gate }
156*0Sstevel@tonic-gate
157*0Sstevel@tonic-gate /* update_panels - Refresh the pile of panels */
158*0Sstevel@tonic-gate void
update_panels(void)159*0Sstevel@tonic-gate update_panels(void)
160*0Sstevel@tonic-gate {
161*0Sstevel@tonic-gate PANEL *panel;
162*0Sstevel@tonic-gate
163*0Sstevel@tonic-gate /*
164*0Sstevel@tonic-gate * if stdscr has been touched, touch the visible lines
165*0Sstevel@tonic-gate * in each panel.
166*0Sstevel@tonic-gate */
167*0Sstevel@tonic-gate
168*0Sstevel@tonic-gate if (is_wintouched(stdscr)) {
169*0Sstevel@tonic-gate if (_Bottom_panel)
170*0Sstevel@tonic-gate std_touchup();
171*0Sstevel@tonic-gate
172*0Sstevel@tonic-gate (void) wnoutrefresh(stdscr);
173*0Sstevel@tonic-gate }
174*0Sstevel@tonic-gate
175*0Sstevel@tonic-gate /*
176*0Sstevel@tonic-gate * Refresh panals starting at the bottom of the pile.
177*0Sstevel@tonic-gate * If a line in a window has been touched, touch all
178*0Sstevel@tonic-gate * corresponding lines in the obscuring windows.
179*0Sstevel@tonic-gate */
180*0Sstevel@tonic-gate
181*0Sstevel@tonic-gate for (panel = _Bottom_panel; panel; panel = panel -> above) {
182*0Sstevel@tonic-gate if (is_wintouched(panel -> win)) {
183*0Sstevel@tonic-gate if (panel -> obscured)
184*0Sstevel@tonic-gate touchup(panel);
185*0Sstevel@tonic-gate (void) wnoutrefresh(panel -> win);
186*0Sstevel@tonic-gate }
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate }
189