xref: /minix3/lib/libcurses/echochar.c (revision 51ffecc181005cb45a40108612ee28d1daaeeb86)
1*51ffecc1SBen Gras /*	$NetBSD: echochar.c,v 1.2 2008/04/29 06:53:01 martin Exp $	*/
2*51ffecc1SBen Gras 
3*51ffecc1SBen Gras /*-
4*51ffecc1SBen Gras  * Copyright (c) 2004 The NetBSD Foundation, Inc.
5*51ffecc1SBen Gras  * All rights reserved.
6*51ffecc1SBen Gras  *
7*51ffecc1SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
8*51ffecc1SBen Gras  * by Julian Coleman.
9*51ffecc1SBen Gras  *
10*51ffecc1SBen Gras  * Redistribution and use in source and binary forms, with or without
11*51ffecc1SBen Gras  * modification, are permitted provided that the following conditions
12*51ffecc1SBen Gras  * are met:
13*51ffecc1SBen Gras  * 1. Redistributions of source code must retain the above copyright
14*51ffecc1SBen Gras  *    notice, this list of conditions and the following disclaimer.
15*51ffecc1SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
16*51ffecc1SBen Gras  *    notice, this list of conditions and the following disclaimer in the
17*51ffecc1SBen Gras  *    documentation and/or other materials provided with the distribution.
18*51ffecc1SBen Gras  *
19*51ffecc1SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20*51ffecc1SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21*51ffecc1SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22*51ffecc1SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23*51ffecc1SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24*51ffecc1SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25*51ffecc1SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26*51ffecc1SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27*51ffecc1SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28*51ffecc1SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29*51ffecc1SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
30*51ffecc1SBen Gras  */
31*51ffecc1SBen Gras 
32*51ffecc1SBen Gras #include <sys/cdefs.h>
33*51ffecc1SBen Gras #ifndef lint
34*51ffecc1SBen Gras __RCSID("$NetBSD: echochar.c,v 1.2 2008/04/29 06:53:01 martin Exp $");
35*51ffecc1SBen Gras #endif				/* not lint */
36*51ffecc1SBen Gras 
37*51ffecc1SBen Gras #include "curses.h"
38*51ffecc1SBen Gras #include "curses_private.h"
39*51ffecc1SBen Gras 
40*51ffecc1SBen Gras #ifndef _CURSES_USE_MACROS
41*51ffecc1SBen Gras /*
42*51ffecc1SBen Gras  * echochar --
43*51ffecc1SBen Gras  *	Echo character and attributes on stdscr and refresh stdscr.
44*51ffecc1SBen Gras  */
45*51ffecc1SBen Gras int
echochar(const chtype ch)46*51ffecc1SBen Gras echochar(const chtype ch)
47*51ffecc1SBen Gras {
48*51ffecc1SBen Gras 
49*51ffecc1SBen Gras 	return wechochar(stdscr, ch);
50*51ffecc1SBen Gras }
51*51ffecc1SBen Gras #endif	/* _CURSES_USE_MACROS */
52*51ffecc1SBen Gras 
53*51ffecc1SBen Gras /*
54*51ffecc1SBen Gras  * echochar --
55*51ffecc1SBen Gras  *	Echo character and attributes on "win" and refresh "win".
56*51ffecc1SBen Gras  */
57*51ffecc1SBen Gras int
wechochar(WINDOW * win,const chtype ch)58*51ffecc1SBen Gras wechochar(WINDOW *win, const chtype ch)
59*51ffecc1SBen Gras {
60*51ffecc1SBen Gras 	int retval;
61*51ffecc1SBen Gras 
62*51ffecc1SBen Gras 	retval = waddch(win, ch);
63*51ffecc1SBen Gras 	if (retval == OK)
64*51ffecc1SBen Gras 		 retval = wrefresh(win);
65*51ffecc1SBen Gras 	return retval;
66*51ffecc1SBen Gras }
67*51ffecc1SBen Gras 
68*51ffecc1SBen Gras /*
69*51ffecc1SBen Gras  * pechochar --
70*51ffecc1SBen Gras  *	Echo character and attributes on "pad" and refresh "pad" at
71*51ffecc1SBen Gras  *	its previous position on the screen.
72*51ffecc1SBen Gras  */
73*51ffecc1SBen Gras int
pechochar(WINDOW * pad,const chtype ch)74*51ffecc1SBen Gras pechochar(WINDOW *pad, const chtype ch)
75*51ffecc1SBen Gras {
76*51ffecc1SBen Gras 	int retval;
77*51ffecc1SBen Gras 
78*51ffecc1SBen Gras 	retval = waddch(pad, ch);
79*51ffecc1SBen Gras 	if (retval == OK)
80*51ffecc1SBen Gras 		 retval = prefresh(pad, pad->pbegy, pad->pbegx,
81*51ffecc1SBen Gras 		    pad->sbegy, pad->sbegx, pad->smaxy, pad->smaxx);
82*51ffecc1SBen Gras 	return retval;
83*51ffecc1SBen Gras }
84