From 1f36118a96fb5605609e5dd04dade38629b53386 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Tue, 29 Nov 1994 02:48:20 +0000 Subject: wscrl: implement partial scrolling via al/dl winsdel: implemented via wscrl winsertln/deleteln: implemented as macros via winsdel --- lib/libncurses/lib_insdel.c | 98 ++++++--------------------------------------- 1 file changed, 13 insertions(+), 85 deletions(-) (limited to 'lib/libncurses/lib_insdel.c') diff --git a/lib/libncurses/lib_insdel.c b/lib/libncurses/lib_insdel.c index 879631fefb11..9eb130bac270 100644 --- a/lib/libncurses/lib_insdel.c +++ b/lib/libncurses/lib_insdel.c @@ -19,11 +19,7 @@ int winsdel(WINDOW *win, int n) { -int line, i; -int touched = 0; -chtype *ptr, *temp; -chtype **saved; -chtype blank = ' '; + int ret, sscroll, stop, sbot; T(("winsdel(%x,%d) called", win, n)); @@ -34,88 +30,20 @@ chtype blank = ' '; /* should we truncate to an appropriate number? */ return ERR; + sscroll = win->_scroll; + stop = win->_regtop; + sbot = win->_regbottom; - saved = (chtype **)malloc(sizeof(chtype *) * abs(n)); + win->_scroll = TRUE; + win->_regtop = win->_cury; + if (win->_regtop > win->_regbottom) + win->_regbottom = win->_maxy; - if (n < 0) { - /* save overwritten lines */ - - for (i = 0; i < -n; i++) - saved[i] = win->_line[win->_regbottom-i]; + ret = wscrl(win, -n); - /* delete n lines */ - - for (line = win->_regbottom; line >= win->_cury; line--) - win->_line[line] = win->_line[line+n]; + win->_scroll = sscroll; + win->_regtop = stop; + win->_regbottom = sbot; - /* restore saved lines and blank them */ - - for (i = 0, line = win->_regtop; line < win->_regtop-n; line++, i++) { - win->_line[line] = saved[i]; - temp = win->_line[line]; - for (ptr = temp; ptr - temp <= win->_maxx; ptr++) - *ptr = blank; - } - } - - if (n > 0) { - /* save overwritten lines */ - - for (i = 0; i < n; i++) - saved[i] = win->_line[win->_regtop+i]; - - /* insert n lines */ - - for (line = win->_regtop; line < win->_regtop + n; line++) - win->_line[line] = win->_line[line+n]; - - /* restore saved lines and blank them */ - - for (i = 0, line = win->_regtop + n; i < n; line--, i++) { - temp = win->_line[line] = saved[i]; - for (ptr = temp; ptr - temp <= win->_maxx; ptr++) - *ptr = blank; - } - } - - free(saved); - - /* as an optimization, if the window is COLS wide we can try - using idl assuming _idlok is true */ - - if (win->_maxx == columns && win->_idlok == TRUE) { - - wrefresh(win); - if (n > 0) { - mvcur(-1, -1, win->_cury, 0); - if (parm_insert_line) { - putp(tparm(parm_insert_line, n)); - touched = 1; - } else if (insert_line) { - while (n--) - putp(insert_line); - touched = 1; - } - } - - if (n < 0) { - mvcur(-1, -1, win->_cury, 0); - n = abs(n); - if (parm_delete_line) { - putp(tparm(parm_delete_line, n)); - touched = 1; - } else if (delete_line) { - while (n--) - putp(delete_line); - touched = 1; - } - } - - mvcur(-1, -1, win->_cury, win->_curx); - } - if (touched == 0) - touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1); - touched = 0; - - return OK; + return ret; } -- cgit v1.2.3