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]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/types.h>
36 #include "curses_inc.h"
39 * Add ncols worth of data to win, using string as input.
40 * Return the number of chtypes copied.
41 * Note: chtype contains 32/16 bit process code.
44 waddwchnstr(WINDOW
*win
, chtype
*string
, int ncols
)
46 int my_x
= win
->_curx
;
47 int my_y
= win
->_cury
;
50 chtype
*ptr
= &(win
->_y
[my_y
][my_x
]);
56 short my_x1
= win
->_curx
;
59 while (ISCBIT(*ptr
)) {
69 counter
= win
->_maxx
- my_x
;
70 while ((ncols
> 0) && (*string
) && (counter
> 0)) {
71 attr
= *string
& A_WATTRIBUTES
;
72 rawc
= *string
& A_WCHARTEXT
;
74 /* conver wchar_t to mbuti byte string */
75 for (mp
= 0; mp
< sizeof (mbbuf
); mp
++)
77 if (_curs_wctomb(mbbuf
, rawc
) <= 0)
80 /* if there are no cols on screen, end */
81 if ((scrw
= wcscrw(rawc
)) > counter
)
84 if (rawc
& WCHAR_CSMASK
) {
85 /* store multi-byte string into chtype */
86 for (s
= 0, mp
= 0; s
< scrw
; s
++, mp
+= 2) {
87 *ptr
= _CHAR(RBYTE(mbbuf
[mp
]) |
88 RBYTE(mbbuf
[mp
+ 1]) << 8) | CBIT
;
98 /* store single-byte string into chtype */
114 my_maxx
= (short) (ptr
- sptr
+ my_x
);
116 if (my_x1
< win
->_firstch
[my_y
])
117 win
->_firstch
[my_y
] = my_x1
;
119 if (my_maxx
> win
->_lastch
[my_y
])
120 win
->_lastch
[my_y
] = my_maxx
;
122 win
->_flags
|= _WINCHANGED
;
124 /* sync with ancestor structures */
128 return (win
->_immed
? wrefresh(win
) : OK
);