xref: /minix3/lib/libcurses/echo_wchar.c (revision 51ffecc181005cb45a40108612ee28d1daaeeb86)
1 /*   $NetBSD: echo_wchar.c,v 1.2 2007/05/28 15:01:55 blymn Exp $ */
2 
3 /*
4  * Copyright (c) 2005 The NetBSD Foundation Inc.
5  * All rights reserved.
6  *
7  * This code is derived from code donated to the NetBSD Foundation
8  * by Ruibiao Qiu <ruibiao@arl.wustl.edu,ruibiao@gmail.com>.
9  *
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *	notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *	notice, this list of conditions and the following disclaimer in the
18  *	documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the NetBSD Foundation nor the names of its
20  *	contributors may be used to endorse or promote products derived
21  *	from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
24  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
25  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGE.
35  */
36 
37 #include <sys/cdefs.h>
38 #ifndef lint
39 __RCSID("$NetBSD: echo_wchar.c,v 1.2 2007/05/28 15:01:55 blymn Exp $");
40 #endif						  /* not lint */
41 
42 #include "curses.h"
43 #include "curses_private.h"
44 
45 /*
46  * echo_wchar --
47  *	Echo wide character and attributes on stdscr and refresh stdscr.
48  */
49 int
echo_wchar(const cchar_t * wch)50 echo_wchar(const cchar_t *wch)
51 {
52 #ifndef HAVE_WCHAR
53 	return ERR;
54 #else
55 	return wecho_wchar(stdscr, wch);
56 #endif /* HAVE_WCHAR */
57 }
58 
59 /*
60  * echo_wchar --
61  *	Echo wide character and attributes on "win" and refresh "win".
62  */
63 int
wecho_wchar(WINDOW * win,const cchar_t * wch)64 wecho_wchar(WINDOW *win, const cchar_t *wch)
65 {
66 #ifndef HAVE_WCHAR
67 	return ERR;
68 #else
69 	int retval;
70 
71 	retval = wadd_wch(win, wch);
72 	if (retval == OK)
73 		 retval = wrefresh(win);
74 	return retval;
75 #endif /* HAVE_WCHAR */
76 }
77 
78 /*
79  * pecho_wchar --
80  *	Echo character and attributes on "pad" and refresh "pad" at
81  *	its previous position on the screen.
82  */
83 int
pecho_wchar(WINDOW * pad,const cchar_t * wch)84 pecho_wchar(WINDOW *pad, const cchar_t *wch)
85 {
86 #ifndef HAVE_WCHAR
87 	return ERR;
88 #else
89 	int retval;
90 
91 	retval = wadd_wch(pad, wch);
92 	if (retval == OK)
93 		 retval = prefresh(pad, pad->pbegy, pad->pbegx,
94 			pad->sbegy, pad->sbegx, pad->smaxy, pad->smaxx);
95 	return retval;
96 #endif /* HAVE_WCHAR */
97 }
98