summaryrefslogtreecommitdiffstats
path: root/lib/libncurses
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
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')
-rw-r--r--lib/libncurses/Makefile6
-rw-r--r--lib/libncurses/lib_insdel.c98
-rw-r--r--lib/libncurses/lib_scroll.c247
-rw-r--r--lib/libncurses/ncurses.h4
4 files changed, 193 insertions, 162 deletions
diff --git a/lib/libncurses/Makefile b/lib/libncurses/Makefile
index 2f758f2..9ed3a67 100644
--- a/lib/libncurses/Makefile
+++ b/lib/libncurses/Makefile
@@ -1,5 +1,5 @@
# Makefile for ncurses
-# $Id: Makefile,v 1.5 1994/10/12 01:59:06 ache Exp $
+# $Id: Makefile,v 1.6 1994/10/28 06:56:55 ache Exp $
LIB= ncurses
SRCS= lib_kernel.c lib_pad.c\
@@ -8,8 +8,8 @@ SRCS= lib_kernel.c lib_pad.c\
lib_addstr.c lib_scroll.c lib_clreol.c lib_touch.c lib_mvcur.c lib_keyname.c\
lib_delwin.c lib_endwin.c lib_clrbot.c lib_move.c lib_printw.c \
lib_scanw.c lib_erase.c lib_getch.c lib_options.c lib_acs.c lib_slk.c\
- lib_box.c lib_clear.c lib_delch.c lib_deleteln.c lib_insch.c \
- lib_insertln.c lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
+ lib_box.c lib_clear.c lib_delch.c lib_insch.c \
+ lib_getstr.c lib_mvwin.c lib_longname.c lib_tstp.c \
lib_newterm.c lib_set_term.c lib_overlay.c lib_scrreg.c lib_color.c \
lib_insstr.c lib_insdel.c lib_twait.c copyright.c
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;
}
diff --git a/lib/libncurses/lib_scroll.c b/lib/libncurses/lib_scroll.c
index c15e52e..0f27817 100644
--- a/lib/libncurses/lib_scroll.c
+++ b/lib/libncurses/lib_scroll.c
@@ -19,9 +19,9 @@
int
wscrl(WINDOW *win, int n)
{
-int line, i;
+int line, i, touched = 0;
chtype *ptr, *temp;
-chtype **saved;
+chtype **saved, **newsaved = NULL, **cursaved = NULL;
chtype blank = ' ';
T(("wscrl(%x,%d) called", win, n));
@@ -34,88 +34,191 @@ chtype blank = ' ';
/* test for scrolling region == entire screen */
- saved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+ /* as an optimization, if the scrolling region is the entire screen
+ scroll the physical screen */
+ /* should we extend this to include smaller scrolling ranges by using
+ change_scroll_region? */
- if (n < 0) {
- /* save overwritten lines */
-
- for (i = 0; i < -n; i++)
- saved[i] = win->_line[win->_regbottom-i];
-
- /* shift n lines */
-
- for (line = win->_regbottom; line > win->_regtop+n; line--)
- win->_line[line] = win->_line[line+n];
-
- /* 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 ( win->_begx == 0 && win->_maxx == columns - 1
+ && !memory_above && !memory_below
+ && ((win->_regtop == 0 && win->_regbottom == lines - 1
+ && ( (n < 0 && (parm_rindex || scroll_reverse))
+ || (n > 0 && (parm_index || scroll_forward))
+ )
+ ) || (win->_idlok && (parm_insert_line || insert_line)
+ && (parm_delete_line || delete_line)
+ )
+ )
+ ) {
+ wrefresh(win);
+ if (n < 0) {
+ if ( win->_regtop == 0 && win->_regbottom == lines - 1
+ && (parm_rindex || scroll_reverse)
+ ) {
+ i = abs(n);
+ mvcur(-1, -1, win->_regtop, 0);
+ if (parm_rindex) {
+ putp(tparm(parm_rindex, i));
+ } else if (scroll_reverse) {
+ while (i--)
+ putp(scroll_reverse);
+ }
+ } else {
+ i = abs(n);
+ if (win->_regbottom < lines - 1) {
+ mvcur(-1, -1, win->_regbottom, 0);
+ if (parm_delete_line) {
+ putp(tparm(parm_delete_line, i));
+ } else if (delete_line) {
+ while (i--)
+ putp(delete_line);
+ i = abs(n);
+ }
+ }
+ mvcur(-1, -1, win->_regtop, 0);
+ if (parm_insert_line) {
+ putp(tparm(parm_insert_line, i));
+ } else if (insert_line) {
+ while (i--)
+ putp(insert_line);
+ }
+ }
+ } else {
+ if ( win->_regtop == 0 && win->_regbottom == lines - 1
+ && (parm_index || scroll_forward)
+ ) {
+ mvcur(-1, -1, win->_regbottom, 0);
+ if (parm_index) {
+ putp(tparm(parm_index, n));
+ } else if (scroll_forward) {
+ i = n;
+ while (i--)
+ putp(scroll_forward);
+ }
+ } else {
+ mvcur(-1, -1, win->_regtop, 0);
+ if (parm_delete_line) {
+ putp(tparm(parm_delete_line, n));
+ } else if (delete_line) {
+ i = n;
+ while (i--)
+ putp(delete_line);
+ }
+ if (win->_regbottom < lines - 1) {
+ mvcur(win->_regtop, 0, win->_regbottom, 0);
+ if (parm_insert_line) {
+ putp(tparm(parm_insert_line, n));
+ } else if (insert_line) {
+ i = n;
+ while (i--)
+ putp(insert_line);
+ }
+ }
+ }
}
- }
- if (n > 0) {
- /* save overwritten lines */
-
- for (i = 0; i < n; i++)
- saved[i] = win->_line[win->_regtop+i];
+ mvcur(-1, -1, win->_cury, win->_curx);
+ touched = 1;
+ }
- /* shift n lines */
-
- for (line = win->_regtop; line < win->_regbottom; line++)
- win->_line[line] = win->_line[line+n];
+ saved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+ if (touched) {
+ newsaved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+ cursaved = (chtype **)malloc(sizeof(chtype *) * abs(n));
+ }
- /* restore saved lines and blank them */
+ if (n < 0) {
+ /* save overwritten lines */
+
+ for (i = 0; i < -n; i++) {
+ saved[i] = win->_line[win->_regbottom-i];
+ if (touched) {
+ newsaved[i] = newscr->_line[win->_begy+win->_regbottom-i];
+ cursaved[i] = curscr->_line[win->_begy+win->_regbottom-i];
+ }
+ }
- for (i = 0, line = win->_regbottom; line > win->_regbottom - n; line--, i++) {
- win->_line[line] = saved[i];
- temp = win->_line[line];
- for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
- *ptr = blank;
- }
+ /* shift n lines */
+
+ for (line = win->_regbottom; line >= win->_regtop - n; line--) {
+ win->_line[line] = win->_line[line+n];
+ if (touched) {
+ newscr->_line[win->_begy+line] = newscr->_line[win->_begy+line+n];
+ curscr->_line[win->_begy+line] = curscr->_line[win->_begy+line+n];
+ }
}
-
- free(saved);
- /* as an optimization, if the scrolling region is the entire screen
- scroll the physical screen */
- /* should we extend this to include smaller scrolling ranges by using
- change_scroll_region? */
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regtop; line < win->_regtop-n; line++, i++) {
+ win->_line[line] = saved[i];
+ if (touched) {
+ newscr->_line[win->_begy+line] = newsaved[i];
+ curscr->_line[win->_begy+line] = cursaved[i];
+ }
+ temp = win->_line[line];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ if (touched) {
+ temp = newscr->_line[win->_begy+line];
+ for (ptr = temp; ptr - temp <= newscr->_maxx; ptr++)
+ *ptr = blank;
+ temp = curscr->_line[win->_begy+line];
+ for (ptr = temp; ptr - temp <= curscr->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+ } else {
+ /* save overwritten lines */
+
+ for (i = 0; i < n; i++) {
+ saved[i] = win->_line[win->_regtop+i];
+ if (touched) {
+ newsaved[i] = newscr->_line[win->_begy+win->_regtop+i];
+ cursaved[i] = curscr->_line[win->_begy+win->_regtop+i];
+ }
+ }
- if (win->_maxx == columns && win->_regtop == 0 && win->_regbottom == lines) {
+ /* shift n lines */
- wrefresh(win);
- /* at the moment this relies on scroll_reverse and scroll_forward
- or parm_rindex and parm_index.
- we should add idl support as an alternative */
-
- if (n > 0) {
- mvcur(-1, -1, win->_regtop, 0);
- if (parm_rindex) {
- putp(tparm(parm_rindex, n));
- } else if (scroll_reverse) {
- while (n--)
- putp(scroll_reverse);
- }
- }
+ for (line = win->_regtop; line <= win->_regbottom - n; line++) {
+ win->_line[line] = win->_line[line+n];
+ if (touched) {
+ newscr->_line[win->_begy+line] = newscr->_line[win->_begy+line+n];
+ curscr->_line[win->_begy+line] = curscr->_line[win->_begy+line+n];
+ }
+ }
- if (n < 0) {
- mvcur(-1, -1, win->_regbottom, columns);
- n = abs(n);
- if (parm_index) {
- putp(tparm(parm_index, n));
- } else if (scroll_forward) {
- while (n--)
- putp(scroll_forward);
- }
- }
+ /* restore saved lines and blank them */
+
+ for (i = 0, line = win->_regbottom; line > win->_regbottom - n; line--, i++) {
+ win->_line[line] = saved[i];
+ if (touched) {
+ newscr->_line[win->_begy+line] = newsaved[i];
+ curscr->_line[win->_begy+line] = cursaved[i];
+ }
+ temp = win->_line[line];
+ for (ptr = temp; ptr - temp <= win->_maxx; ptr++)
+ *ptr = blank;
+ if (touched) {
+ temp = newscr->_line[win->_begy+line];
+ for (ptr = temp; ptr - temp <= newscr->_maxx; ptr++)
+ *ptr = blank;
+ temp = curscr->_line[win->_begy+line];
+ for (ptr = temp; ptr - temp <= curscr->_maxx; ptr++)
+ *ptr = blank;
+ }
+ }
+ }
+
+ free(saved);
+ if (touched) {
+ free(newsaved);
+ free(cursaved);
+ }
- mvcur(-1, -1, win->_cury, win->_curx);
- } else
- touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);
+ if (!touched)
+ touchline(win, win->_regtop, win->_regbottom - win->_regtop + 1);
return OK;
}
diff --git a/lib/libncurses/ncurses.h b/lib/libncurses/ncurses.h
index 6f11d18..d9f615a 100644
--- a/lib/libncurses/ncurses.h
+++ b/lib/libncurses/ncurses.h
@@ -240,14 +240,12 @@ extern int wclear(WINDOW *);
extern int wclrtobot(WINDOW *);
extern int wclrtoeol(WINDOW *);
extern int wdelch(WINDOW *);
-extern int wdeleteln(WINDOW *);
extern int werase(WINDOW *);
extern int wgetch(WINDOW *);
extern int wgetnstr(WINDOW *,char *,int maxlen);
extern int whline(WINDOW *,chtype,int);
extern int winsch(WINDOW *,chtype);
extern int winsdel(WINDOW *,int);
-extern int winsertln(WINDOW *);
extern int winsnstr(WINDOW *,char *,int);
extern int wmove(WINDOW *,int,int);
extern int wnoutrefresh(WINDOW *);
@@ -327,6 +325,8 @@ extern int slk_touch(void);
#define vline(ch, n) wvline(stdscr, ch, n)
#define winsstr(w, s) winsnstr(w, s, 0)
+#define winsertln(w) winsdel(w, 1)
+#define wdeleteln(w) winsdel(w, -1)
#define redrawwin(w) redrawln(w, 0, w->_maxy+1)
OpenPOWER on IntegriCloud