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 /* Insert a character at (curx, cury). */
51 winsch(WINDOW
*win
, chtype c
)
53 short curx
= win
->_curx
;
54 int n
, cury
= win
->_cury
;
63 if (_scrmax
> 1 && (rv
= _mbvalid(win
)) == ERR
)
65 /* take care of multi-byte characters */
66 if (_mbtrue
&& ISMBIT(c
)) {
67 rv
= _mbaddch(win
, A_NORMAL
, RBYTE(c
));
73 /* let waddch() worry about these */
74 if (c
== '\r' || c
== '\b')
75 return (waddch(win
, c
));
77 /* with \n, in contrast to waddch, we don't clear-to-eol */
79 if (cury
>= (win
->_maxy
-1) || cury
== win
->_bmarg
)
80 return (wscrl(win
, 1));
88 /* with tabs or control characters, we have to do more */
90 n
= (TABSIZE
- (curx
% TABSIZE
));
91 if ((curx
+ n
) >= win
->_maxx
)
92 n
= win
->_maxx
- curx
;
95 if (iscntrl((int) c
) != 0) {
96 if (curx
>= win
->_maxx
-1)
104 wcp
= win
->_y
[cury
] + curx
;
105 if ((rv
= _mbinsshift(win
, n
)) == ERR
)
108 /* insert new control character */
109 if (c
< ' ' || c
== _CTRL('?')) {
110 *wcp
++ = '^' | win
->_attrs
| a
;
111 *wcp
= _UNCTRL(c
) | win
->_attrs
| a
;
113 /* normal characters */
114 c
= _WCHAR(win
, c
) | a
;
120 if (curx
< win
->_firstch
[cury
])
121 win
->_firstch
[cury
] = curx
;
122 win
->_lastch
[cury
] = win
->_maxx
-1;
124 win
->_flags
|= _WINCHANGED
;
129 return ((rv
== OK
&& win
->_immed
) ? wrefresh(win
) : rv
);