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