aboutsummaryrefslogtreecommitdiff
path: root/lib/libncurses/lib_insdel.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-11-29 02:48:20 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-11-29 02:48:20 +0000
commit1f36118a96fb5605609e5dd04dade38629b53386 (patch)
treeec0b67f9dfd7b50ab0da583dec626b7e9038eb87 /lib/libncurses/lib_insdel.c
parentf3be64932ff1058277260267f86a9bb1a1775884 (diff)
downloadsrc-1f36118a96fb5605609e5dd04dade38629b53386.tar.gz
src-1f36118a96fb5605609e5dd04dade38629b53386.zip
wscrl: implement partial scrolling via al/dl
winsdel: implemented via wscrl winsertln/deleteln: implemented as macros via winsdel
Notes
Notes: svn path=/head/; revision=4860
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 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;
}