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 /*LINTLIBRARY*/
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
36*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
37*7c478bd9Sstevel@tonic-gate #include <curses.h>
38*7c478bd9Sstevel@tonic-gate #include "private.h"
39*7c478bd9Sstevel@tonic-gate
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate * touch_top - Touch the line in all windows
42*7c478bd9Sstevel@tonic-gate * which is visible above a given line
43*7c478bd9Sstevel@tonic-gate */
44*7c478bd9Sstevel@tonic-gate static void
touch_top(PANEL * panel,int line,_obscured_list * obs,int start_x,int end_x)45*7c478bd9Sstevel@tonic-gate touch_top(PANEL *panel, int line, _obscured_list *obs, int start_x, int end_x)
46*7c478bd9Sstevel@tonic-gate {
47*7c478bd9Sstevel@tonic-gate PANEL *pnl;
48*7c478bd9Sstevel@tonic-gate _obscured_list *next_obs;
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate do {
51*7c478bd9Sstevel@tonic-gate pnl = obs -> panel_p;
52*7c478bd9Sstevel@tonic-gate if ((next_obs = obs->next) == panel -> obscured -> next)
53*7c478bd9Sstevel@tonic-gate next_obs = 0;
54*7c478bd9Sstevel@tonic-gate
55*7c478bd9Sstevel@tonic-gate if (line >= obs -> start && line <= obs -> end &&
56*7c478bd9Sstevel@tonic-gate pnl->wstartx <= end_x && pnl->wendx >= start_x) {
57*7c478bd9Sstevel@tonic-gate (void) touchline(pnl->win, line - pnl->wstarty, 1);
58*7c478bd9Sstevel@tonic-gate if (pnl->wstartx > start_x && pnl->wendx < end_x) {
59*7c478bd9Sstevel@tonic-gate if (next_obs)
60*7c478bd9Sstevel@tonic-gate touch_top(panel, line, next_obs,
61*7c478bd9Sstevel@tonic-gate pnl->wendx+1, end_x);
62*7c478bd9Sstevel@tonic-gate end_x = pnl -> wstartx - 1;
63*7c478bd9Sstevel@tonic-gate } else {
64*7c478bd9Sstevel@tonic-gate if (pnl->wstartx <= start_x)
65*7c478bd9Sstevel@tonic-gate start_x = pnl -> wendx + 1;
66*7c478bd9Sstevel@tonic-gate if (pnl->wendx >= end_x)
67*7c478bd9Sstevel@tonic-gate end_x = pnl -> wstartx - 1;
68*7c478bd9Sstevel@tonic-gate if (start_x > end_x)
69*7c478bd9Sstevel@tonic-gate return;
70*7c478bd9Sstevel@tonic-gate }
71*7c478bd9Sstevel@tonic-gate }
72*7c478bd9Sstevel@tonic-gate }
73*7c478bd9Sstevel@tonic-gate while ((obs = next_obs) != 0);
74*7c478bd9Sstevel@tonic-gate }
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gate /*
77*7c478bd9Sstevel@tonic-gate * std_touch_top
78*7c478bd9Sstevel@tonic-gate * Touch the line in all windows which is visible above a given line.
79*7c478bd9Sstevel@tonic-gate * This routine is almost identical to touch_top, except that the "panel"
80*7c478bd9Sstevel@tonic-gate * is stdscr in this case. The "obscured" list is the list of panels.
81*7c478bd9Sstevel@tonic-gate */
82*7c478bd9Sstevel@tonic-gate static void
std_touch_top(int line,PANEL * obs_pnl,int start_x,int end_x)83*7c478bd9Sstevel@tonic-gate std_touch_top(int line, PANEL *obs_pnl, int start_x, int end_x)
84*7c478bd9Sstevel@tonic-gate {
85*7c478bd9Sstevel@tonic-gate PANEL *next_obs;
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gate do {
88*7c478bd9Sstevel@tonic-gate next_obs = obs_pnl -> below;
89*7c478bd9Sstevel@tonic-gate
90*7c478bd9Sstevel@tonic-gate if (line >= obs_pnl->wstarty && line <= obs_pnl->wendy &&
91*7c478bd9Sstevel@tonic-gate obs_pnl->wstartx <= end_x && obs_pnl->wendx >= start_x) {
92*7c478bd9Sstevel@tonic-gate (void) touchline(obs_pnl->win,
93*7c478bd9Sstevel@tonic-gate line - obs_pnl->wstarty, 1);
94*7c478bd9Sstevel@tonic-gate if (obs_pnl->wstartx > start_x &&
95*7c478bd9Sstevel@tonic-gate obs_pnl->wendx < end_x) {
96*7c478bd9Sstevel@tonic-gate if (next_obs)
97*7c478bd9Sstevel@tonic-gate std_touch_top(line, next_obs,
98*7c478bd9Sstevel@tonic-gate obs_pnl->wendx+1, end_x);
99*7c478bd9Sstevel@tonic-gate end_x = obs_pnl -> wstartx - 1;
100*7c478bd9Sstevel@tonic-gate } else {
101*7c478bd9Sstevel@tonic-gate if (obs_pnl->wstartx <= start_x)
102*7c478bd9Sstevel@tonic-gate start_x = obs_pnl -> wendx + 1;
103*7c478bd9Sstevel@tonic-gate if (obs_pnl->wendx >= end_x)
104*7c478bd9Sstevel@tonic-gate end_x = obs_pnl -> wstartx - 1;
105*7c478bd9Sstevel@tonic-gate if (start_x > end_x)
106*7c478bd9Sstevel@tonic-gate return;
107*7c478bd9Sstevel@tonic-gate }
108*7c478bd9Sstevel@tonic-gate }
109*7c478bd9Sstevel@tonic-gate }
110*7c478bd9Sstevel@tonic-gate while ((obs_pnl = next_obs) != 0);
111*7c478bd9Sstevel@tonic-gate }
112*7c478bd9Sstevel@tonic-gate
113*7c478bd9Sstevel@tonic-gate /* touchup - Touch lines in obscuring panals as necessary */
114*7c478bd9Sstevel@tonic-gate static void
touchup(PANEL * panel)115*7c478bd9Sstevel@tonic-gate touchup(PANEL *panel)
116*7c478bd9Sstevel@tonic-gate {
117*7c478bd9Sstevel@tonic-gate int screen_y, i;
118*7c478bd9Sstevel@tonic-gate
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate * for each line in the window which has been touched,
121*7c478bd9Sstevel@tonic-gate * touch lines in panals above it.
122*7c478bd9Sstevel@tonic-gate */
123*7c478bd9Sstevel@tonic-gate
124*7c478bd9Sstevel@tonic-gate screen_y = panel->wendy;
125*7c478bd9Sstevel@tonic-gate
126*7c478bd9Sstevel@tonic-gate for (i = panel->wendy - panel->wstarty; i >= 0; screen_y--, i--) {
127*7c478bd9Sstevel@tonic-gate if (is_linetouched(panel -> win, i) == TRUE)
128*7c478bd9Sstevel@tonic-gate touch_top(panel, screen_y, panel->obscured->next,
129*7c478bd9Sstevel@tonic-gate panel->wstartx, panel->wendx);
130*7c478bd9Sstevel@tonic-gate }
131*7c478bd9Sstevel@tonic-gate }
132*7c478bd9Sstevel@tonic-gate
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate * std_touchup
135*7c478bd9Sstevel@tonic-gate * Touch lines in obscuring panals as necessary. This routine is
136*7c478bd9Sstevel@tonic-gate * almost exactly like touchup, except that the "panel" is stdscr,
137*7c478bd9Sstevel@tonic-gate * and the obscured list is the list of panels.
138*7c478bd9Sstevel@tonic-gate */
139*7c478bd9Sstevel@tonic-gate static void
std_touchup(void)140*7c478bd9Sstevel@tonic-gate std_touchup(void)
141*7c478bd9Sstevel@tonic-gate {
142*7c478bd9Sstevel@tonic-gate int screen_y;
143*7c478bd9Sstevel@tonic-gate
144*7c478bd9Sstevel@tonic-gate /*
145*7c478bd9Sstevel@tonic-gate * for each line in stdscr which has been touched,
146*7c478bd9Sstevel@tonic-gate * touch lines in panals above it.
147*7c478bd9Sstevel@tonic-gate */
148*7c478bd9Sstevel@tonic-gate
149*7c478bd9Sstevel@tonic-gate for (screen_y = LINES - 1; screen_y >= 0; screen_y--) {
150*7c478bd9Sstevel@tonic-gate if (is_linetouched(stdscr, screen_y) == TRUE)
151*7c478bd9Sstevel@tonic-gate std_touch_top(screen_y, _Top_panel, 0, COLS - 1);
152*7c478bd9Sstevel@tonic-gate }
153*7c478bd9Sstevel@tonic-gate }
154*7c478bd9Sstevel@tonic-gate
155*7c478bd9Sstevel@tonic-gate /* update_panels - Refresh the pile of panels */
156*7c478bd9Sstevel@tonic-gate void
update_panels(void)157*7c478bd9Sstevel@tonic-gate update_panels(void)
158*7c478bd9Sstevel@tonic-gate {
159*7c478bd9Sstevel@tonic-gate PANEL *panel;
160*7c478bd9Sstevel@tonic-gate
161*7c478bd9Sstevel@tonic-gate /*
162*7c478bd9Sstevel@tonic-gate * if stdscr has been touched, touch the visible lines
163*7c478bd9Sstevel@tonic-gate * in each panel.
164*7c478bd9Sstevel@tonic-gate */
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gate if (is_wintouched(stdscr)) {
167*7c478bd9Sstevel@tonic-gate if (_Bottom_panel)
168*7c478bd9Sstevel@tonic-gate std_touchup();
169*7c478bd9Sstevel@tonic-gate
170*7c478bd9Sstevel@tonic-gate (void) wnoutrefresh(stdscr);
171*7c478bd9Sstevel@tonic-gate }
172*7c478bd9Sstevel@tonic-gate
173*7c478bd9Sstevel@tonic-gate /*
174*7c478bd9Sstevel@tonic-gate * Refresh panals starting at the bottom of the pile.
175*7c478bd9Sstevel@tonic-gate * If a line in a window has been touched, touch all
176*7c478bd9Sstevel@tonic-gate * corresponding lines in the obscuring windows.
177*7c478bd9Sstevel@tonic-gate */
178*7c478bd9Sstevel@tonic-gate
179*7c478bd9Sstevel@tonic-gate for (panel = _Bottom_panel; panel; panel = panel -> above) {
180*7c478bd9Sstevel@tonic-gate if (is_wintouched(panel -> win)) {
181*7c478bd9Sstevel@tonic-gate if (panel -> obscured)
182*7c478bd9Sstevel@tonic-gate touchup(panel);
183*7c478bd9Sstevel@tonic-gate (void) wnoutrefresh(panel -> win);
184*7c478bd9Sstevel@tonic-gate }
185*7c478bd9Sstevel@tonic-gate }
186*7c478bd9Sstevel@tonic-gate }
187