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
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.
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]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
42 #include <sys/types.h>
43 #include "curses_inc.h"
46 * This routine prints the character in the current position.
47 * Think of it as putc.
51 waddch(WINDOW
*win
, chtype c
)
55 chtype rawc
= _CHAR(c
);
56 chtype rawattrs
= _ATTR(c
);
58 bool savimmed
= win
->_immed
;
59 bool savsync
= win
->_sync
;
61 win
->_immed
= win
->_sync
= FALSE
;
66 fprintf(outf
, "'%c'", rawc
);
68 fprintf(outf
, "'%c' %o, raw %o", c
, c
, rawc
);
71 win
->_insmode
= FALSE
;
72 if (_scrmax
> 1 && _mbvalid(win
) == ERR
)
74 if (_mbtrue
&& ISMBIT(rawc
)) {
75 rv
= _mbaddch(win
, rawattrs
, RBYTE(rawc
));
76 win
->_immed
= savimmed
;
83 (void) wclrtoeol(win
);
86 goto move_to_begin_line
;
92 win
->_flags
|= _WINMOVED
;
95 if (rawc
< ' ' || rawc
== _CTRL('?')) {
98 chtype space
= ' ' | rawattrs
;
100 if ((newx
= x
+ (TABSIZE
-
101 (x
% TABSIZE
))) > win
->_maxx
) {
104 for (; x
< newx
; x
++) {
105 if (waddch(win
, space
) == ERR
)
109 if ((waddch(win
, (chtype
)
110 '^'|rawattrs
) == ERR
) ||
111 (waddch(win
, (chtype
)
112 _UNCTRL(rawc
)|rawattrs
) == ERR
)) {
119 win
->_immed
= savimmed
;
120 win
->_sync
= savsync
;
124 if ((win
->_attrs
) && outf
)
125 fprintf(outf
, "(attrs %o, %o=>%o)", win
->_attrs
,
129 /* clear any partial multi-column character */
130 if (_scrmax
> 1 && ISMBIT(win
->_y
[y
][x
]) &&
131 (rv
= _mbclrch(win
, y
, x
)) == ERR
) {
134 win
->_immed
= savimmed
;
135 win
->_sync
= savsync
;
139 if ((c
= _WCHAR(win
, c
)|rawattrs
) != win
->_y
[y
][x
]) {
140 if (x
< win
->_firstch
[y
])
141 win
->_firstch
[y
] = x
;
142 if (x
> win
->_lastch
[y
])
145 #ifdef _VR3_COMPAT_CODE
148 win
->_y16
[y
][x
] = _TO_OCHTYPE(c
);
149 #endif /* _VR3_COMPAT_CODE */
151 if (++x
== win
->_maxx
) {
153 if (y
== win
->_bmarg
) {
154 if (wscrl(win
, 1) == ERR
) {
162 fprintf(outf
, "ERR because "
163 "(%d, %d) > (%d, %d)\n",
166 fprintf(outf
, "line: '");
167 for (i
= 0; i
< win
->_maxy
;
171 fprintf(outf
, "'\n");
187 fprintf(outf
, "ADDCH: 2: y = %d, x = %d, "
188 "firstch = %d, lastch = %d\n", y
, x
,
189 win
->_firstch
[y
], win
->_lastch
[y
]);
191 #endif /* FULLDEBUG */
198 /* sync with ancestor structures */
203 return ((*_quick_ptr
)(win
, c
));
205 win
->_flags
|= _WINCHANGED
;
209 return ((savimmed
== 1) ? wrefresh(win
) : rv
);