5525 Update hwdata - 20150111
[illumos-gate.git] / usr / src / lib / libcurses / screen / ripoffline.c
bloba1662a4530b56bdb8286ea68072ea683f90d75bf
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
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
40 #pragma ident "%Z%%M% %I% %E% SMI"
42 /*LINTLIBRARY*/
45 * This routine is used by initialization routines. It sets it up
46 * such that a line is removed from the user's screen by initscr. This
47 * function must be called BEFORE initscr. It works by leaving a cookie
48 * which tells initscr to reduce the size of stdscr by one for each line
49 * ripped off. This routine has been generalized so that other applications
50 * can make use of it in a straightforward manner.
53 #include <sys/types.h>
54 #include "curses_inc.h"
56 static struct _ripdef
58 int line;
59 int (*initfunction)(WINDOW *, int);
60 } _ripstruct[5];
62 static char _ripcounter;
64 static void
65 _init_rip_func(void)
67 int i, flag;
69 for (i = 0; i < _ripcounter; i++) {
70 LINES = --SP->lsize;
72 * We don't need to check for newwin returning NULL because even if
73 * we did and broke from the for loop, the application's initfunction
74 * would not be called and they would have a NULL window pointer. Their
75 * code would then blow up if they don't check it anyway. Therefore,
76 * we can send in the newwin and their code has to check for NULL in either
77 * case.
79 * NOTE: The application has the responsibilty to do a delwin !!!
81 (*_ripstruct[i].initfunction) (newwin(1, COLS,
82 ((flag = _ripstruct[i].line) > 0) ? 0 : LINES, 0), COLS);
83 if (flag > 0)
84 SP->Yabove++;
86 _ripcounter = 0;
89 int
90 ripoffline(int line, int (*initfunction)(WINDOW *, int))
92 if (_ripcounter < 5) {
93 _ripstruct[_ripcounter].line = line;
94 _ripstruct[_ripcounter++].initfunction = initfunction;
96 _rip_init = _init_rip_func;
97 return (OK);