4 /****************************************************************/
5 /* Newline() does line advance and returns the new cursor line. */
6 /* If error, return -1. */
7 /****************************************************************/
9 _PROTOTYPE( static short newline
, (WINDOW
*win
, int lin
));
11 static short newline(win
, lin
)
15 if (++lin
> win
->_regbottom
) {
25 /****************************************************************/
26 /* Waddch() inserts character 'c' at the current cursor posi- */
27 /* Tion in window 'win', and takes any actions as dictated by */
29 /****************************************************************/
39 int ts
= win
->_tabsize
;
41 ch
&= (A_ALTCHARSET
| 0xff);
42 if (y
> win
->_maxy
|| x
> win
->_maxx
|| y
< 0 || x
< 0) return(ERR
);
45 for (newx
= ((x
/ ts
) + 1) * ts
; x
< newx
; x
++) {
46 if (waddch(win
, ' ') == ERR
) return(ERR
);
47 if (win
->_curx
== 0) /* if tab to next line */
48 return(OK
); /* exit the loop */
54 if ((y
= newline(win
, y
)) < 0) return (ERR
);
57 case '\r': x
= 0; break;
60 if (--x
< 0) /* no back over left margin */
66 if (waddch(win
, '^') == ERR
) return(ERR
);
67 return(waddch(win
, '?'));
71 if (ch
< ' ') { /* handle control chars */
72 if (waddch(win
, '^') == ERR
) return(ERR
);
73 return(waddch(win
, c
+ '@'));
75 ch
|= (win
->_attrs
& ATR_MSK
);
76 if (win
->_line
[y
][x
] != ch
) { /* only if data change */
77 if (win
->_minchng
[y
] == _NO_CHANGE
)
78 win
->_minchng
[y
] = win
->_maxchng
[y
] = x
;
79 else if (x
< win
->_minchng
[y
])
81 else if (x
> win
->_maxchng
[y
])
84 win
->_line
[y
][x
++] = ch
;
85 if (x
> win
->_maxx
) { /* wrap around test */
87 if ((y
= newline(win
, y
)) < 0) return(ERR
);