2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
19 sccsid
[] = "@(#)addch.c 1.6 88/02/08 SMI"; /* from UCB 5.1 85/06/07 */
24 /* forward declaration */
25 static void set_ch(WINDOW
*, int, int, int);
28 * This routine adds the character to the current position
32 waddch(WINDOW
*win
, char c
)
40 fprintf(outf
, "ADDCH('%c') at (%d, %d)\n", c
, y
, x
);
44 for (newx
= x
+ (8 - (x
& 07)); x
< newx
; x
++)
45 if (waddch(win
, ' ') == ERR
)
51 fprintf(outf
, "ADDCH: 1: y = %d, x = %d, firstch = %d,"
52 " lastch = %d\n", y
, x
, win
->_firstch
[y
],
55 if (win
->_flags
& _STANDOUT
)
59 if (x
>= win
->_maxx
) {
62 if (++y
>= win
->_maxy
)
71 fprintf(outf
, "ADDCH: 2: y = %d, x = %d, firstch = %d,"
72 " lastch = %d\n", y
, x
, win
->_firstch
[y
],
77 (void) wclrtoeol(win
);
89 win
->_curx
= (short)x
;
90 win
->_cury
= (short)y
;
96 * Set the first and last change flags for this window.
100 set_ch(WINDOW
*win
, int y
, int x
, int ch
)
103 fprintf(outf
, "SET_CH(%0.2o, %d, %d)\n", win
, y
, x
);
105 if (win
->_y
[y
][x
] != ch
) {
107 if (win
->_firstch
[y
] == _NOCHANGE
)
108 win
->_firstch
[y
] = win
->_lastch
[y
] = (short)x
;
109 else if (x
< win
->_firstch
[y
])
110 win
->_firstch
[y
] = (short)x
;
111 else if (x
> win
->_lastch
[y
])
112 win
->_lastch
[y
] = (short)x
;
114 fprintf(outf
, "SET_CH: change gives f/l: %d/%d [%d/%d]\n",
115 win
->_firstch
[y
], win
->_lastch
[y
],
116 win
->_firstch
[y
] - win
->_ch_off
,
117 win
->_lastch
[y
] - win
->_ch_off
);