xref: /csrg-svn/lib/libcurses/insch.c (revision 55964)
122669Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
542653Sbostic  * %sccs.include.redist.c%
622669Sdist  */
722669Sdist 
822669Sdist #ifndef lint
9*55964Sbostic static char sccsid[] = "@(#)insch.c	5.5 (Berkeley) 08/23/92";
10*55964Sbostic #endif	/* not lint */
1122669Sdist 
12*55964Sbostic #include <curses.h>
133532Sarnold 
143532Sarnold /*
15*55964Sbostic  * winsch --
16*55964Sbostic  *	Do an insert-char on the line, leaving (_cury,_curx) unchanged.
173532Sarnold  */
18*55964Sbostic int
19*55964Sbostic winsch(win, ch)
20*55964Sbostic 	register WINDOW *win;
21*55964Sbostic 	int ch;
22*55964Sbostic {
233532Sarnold 
24*55964Sbostic 	register char *end, *temp1, *temp2;
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--;
31*55964Sbostic 	*temp1 = ch;
3219886Sbloom 	touchline(win, win->_cury, win->_curx, win->_maxx - 1);
33*55964Sbostic 	if (win->_cury == LINES - 1 && win->_y[LINES - 1][COLS - 1] != ' ')
343532Sarnold 		if (win->_scroll) {
353532Sarnold 			wrefresh(win);
363532Sarnold 			scroll(win);
373532Sarnold 			win->_cury--;
38*55964Sbostic 		} else
39*55964Sbostic 			return (ERR);
40*55964Sbostic 	return (OK);
413532Sarnold }
42