8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libeti / panel / common / new.c
blob25abe73e71c24394ec9d8a2a8b29353287dbba9c
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--create a new panel */
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 /* add_top - Put a new or hidden panel on top of the pile */
43 static void
44 add_top(PANEL *panel)
46 if (!_Top_panel) {
47 panel-> below = 0;
48 _Bottom_panel = panel;
49 } else {
50 _Top_panel -> above = panel;
51 panel -> below = _Top_panel;
54 _Top_panel = panel;
55 panel -> above = 0;
56 panel -> obscured = 0;
57 _Panel_cnt++;
59 /* Determine which panels the new panel obscures */
61 _intersect_panel(panel);
64 /* new_panel */
65 PANEL *
66 new_panel(WINDOW *window)
68 PANEL *panel;
69 int lines, cols;
71 /* create a panel */
73 if (!window || !_alloc_overlap(_Panel_cnt) ||
74 !(panel = (PANEL *) malloc(sizeof (PANEL))))
75 return ((PANEL *) 0);
77 panel -> win = window;
78 getbegyx(window, panel -> wstarty, panel -> wstartx);
79 getmaxyx(window, lines, cols);
80 panel -> wendy = panel->wstarty + lines - 1;
81 panel -> wendx = panel->wstartx + cols - 1;
82 panel -> user = 0;
84 /* put the new panel on top of the pile */
86 add_top(panel);
87 return (panel);
90 /* show_panel */
91 int
92 show_panel(PANEL *panel)
94 /* Allocate the obscured nodes for the new panel */
96 if (!panel || panel != panel -> below || !_alloc_overlap(_Panel_cnt))
97 return (ERR);
99 /* put the new panel on top of the pile */
101 add_top(panel);
102 (void) touchwin(panel -> win);
103 return (OK);