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
40 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <sys/types.h>
45 #include "curses_inc.h"
48 * This routine prints the character in the current position.
49 * Think of it as putc.
53 waddch(WINDOW
*win
, chtype c
)
57 chtype rawc
= _CHAR(c
);
58 chtype rawattrs
= _ATTR(c
);
60 bool savimmed
= win
->_immed
;
61 bool savsync
= win
->_sync
;
63 win
->_immed
= win
->_sync
= FALSE
;
68 fprintf(outf
, "'%c'", rawc
);
70 fprintf(outf
, "'%c' %o, raw %o", c
, c
, rawc
);
73 win
->_insmode
= FALSE
;
74 if (_scrmax
> 1 && _mbvalid(win
) == ERR
)
76 if (_mbtrue
&& ISMBIT(rawc
)) {
77 rv
= _mbaddch(win
, rawattrs
, RBYTE(rawc
));
78 win
->_immed
= savimmed
;
85 (void) wclrtoeol(win
);
88 goto move_to_begin_line
;
94 win
->_flags
|= _WINMOVED
;
97 if (rawc
< ' ' || rawc
== _CTRL('?')) {
100 chtype space
= ' ' | rawattrs
;
102 if ((newx
= x
+ (TABSIZE
-
103 (x
% TABSIZE
))) > win
->_maxx
)
105 for (; x
< newx
; x
++)
110 if ((waddch(win
, (chtype
)
111 '^'|rawattrs
) == ERR
) ||
112 (waddch(win
, (chtype
)
113 _UNCTRL(rawc
)|rawattrs
) == ERR
)) {
120 win
->_immed
= savimmed
;
121 win
->_sync
= savsync
;
125 if ((win
->_attrs
) && outf
)
126 fprintf(outf
, "(attrs %o, %o=>%o)", win
->_attrs
,
130 /* clear any partial multi-column character */
131 if (_scrmax
> 1 && ISMBIT(win
->_y
[y
][x
]) &&
132 (rv
= _mbclrch(win
, y
, x
)) == ERR
) {
135 win
->_immed
= savimmed
;
136 win
->_sync
= savsync
;
140 if ((c
= _WCHAR(win
, c
)|rawattrs
) != win
->_y
[y
][x
]) {
141 if (x
< win
->_firstch
[y
])
142 win
->_firstch
[y
] = x
;
143 if (x
> win
->_lastch
[y
])
146 #ifdef _VR3_COMPAT_CODE
149 win
->_y16
[y
][x
] = _TO_OCHTYPE(c
);
150 #endif /* _VR3_COMPAT_CODE */
152 if (++x
== win
->_maxx
) {
154 if (y
== win
->_bmarg
) {
155 if (wscrl(win
, 1) == ERR
) {
163 fprintf(outf
, "ERR because "
164 "(%d, %d) > (%d, %d)\n",
167 fprintf(outf
, "line: '");
168 for (i
= 0; i
< win
->_maxy
;
172 fprintf(outf
, "'\n");
185 fprintf(outf
, "ADDCH: 2: y = %d, x = %d, "
186 "firstch = %d, lastch = %d\n", y
, x
,
187 win
->_firstch
[y
], win
->_lastch
[y
]);
188 #endif /* FULLDEBUG */
195 /* sync with ancestor structures */
200 return ((*_quick_ptr
)(win
, c
));
202 win
->_flags
|= _WINCHANGED
;
206 return ((savimmed
== 1) ? wrefresh(win
) : rv
);