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