xref: /csrg-svn/lib/libcurses/insch.c (revision 42653)
122669Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
5*42653Sbostic  * %sccs.include.redist.c%
622669Sdist  */
722669Sdist 
822669Sdist #ifndef lint
9*42653Sbostic static char sccsid[] = "@(#)insch.c	5.4 (Berkeley) 06/01/90";
1034677Sbostic #endif /* not lint */
1122669Sdist 
123532Sarnold # include	"curses.ext"
133532Sarnold 
143532Sarnold /*
153532Sarnold  *	This routine performs an insert-char on the line, leaving
163532Sarnold  * (_cury,_curx) unchanged.
173532Sarnold  *
183532Sarnold  */
193532Sarnold winsch(win, c)
203532Sarnold reg WINDOW	*win;
213532Sarnold char		c; {
223532Sarnold 
233532Sarnold 	reg char	*temp1, *temp2;
243532Sarnold 	reg char	*end;
253532Sarnold 
263532Sarnold 	end = &win->_y[win->_cury][win->_curx];
273532Sarnold 	temp1 = &win->_y[win->_cury][win->_maxx - 1];
283532Sarnold 	temp2 = temp1 - 1;
293532Sarnold 	while (temp1 > end)
303532Sarnold 		*temp1-- = *temp2--;
313532Sarnold 	*temp1 = c;
3219886Sbloom 	touchline(win, win->_cury, win->_curx, win->_maxx - 1);
333532Sarnold 	if (win->_cury == LINES - 1 && win->_y[LINES-1][COLS-1] != ' ')
343532Sarnold 		if (win->_scroll) {
353532Sarnold 			wrefresh(win);
363532Sarnold 			scroll(win);
373532Sarnold 			win->_cury--;
383532Sarnold 		}
393539Sarnold 		else
403532Sarnold 			return ERR;
413532Sarnold 	return OK;
423532Sarnold }
43