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