1 /****************************************************************************
2 * Copyright (c) 2004,2006 Free Software Foundation, Inc. *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
27 ****************************************************************************/
32 ** The routine wadd_wch().
36 #include <curses.priv.h>
38 MODULE_ID("$Id: lib_add_wch.c,v 1.6 2006/12/02 21:19:17 tom Exp $")
41 wadd_wch(WINDOW *win, const cchar_t *wch)
47 TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wadd_wch(%p, %s)"), win,
52 for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
53 attr_t attrs = (wch->attr & A_ATTRIBUTES);
55 if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0')
57 if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
60 code = waddch(win, UChar(PUTC_ch) | attrs);
63 for (n = 0; n < PUTC_n; n++) {
64 if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) {
73 TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));
78 wecho_wchar(WINDOW *win, const cchar_t *wch)
84 TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_CALLED("wecho_wchar(%p, %s)"), win,
89 for (PUTC_i = 0; PUTC_i < CCHARW_MAX; ++PUTC_i) {
90 attr_t attrs = (wch->attr & A_ATTRIBUTES);
92 if ((PUTC_ch = wch->chars[PUTC_i]) == L'\0')
94 if ((PUTC_n = wcrtomb(PUTC_buf, PUTC_ch, &PUT_st)) <= 0) {
97 code = waddch(win, UChar(PUTC_ch) | attrs);
100 for (n = 0; n < PUTC_n; n++) {
101 if ((code = waddch(win, UChar(PUTC_buf[n]) | attrs)) == ERR) {
111 TR(TRACE_VIRTPUT | TRACE_CCALLS, (T_RETURN("%d"), code));