1/* $NetBSD: add_wch.c,v 1.2 2007/05/28 15:01:53 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: add_wch.c,v 1.2 2007/05/28 15:01:53 blymn Exp $"); 40#endif /* not lint */ 41 42#include <stdlib.h> 43#include "curses.h" 44#include "curses_private.h" 45#ifdef DEBUG 46#include <assert.h> 47#endif 48 49/* 50 * add_wch -- 51 * Add the wide character to the current position in stdscr. 52 * 53 */ 54int 55add_wch(const cchar_t *wch) 56{ 57#ifndef HAVE_WCHAR 58 return ERR; 59#else 60 return wadd_wch(stdscr, wch); 61#endif /* HAVE_WCHAR */ 62} 63 64 65/* 66 * mvadd_wch -- 67 * Add the wide character to stdscr at the given location. 68 */ 69int 70mvadd_wch(int y, int x, const cchar_t *wch) 71{ 72#ifndef HAVE_WCHAR 73 return ERR; 74#else 75 return mvwadd_wch(stdscr, y, x, wch); 76#endif /* HAVE_WCHAR */ 77} 78 79 80/* 81 * mvwadd_wch -- 82 * Add the character to the given window at the given location. 83 */ 84int 85mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) 86{ 87#ifndef HAVE_WCHAR 88 return ERR; 89#else 90 if (wmove(win, y, x) == ERR) 91 return ERR; 92 93 return wadd_wch(win, wch); 94#endif /* HAVE_WCHAR */ 95} 96 97 98/* 99 * wadd_wch -- 100 * Add the wide character to the current position in the 101 * given window. 102 * 103 */ 104int 105wadd_wch(WINDOW *win, const cchar_t *wch) 106{ 107#ifndef HAVE_WCHAR 108 return ERR; 109#else 110 int x = win->curx, y = win->cury; 111 __LINE *lnp = NULL; 112 113#ifdef DEBUG 114 int i; 115 116 for (i = 0; i < win->maxy; i++) { 117 assert(win->alines[i]->sentinel == SENTINEL_VALUE); 118 } 119 __CTRACE(__CTRACE_INPUT, "wadd_wch: win(%p)", win); 120#endif 121 lnp = win->alines[y]; 122 return _cursesi_addwchar(win, &lnp, &y, &x, wch); 123#endif /* HAVE_WCHAR */ 124} 125