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 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 /*LINTLIBRARY*/
41
42 #include <sys/types.h>
43 #include "curses_inc.h"
44
45 extern int outchcount;
46
47 /*
48 * These routines short-circuit much of the innards of curses in order to get
49 * a single character output to the screen quickly! It is used by waddch().
50 */
51
52 int
_quick_echo(WINDOW * win,chtype ch)53 _quick_echo(WINDOW *win, chtype ch)
54 {
55 short y = win->_cury;
56 short SPy = y + win->_begy + win->_yoffset;
57 short SPx = (win->_curx - 1) + win->_begx;
58 chtype rawc = _CHAR(ch), rawattrs = _ATTR(ch);
59
60 if ((curscr->_flags & _CANT_BE_IMMED) ||
61 (win->_flags & _WINCHANGED) ||
62 (win->_clear) || (curscr->_clear) ||
63 (_virtscr->_flags & _WINCHANGED) ||
64 (SPy > ((LINES + SP->Yabove) - 1)) || (SPx > (COLS - 1)) ||
65 (SP->slk && (SP->slk->_changed == TRUE))) {
66 win->_flags |= _WINCHANGED;
67 return (wrefresh(win));
68 }
69
70 outchcount = 0;
71 win->_firstch[y] = _INFINITY;
72 win->_lastch[y] = -1;
73 /* If the cursor is not in the right place, put it there! */
74 if ((SPy != curscr->_cury) || (SPx != curscr->_curx)) {
75 (void) mvcur(curscr->_cury, curscr->_curx, SPy, SPx);
76 curscr->_cury = SPy;
77 }
78 curscr->_curx = SPx + 1;
79 _CURHASH[SPy] = _NOHASH;
80 if (ch != ' ') {
81 if (SPx > _ENDNS[SPy])
82 _ENDNS[SPy] = SPx;
83 if (SPx < _BEGNS[SPy])
84 _BEGNS[SPy] = SPx;
85 }
86 _virtscr->_y[SPy][SPx] = curscr->_y[SPy][SPx] = ch;
87
88 if (rawattrs != curscr->_attrs)
89 _VIDS(rawattrs, curscr->_attrs);
90
91 if (SP->phys_irm)
92 _OFFINSERT();
93
94 /* Write it out! */
95 /* LINTED */
96 (void) _outch((char) rawc);
97 (void) fflush(SP->term_file);
98
99 return (outchcount);
100 }
101