1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995, by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 /* 28 * wadd_wch.c 29 * 30 * XCurses Library 31 * 32 * Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. 33 * 34 */ 35 36 #ifdef M_RCSID 37 #ifndef lint 38 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/wadd_wch.c 1.5 1995/07/26 17:43:19 ant Exp $"; 39 #endif 40 #endif 41 42 #include <private.h> 43 #include <wctype.h> 44 #include <string.h> 45 46 /*f 47 * Add a character (and attributes) to a window and advance the cursor. 48 * Automatic newline done at right margin, tabs are expanded every 8 49 * columns, backspaces are handled. Newline will clear the rest of the 50 * line; if nl() mode then the cursor is advanced to the start of the 51 * next line. 52 */ 53 int 54 wadd_wch(w, cc) 55 WINDOW *w; 56 const cchar_t *cc; 57 { 58 cchar_t uc; 59 const wchar_t *p; 60 int code, x, y, nx; 61 62 #ifdef M_CURSES_TRACE 63 __m_trace("wadd_wch(%p, %p) at (%d, %d)", w, cc, w->_cury, w->_curx); 64 #endif 65 66 code = ERR; 67 x = w->_curx; 68 y = w->_cury; 69 70 if (x < 0 || w->_maxx <= x || y < 0 || w->_maxy <= y) 71 goto error; 72 73 switch (cc->_wc[0]) { 74 default: 75 if (iswprint(cc->_wc[0])) { 76 case '\t': 77 case '\n': 78 case '\b': 79 case '\r': 80 if (__m_cc_add(w, y, x, cc, 0, &y, &x) == ERR) 81 goto error; 82 break; 83 } 84 85 /* Convert non-printables into printable representation. */ 86 uc._n = 1; 87 uc._at = cc->_at; 88 uc._co = cc->_co; 89 90 if ((p = wunctrl(cc)) == (wchar_t *) 0) 91 goto error; 92 93 for ( ; *p != '\0'; ++p) { 94 uc._wc[0] = *p; 95 if (__m_cc_add(w, y, x, &uc, 0, &y, &x) == ERR) 96 goto error; 97 } 98 break; 99 } 100 101 w->_curx = x; 102 w->_cury = y; 103 104 WSYNC(w); 105 106 code = WFLUSH(w); 107 error: 108 return __m_return_code("wadd_wch", code); 109 } 110 111