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
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]
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
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
46 #include "curses_inc.h"
49 * Draw a box around a window.
51 * ls : the character and attributes used for the left side.
57 #define _LEFTSIDE variables[0]
58 #define _RIGHTSIDE variables[1]
59 #define _TOPSIDE variables[2]
60 #define _BOTTOMSIDE variables[3]
61 #define _TOPLEFT variables[4]
62 #define _TOPRIGHT variables[5]
63 #define _BOTTOMLEFT variables[6]
64 #define _BOTTOMRIGHT variables[7]
66 static char acs_values
[] = {
71 'l', /* ACS_ULCORNER */
72 'k', /* ACS_URCORNER */
73 'm', /* ACS_LLCORNER */
74 'j' /* ACS_LRCORNER */
78 wborder(WINDOW
*win
, chtype ls
, chtype rs
, chtype ts
,
79 chtype bs
, chtype tl
, chtype tr
, chtype bl
, chtype br
)
81 int i
, endy
= win
->_maxy
- 1, endx
= win
->_maxx
- 2;
82 chtype
**_y
= win
->_y
; /* register version */
83 chtype
*line_ptr
, variables
[8];
96 for (i
= 0; i
< 8; i
++) {
97 if (_CHAR(variables
[i
]) == 0 ||
98 variables
[i
] & 0xFF00)
99 variables
[i
] = acs_map
[acs_values
[i
]];
100 if (ISCBIT(variables
[i
]))
101 variables
[i
] = _CHAR((RBYTE(variables
[i
])<<8) | \
102 (LBYTE(variables
[i
])|MBIT
)) | CBIT
;
103 variables
[i
] &= ~CBIT
;
104 variables
[i
] = _WCHAR(win
, variables
[i
]) | _ATTR(variables
[i
]);
107 /* do top and bottom edges and corners */
110 for (; x
<= xend
; ++x
)
111 if (!ISCBIT(_y
[0][x
]))
113 for (; xend
>= x
; --xend
)
114 if (!ISCBIT(_y
[0][endx
])) {
116 wc
= RBYTE(_y
[0][xend
]);
117 if ((m
= xend
+ _curs_scrwidth
[TYPE(wc
)]) > win
->_maxx
)
125 memSset((line_ptr
= &_y
[0][sx
]), _TOPSIDE
, endx
);
127 *(--line_ptr
) = _TOPLEFT
;
128 if (endx
== win
->_maxx
-2)
129 line_ptr
[++endx
] = _TOPRIGHT
;
133 for (; x
<= xend
; ++x
)
134 if (!ISCBIT(_y
[endy
][x
]))
136 for (; xend
>= x
; --xend
)
137 if (!ISCBIT(_y
[endy
][xend
])) {
139 wc
= RBYTE(_y
[endy
][xend
]);
140 if ((m
= xend
+ _curs_scrwidth
[TYPE(wc
)]) > win
->_maxx
)
149 memSset((line_ptr
= &_y
[endy
][sx
]), _BOTTOMSIDE
, endx
);
151 *--line_ptr
= _BOTTOMLEFT
;
152 if (endx
== win
->_maxx
-2)
153 line_ptr
[++endx
] = _BOTTOMRIGHT
;
155 #ifdef _VR3_COMPAT_CODE
157 (*_y16update
)(win
, 1, ++endx
, 0, 0);
158 (*_y16update
)(win
, 1, endx
--, endy
, 0);
160 #endif /* _VR3_COMPAT_CODE */
162 /* left and right edges */
165 if (!ISCBIT(wc
) && _curs_scrwidth
[TYPE(RBYTE(wc
))] == 1)
166 _y
[endy
][0] = _LEFTSIDE
;
168 if (!ISCBIT(wc
) && _curs_scrwidth
[TYPE(RBYTE(wc
))] == 1)
169 _y
[endy
][endx
] = _RIGHTSIDE
;
171 #ifdef _VR3_COMPAT_CODE
174 win
->_y16
[endy
][0] = _TO_OCHTYPE(_LEFTSIDE
);
176 win
->_y16
[endy
][endx
] = _TO_OCHTYPE(_RIGHTSIDE
);
178 #endif /* _VR3_COMPAT_CODE */
180 return (wtouchln((win
), 0, (win
)->_maxy
, TRUE
));