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