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>
45 #include "curses_inc.h"
47 /* This routine adds a string starting at (_cury, _curx) */
50 waddnstr(WINDOW
*win
, char *tstr
, int i
)
53 short maxx_1
= win
->_maxx
- 1, cury
= win
->_cury
,
55 chtype
**_y
= win
->_y
;
56 bool savimmed
= win
->_immed
,
60 unsigned char *str
= (unsigned char *)tstr
;
65 fprintf(outf
, "waddnstr(stdscr, ");
67 fprintf(outf
, "waddnstr(%o, ", win
);
68 fprintf(outf
, "\"%s\")\n", str
);
72 /* throw away any current partial character */
74 win
->_insmode
= FALSE
;
77 win
->_immed
= win
->_sync
= FALSE
;
82 while (((ch
= *str
) != 0) && (i
-- > 0)) {
84 if (_scrmax
> 1 && (rv
= _mbvalid(win
)) == ERR
)
89 if (_mbtrue
&& ISMBIT(ch
)) {
92 /* make sure we have the whole character */
95 m
= cswidth
[ty
] - (ty
== 0 ? 1 : 0);
96 for (k
= 1; str
[k
] != '\0' && k
<= m
; ++k
)
103 for (k
= 0; k
<= m
; ++k
, ++str
) {
104 if ((rv
= _mbaddch(win
, A_NORMAL
,
105 RBYTE(*str
))) == ERR
)
116 /* do normal characters while not next to edge */
117 if ((ch
>= ' ') && (ch
!= _CTRL('?')) && (curx
< maxx_1
)) {
118 if (_scrmax
> 1 && ISMBIT(_y
[cury
][curx
]) &&
119 (rv
= _mbclrch(win
, cury
, curx
)) == ERR
)
121 if (curx
< win
->_firstch
[cury
])
122 win
->_firstch
[cury
] = curx
;
123 if (curx
> win
->_lastch
[cury
])
124 win
->_lastch
[cury
] = curx
;
125 ch
= _WCHAR(win
, ch
);
127 #ifdef _VR3_COMPAT_CODE
130 win
->_y16
[cury
][curx
] = _TO_OCHTYPE(ch
);
131 #endif /* _VR3_COMPAT_CODE */
136 /* found a char that is too tough to handle above */
137 if (waddch(win
, ch
) == ERR
) {
151 win
->_flags
|= _WINCHANGED
;
152 win
->_sync
= savsync
;
156 return ((win
->_immed
= savimmed
) ? wrefresh(win
) : rv
);