122669Sdist /*
2*67082Sbostic * Copyright (c) 1981, 1993, 1994
361270Sbostic * The Regents of the University of California. All rights reserved.
434677Sbostic *
542653Sbostic * %sccs.include.redist.c%
622669Sdist */
722669Sdist
822669Sdist #ifndef lint
9*67082Sbostic static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 05/04/94";
1055964Sbostic #endif /* not lint */
1122669Sdist
1258047Selan #include <string.h>
133532Sarnold
14*67082Sbostic #include "curses.h"
15*67082Sbostic
163532Sarnold /*
1755964Sbostic * winsch --
1856647Selan * Do an insert-char on the line, leaving (cury, curx) unchanged.
193532Sarnold */
2055964Sbostic int
winsch(win,ch)2155964Sbostic winsch(win, ch)
2255964Sbostic register WINDOW *win;
2355964Sbostic int ch;
2455964Sbostic {
253532Sarnold
2656647Selan register __LDATA *end, *temp1, *temp2;
273532Sarnold
2856238Selan end = &win->lines[win->cury]->line[win->curx];
2956238Selan temp1 = &win->lines[win->cury]->line[win->maxx - 1];
303532Sarnold temp2 = temp1 - 1;
3156596Selan while (temp1 > end) {
3258041Selan (void)memcpy(temp1, temp2, sizeof(__LDATA));
3356596Selan temp1--, temp2--;
3456596Selan }
3556647Selan temp1->ch = ch;
3656647Selan temp1->attr &= ~__STANDOUT;
3756650Selan __touchline(win, win->cury, win->curx, win->maxx - 1, 0);
3856238Selan if (win->cury == LINES - 1 &&
3956647Selan (win->lines[LINES - 1]->line[COLS - 1].ch != ' ' ||
4056647Selan win->lines[LINES -1]->line[COLS - 1].attr != 0))
4156238Selan if (win->flags & __SCROLLOK) {
423532Sarnold wrefresh(win);
433532Sarnold scroll(win);
4456238Selan win->cury--;
4555964Sbostic } else
4657472Sbostic return (ERR);
4757472Sbostic return (OK);
483532Sarnold }
49