1 /* 2 * CDDL HEADER START 3 * 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. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22 /* Copyright (c) 1988 AT&T */ 23 /* All Rights Reserved */ 24 25 26 /* 27 * Copyright (c) 1997, by Sun Microsystems, Inc. 28 * All rights reserved. 29 */ 30 31 /* A panels subsystem built on curses--Delete panel routines */ 32 33 /*LINTLIBRARY*/ 34 35 #include <sys/types.h> 36 #include <stdlib.h> 37 #include <curses.h> 38 #include "private.h" 39 40 /* hide_panel - Unlink a panel from the pile and remove it from the screen. */ 41 int 42 hide_panel(PANEL *panel) 43 { 44 if (!panel) 45 return (ERR); 46 47 /* It is ok to hide a panel that is already hidden. */ 48 49 if (panel == panel -> below) 50 return (OK); 51 52 /* unlink panel */ 53 54 _remove_overlap(panel); 55 if (panel == _Bottom_panel) 56 _Bottom_panel = panel -> above; 57 else 58 panel -> below -> above = panel -> above; 59 60 if (panel == _Top_panel) 61 _Top_panel = panel -> below; 62 else 63 panel -> above -> below = panel -> below; 64 65 _Panel_cnt--; 66 panel -> below = panel; 67 return (OK); 68 } 69 70 /* 71 * del_panel - Delete a panel from the pile 72 * and free all memory associated with it. 73 */ 74 int 75 del_panel(PANEL *panel) 76 { 77 return ((hide_panel(panel) == OK) ? free(panel), OK : ERR); 78 } 79 80 /* 81 * _remove_overlap 82 * Remove all references to a panel from the obscured lists of all panels. 83 * Also remove all obscured nodes from the given panel. This routine 84 * touches the appropriate places to ensure that everybody is properly 85 * updated. 86 */ 87 void 88 _remove_overlap(PANEL *panel) 89 { 90 PANEL *pnl; 91 _obscured_list *obs; 92 _obscured_list *prev_obs; 93 94 /* Make sure that the background gets updated */ 95 96 (void) touchline(stdscr, panel->wstarty, 97 panel->wendy - panel->wstarty + 1); 98 99 /* Remove all references to the panel from the remaining panels */ 100 101 for (pnl = _Bottom_panel; pnl != panel; pnl = pnl->above) { 102 if (obs = _unlink_obs(pnl, panel)) 103 _free_overlap(obs); 104 } 105 106 /* delete the obscured list from the panel */ 107 108 if ((obs = panel -> obscured) != 0) { 109 do { 110 prev_obs = obs; 111 obs = obs -> next; 112 _free_overlap(prev_obs); 113 } 114 while (obs != panel -> obscured); 115 panel -> obscured = 0; 116 } 117 } 118