8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libeti / panel / common / delete.c
blobf49d58d94c50cf84e6355ef3432c547599cf9877
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--Delete panel routines */
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"
42 /* hide_panel - Unlink a panel from the pile and remove it from the screen. */
43 int
44 hide_panel(PANEL *panel)
46 if (!panel)
47 return (ERR);
49 /* It is ok to hide a panel that is already hidden. */
51 if (panel == panel -> below)
52 return (OK);
54 /* unlink panel */
56 _remove_overlap(panel);
57 if (panel == _Bottom_panel)
58 _Bottom_panel = panel -> above;
59 else
60 panel -> below -> above = panel -> above;
62 if (panel == _Top_panel)
63 _Top_panel = panel -> below;
64 else
65 panel -> above -> below = panel -> below;
67 _Panel_cnt--;
68 panel -> below = panel;
69 return (OK);
73 * del_panel - Delete a panel from the pile
74 * and free all memory associated with it.
76 int
77 del_panel(PANEL *panel)
79 return ((hide_panel(panel) == OK) ? free(panel), OK : ERR);
83 * _remove_overlap
84 * Remove all references to a panel from the obscured lists of all panels.
85 * Also remove all obscured nodes from the given panel. This routine
86 * touches the appropriate places to ensure that everybody is properly
87 * updated.
89 void
90 _remove_overlap(PANEL *panel)
92 PANEL *pnl;
93 _obscured_list *obs;
94 _obscured_list *prev_obs;
96 /* Make sure that the background gets updated */
98 (void) touchline(stdscr, panel->wstarty,
99 panel->wendy - panel->wstarty + 1);
101 /* Remove all references to the panel from the remaining panels */
103 for (pnl = _Bottom_panel; pnl != panel; pnl = pnl->above) {
104 if (obs = _unlink_obs(pnl, panel))
105 _free_overlap(obs);
108 /* delete the obscured list from the panel */
110 if ((obs = panel -> obscured) != 0) {
111 do {
112 prev_obs = obs;
113 obs = obs -> next;
114 _free_overlap(prev_obs);
116 while (obs != panel -> obscured);
117 panel -> obscured = 0;