1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 1995, by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 /* 28 * winsdel.c 29 * 30 * XCurses Library 31 * 32 * Copyright 1990, 1995 by Mortice Kern Systems. All rights reserved. 33 * 34 */ 35 36 #ifdef M_RCSID 37 #ifndef lint 38 static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/winsdel.c 1.4 1995/06/21 20:31:02 ant Exp $"; 39 #endif 40 #endif 41 42 #include <private.h> 43 #include <stdlib.h> 44 45 /*f 46 * Insert/delete rows from a window. 47 * 48 * Positive N inserts rows and negative N deletes. The size of the 49 * window remains fixed so that rows insert/deleted will cause rows to 50 * disappear/appear at the end of the window. 51 * 52 * NOTE: This routine called in doupdate.c with curscr as window. 53 */ 54 int 55 winsdelln(w, n) 56 WINDOW *w; 57 int n; 58 { 59 int row; 60 61 #ifdef M_CURSES_TRACE 62 __m_trace("winsdelln(%p, %d)", w, n); 63 #endif 64 65 /* Check bounds and limit if necessary. */ 66 if (w->_maxy < w->_cury + abs(n)) 67 n = (w->_maxy - w->_cury + 1) * (n < 0 ? -1 : 1); 68 69 /* Insert/delete accomplished by pointer shuffling. */ 70 if (n < 0) { 71 /* Delete n lines from current cursor line. */ 72 (void) __m_ptr_move( 73 (void **) w->_line, w->_maxy, 74 w->_cury, w->_cury - (n+1), w->_maxy 75 ); 76 77 /* Blank lines come in at the bottom of the screen. */ 78 row = w->_maxy + n; 79 } else { 80 /* Insert n lines before current cursor line. */ 81 (void) __m_ptr_move( 82 (void **) w->_line, w->_maxy, 83 w->_maxy - n, w->_maxy-1, w->_cury 84 ); 85 86 /* Blank lines inserted at the cursor line. */ 87 row = w->_cury; 88 } 89 90 /* Clear inserted/deleted lines. */ 91 (void) __m_cc_erase(w, row, 0, row + abs(n), w->_maxx-1); 92 93 /* Mark from the cursor line to the end of window as dirty. */ 94 (void) wtouchln(w, w->_cury, w->_maxy - w->_cury, 1); 95 96 /* If we insert/delete lines at the top of the screen and we're, 97 * permitted to scroll, then treat the action as a scroll. 98 */ 99 if (w->_scroll && w->_cury == 0 && n != 0 && (w->_flags & W_FULL_WINDOW) 100 && w->_top == 0 && w->_bottom == w->_maxy) 101 w->_scroll += n; 102 else 103 w->_scroll = 0; 104 105 WSYNC(w); 106 107 return __m_return_code("winsdelln", WFLUSH(w)); 108 } 109 110