summaryrefslogtreecommitdiffstats
path: root/lib/libncurses/lib_insdel.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-11-29 02:48:20 +0000
committerache <ache@FreeBSD.org>1994-11-29 02:48:20 +0000
commita41d3aa1190512c05ef7c4d4f9671f1d0e4a9fac (patch)
treeec0b67f9dfd7b50ab0da583dec626b7e9038eb87 /lib/libncurses/lib_insdel.c
parentc86bd43a842dd8ead831909bae8c98f68cedee12 (diff)
downloadFreeBSD-src-a41d3aa1190512c05ef7c4d4f9671f1d0e4a9fac.zip
FreeBSD-src-a41d3aa1190512c05ef7c4d4f9671f1d0e4a9fac.tar.gz
wscrl: implement partial scrolling via al/dl
winsdel: implemented via wscrl winsertln/deleteln: implemented as macros via winsdel
Diffstat (limited to 'lib/libncurses/lib_insdel.c')
-rw-r--r--lib/libncurses/lib_insdel.c98
1 files changed, 13 insertions, 85 deletions
diff --git a/lib/libncurses/lib_insdel.c b/lib/libncurses/lib_insdel.c
index 879631f..9eb130b 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;
}
OpenPOWER on IntegriCloud