1 /* 2 * Copyright (c) 1981, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)insch.c 8.2 (Berkeley) 05/04/94"; 10 #endif /* not lint */ 11 12 #include <string.h> 13 14 #include "curses.h" 15 16 /* 17 * winsch -- 18 * Do an insert-char on the line, leaving (cury, curx) unchanged. 19 */ 20 int 21 winsch(win, ch) 22 register WINDOW *win; 23 int ch; 24 { 25 26 register __LDATA *end, *temp1, *temp2; 27 28 end = &win->lines[win->cury]->line[win->curx]; 29 temp1 = &win->lines[win->cury]->line[win->maxx - 1]; 30 temp2 = temp1 - 1; 31 while (temp1 > end) { 32 (void)memcpy(temp1, temp2, sizeof(__LDATA)); 33 temp1--, temp2--; 34 } 35 temp1->ch = ch; 36 temp1->attr &= ~__STANDOUT; 37 __touchline(win, win->cury, win->curx, win->maxx - 1, 0); 38 if (win->cury == LINES - 1 && 39 (win->lines[LINES - 1]->line[COLS - 1].ch != ' ' || 40 win->lines[LINES -1]->line[COLS - 1].attr != 0)) 41 if (win->flags & __SCROLLOK) { 42 wrefresh(win); 43 scroll(win); 44 win->cury--; 45 } else 46 return (ERR); 47 return (OK); 48 } 49