fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License, Version 1.0 only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * (the "License"). You may not use this file except in compliance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Copyright (c) 1988 AT&T */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* All Rights Reserved */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * University Copyright- Copyright (c) 1982, 1986, 1988
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The Regents of the University of California
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed * All Rights Reserved
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * University Acknowledgment- Portions of this document are derived from
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * software developed by the University of California, Berkeley, and its
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contributors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#pragma ident "%Z%%M% %I% %E% SMI"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed/*LINTLIBRARY*/
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <stdlib.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "curses_inc.h"
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Draw a box around a window.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ls : the character and attributes used for the left side.
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed * rs : right side.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ts : top side.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * bs : bottom side.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed#define _LEFTSIDE variables[0]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _RIGHTSIDE variables[1]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _TOPSIDE variables[2]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _BOTTOMSIDE variables[3]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _TOPLEFT variables[4]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _TOPRIGHT variables[5]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _BOTTOMLEFT variables[6]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define _BOTTOMRIGHT variables[7]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
a7d0884d71898c1977a10cdb2235307e2eb9b20eGary Millsstatic char acs_values[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'x', /* ACS_VLINE */
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe 'x', /* ACS_VLINE */
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe 'q', /* ACS_HLINE */
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe 'q', /* ACS_HLINE */
7014882c6a3672fd0e5d60200af8643ae53c5928Richard Lowe 'l', /* ACS_ULCORNER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'k', /* ACS_URCORNER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'm', /* ACS_LLCORNER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'j' /* ACS_LRCORNER */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortewborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, endy = win->_maxy - 1, endx = win->_maxx - 2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chtype **_y = win->_y; /* register version */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chtype *line_ptr, variables[8];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int x, sx, xend;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte chtype wc;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _LEFTSIDE = ls;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _RIGHTSIDE = rs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _TOPSIDE = ts;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _BOTTOMSIDE = bs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _TOPLEFT = tl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _TOPRIGHT = tr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _BOTTOMLEFT = bl;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _BOTTOMRIGHT = br;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
6e0414acac7fe81ff262fb9d3d83c0700fe9b695Reed for (i = 0; i < 8; i++) {
if (_CHAR(variables[i]) == 0 ||
variables[i] & 0xFF00)
variables[i] = acs_map[acs_values[i]];
if (ISCBIT(variables[i]))
variables[i] = _CHAR((RBYTE(variables[i])<<8) | \
(LBYTE(variables[i])|MBIT)) | CBIT;
variables[i] &= ~CBIT;
variables[i] = _WCHAR(win, variables[i]) | _ATTR(variables[i]);
}
/* do top and bottom edges and corners */
xend = win->_maxx-1;
x = 0;
for (; x <= xend; ++x)
if (!ISCBIT(_y[0][x]))
break;
for (; xend >= x; --xend)
if (!ISCBIT(_y[0][endx])) {
int m;
wc = RBYTE(_y[0][xend]);
if ((m = xend + _curs_scrwidth[TYPE(wc)]) > win->_maxx)
xend -= 1;
else
xend = m - 1;
endx = xend - 1;
break;
}
sx = x == 0 ? 1 : x;
memSset((line_ptr = &_y[0][sx]), _TOPSIDE, endx);
if (x == 0)
*(--line_ptr) = _TOPLEFT;
if (endx == win->_maxx-2)
line_ptr[++endx] = _TOPRIGHT;
xend = win->_maxx-1;
x = 0;
for (; x <= xend; ++x)
if (!ISCBIT(_y[endy][x]))
break;
for (; xend >= x; --xend)
if (!ISCBIT(_y[endy][xend])) {
int m;
wc = RBYTE(_y[endy][xend]);
if ((m = xend + _curs_scrwidth[TYPE(wc)]) > win->_maxx)
xend -= 1;
else
xend = m - 1;
endx = xend - 1;
break;
}
sx = x == 0 ? 1 : x;
memSset((line_ptr = &_y[endy][sx]), _BOTTOMSIDE, endx);
if (x == 0)
*--line_ptr = _BOTTOMLEFT;
if (endx == win->_maxx-2)
line_ptr[++endx] = _BOTTOMRIGHT;
#ifdef _VR3_COMPAT_CODE
if (_y16update) {
(*_y16update)(win, 1, ++endx, 0, 0);
(*_y16update)(win, 1, endx--, endy, 0);
}
#endif /* _VR3_COMPAT_CODE */
/* left and right edges */
while (--endy > 0) {
wc = _y[endy][0];
if (!ISCBIT(wc) && _curs_scrwidth[TYPE(RBYTE(wc))] == 1)
_y[endy][0] = _LEFTSIDE;
wc = _y[endy][endx];
if (!ISCBIT(wc) && _curs_scrwidth[TYPE(RBYTE(wc))] == 1)
_y[endy][endx] = _RIGHTSIDE;
#ifdef _VR3_COMPAT_CODE
if (_y16update) {
/* LINTED */
win->_y16[endy][0] = _TO_OCHTYPE(_LEFTSIDE);
/* LINTED */
win->_y16[endy][endx] = _TO_OCHTYPE(_RIGHTSIDE);
}
#endif /* _VR3_COMPAT_CODE */
}
return (wtouchln((win), 0, (win)->_maxy, TRUE));
}