Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses * Fixed bug in copywin.



details:   https://anonhg.NetBSD.org/src/rev/7097c9773b41
branches:  trunk
changeset: 485367:7097c9773b41
user:      blymn <blymn%NetBSD.org@localhost>
date:      Wed Apr 26 12:29:47 2000 +0000

description:
* Fixed bug in copywin.
* Fixed bug in overwrite.
* Added functions is_linetouched, is_wintouched, untouchwin and wtouchln.

diffstat:

 lib/libcurses/PSD.doc/fns.doc |  36 +++++++++++++++++++
 lib/libcurses/copywin.c       |   8 ++--
 lib/libcurses/curses.3        |  23 ++++++++++++-
 lib/libcurses/curses.h        |   6 ++-
 lib/libcurses/overwrite.c     |   7 ++-
 lib/libcurses/shlib_version   |   4 +-
 lib/libcurses/touchwin.c      |  78 ++++++++++++++++++++++++++++++++++++------
 7 files changed, 139 insertions(+), 23 deletions(-)

diffs (truncated from 333 to 300 lines):

diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/PSD.doc/fns.doc
--- a/lib/libcurses/PSD.doc/fns.doc     Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/PSD.doc/fns.doc     Wed Apr 26 12:29:47 2000 +0000
@@ -582,6 +582,22 @@
 The current line will become blank,
 and the current \*y will remain unchanged.
 .Ds
+.Fn is_linetouched "WINDOW *win" "int line"
+.De
+Returns TRUE if 
+.Vn line
+in the window
+.Vn win
+has been modified since the last call to
+.Fn wrefresh .
+.Ds
+.Fn is_wintouched "WINDOW *win" "int line"
+.De
+Returns TRUE if the window
+.Vn win
+has been modified since the last call to
+.Fn wrefresh .
+.Ds
 .Fn isendwin ""
 .De
 Returns TRUE if
@@ -1168,6 +1184,10 @@
 is guaranteed to function correctly.  The results of attempting more
 than one character of push back is undefined.
 .Ds
+.Fn untouchwin "WINDOW *win"
+.De
+Make the window appear to have not been updated even if it has been.
+.Ds
 .Fn vline "chtype ch" "int count"
 .De
 Draws a vertical line of character
@@ -1202,6 +1222,22 @@
 .Vn str
 are output to the current \*y position of the window specified by
 .Vn win.
+.Ds
+.Fn wtouchln "WINDOW *win" "int line" "int n" "int changed"
+.De
+If 
+.Vn changed
+is 1 then 
+.Vn n
+lines starting at
+.Vn line
+in the window are touched.  If
+.Vn changed
+is 0 then 
+.Vn n
+lines starting at
+.Vn line
+in the window are untouched.
 .sp 2
 .pp
 \fIThe following functions differ from the standard functions only in their
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/copywin.c
--- a/lib/libcurses/copywin.c   Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/copywin.c   Wed Apr 26 12:29:47 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copywin.c,v 1.5 2000/04/24 14:09:42 blymn Exp $        */
+/*     $NetBSD: copywin.c,v 1.6 2000/04/26 12:29:47 blymn Exp $        */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: copywin.c,v 1.5 2000/04/24 14:09:42 blymn Exp $");
+__RCSID("$NetBSD: copywin.c,v 1.6 2000/04/26 12:29:47 blymn Exp $");
 #endif                         /* not lint */
 
 #include <ctype.h>
@@ -54,8 +54,8 @@
        int starty, startx, endy, endx, x, y, y1, y2, smaxrow, smaxcol;
        __LDATA *sp, *end;
        
-       smaxrow = min(sminrow + dmaxrow - dminrow, srcwin->maxy - sminrow);
-       smaxcol = min(smincol + dmaxcol - dmincol, srcwin->maxx - smincol);
+       smaxrow = min(sminrow + dmaxrow - dminrow, srcwin->maxy);
+       smaxcol = min(smincol + dmaxcol - dmincol, srcwin->maxx);
        starty = max(sminrow, dminrow);
        startx = max(smincol, dmincol);
        endy = min(sminrow + smaxrow, dminrow + dmaxrow);
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/curses.3
--- a/lib/libcurses/curses.3    Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/curses.3    Wed Apr 26 12:29:47 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: curses.3,v 1.23 2000/04/24 15:13:54 pk Exp $
+.\"    $NetBSD: curses.3,v 1.24 2000/04/26 12:29:47 blymn Exp $
 .\"
 .\" Copyright (c) 1985, 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -158,6 +158,10 @@
 .Em stdstr
 .It insertln() insert a line
 .It intrflush(win,boolf)       set flush on interrupt terminal mode
+.It is_linetouched(win, line)  check if line has been modified since
+last refresh.
+.It is_wintouched(win) Check if window has been modified since last
+refresh.
 .It isendwin() check if endwin() or wrefresh() was called latest
 .It keypad(win,boolf)  set keypad flag for
 .Em win
@@ -260,6 +264,7 @@
 .It underend() end underscore mode
 .It underscore()       start underscore mode
 .It ungetch(ch)                Put character back onto input queue.
+.It untouchwin(win)    Make window appear not to have been modified.
 .It vline(ch, count)   Draw a vertical line of character
 .Em ch .
 .It waddch(win,ch)     add char to
@@ -324,6 +329,22 @@
 .Em win
 .It wtimeout(win,delay)        set blocking or non-blocking read for
 .Em win
+.It wtouchln(win, line, n, changed)    If 
+.Em changed
+is 1 then touch
+.Em n
+lines starting at
+.Em line
+in window
+.Em win .
+If 
+.Em changed
+is 0 then untouch
+.Em n
+lines starting at
+.Em line
+in window
+.Em win
 .It wunderend(win)     end underscore mode on
 .Em win
 .It wunderscore(win)   start underscore mode on
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/curses.h
--- a/lib/libcurses/curses.h    Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/curses.h    Wed Apr 26 12:29:47 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: curses.h,v 1.42 2000/04/24 14:09:43 blymn Exp $        */
+/*     $NetBSD: curses.h,v 1.43 2000/04/26 12:29:47 blymn Exp $        */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -521,6 +521,8 @@
 WINDOW *initscr(void);
 int     intrflush(WINDOW *win, bool bf);
 bool    isendwin(void);
+bool     is_linetouched(WINDOW *win, int line);
+bool     is_wintouched(WINDOW *win);
 void    keypad(WINDOW *win, bool bf);
 int     leaveok(WINDOW *win, bool bf);
 char   *longname(void);
@@ -562,6 +564,7 @@
 int     touchoverlap(WINDOW *win1, WINDOW *win2);
 int     touchwin(WINDOW *win);
 int      ungetch(int c);
+int      untouchwin(WINDOW *win);
 int      vline(chtype ch, int count);
 int     vwprintw(WINDOW *win, const char *fmt, _BSD_VA_LIST_);
 int     vwscanw(WINDOW *win, const char *fmt, _BSD_VA_LIST_);
@@ -596,6 +599,7 @@
 int     wstandend(WINDOW *win);
 int     wstandout(WINDOW *win);
 void    wtimeout(WINDOW *win, int delay);
+int      wtouchln(WINDOW *win, int line, int n, int changed);
 int     wunderend(WINDOW *win);
 int     wunderscore(WINDOW *win);
 int      wvline(WINDOW *win, chtype ch, int count);
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/overwrite.c
--- a/lib/libcurses/overwrite.c Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/overwrite.c Wed Apr 26 12:29:47 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: overwrite.c,v 1.13 2000/04/18 12:23:01 blymn Exp $     */
+/*     $NetBSD: overwrite.c,v 1.14 2000/04/26 12:29:47 blymn Exp $     */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)overwrite.c        8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: overwrite.c,v 1.13 2000/04/18 12:23:01 blymn Exp $");
+__RCSID("$NetBSD: overwrite.c,v 1.14 2000/04/26 12:29:47 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -59,5 +59,6 @@
        __CTRACE("overwrite: (%0.2o, %0.2o);\n", win1, win2);
 #endif
        return copywin(win1, win2, win1->begy, win1->begx, win2->begy,
-                      win2->begx, win2->maxy, win2->maxx, FALSE);
+                      win2->begx, win2->begy + win2->maxy,
+                      win2->begx + win2->maxx, FALSE);
 }
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/shlib_version
--- a/lib/libcurses/shlib_version       Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/shlib_version       Wed Apr 26 12:29:47 2000 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: shlib_version,v 1.12 2000/04/25 14:05:15 blymn Exp $
+#      $NetBSD: shlib_version,v 1.13 2000/04/26 12:29:47 blymn Exp $
 #      Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=3
-minor=2
+minor=3
diff -r accd9660a9d0 -r 7097c9773b41 lib/libcurses/touchwin.c
--- a/lib/libcurses/touchwin.c  Wed Apr 26 12:25:51 2000 +0000
+++ b/lib/libcurses/touchwin.c  Wed Apr 26 12:29:47 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: touchwin.c,v 1.12 2000/04/15 22:53:05 jdc Exp $        */
+/*     $NetBSD: touchwin.c,v 1.13 2000/04/26 12:29:47 blymn Exp $      */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)touchwin.c 8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: touchwin.c,v 1.12 2000/04/15 22:53:05 jdc Exp $");
+__RCSID("$NetBSD: touchwin.c,v 1.13 2000/04/26 12:29:47 blymn Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -46,6 +46,20 @@
 #include "curses_private.h"
 
 /*
+ * is_linetouched --
+ *    Indicate if line has been touched or not.
+ */
+bool
+is_linetouched(WINDOW *win, int line)
+{
+       if (line > win->maxy)
+               return FALSE;
+       
+       return ((win->lines[line]->flags & (__ISDIRTY | __FORCEPAINT)) != 0);
+}
+       
+
+/*
  * Touch count lines starting at start.  This is the SUS v2 compliant
  * version.
  */
@@ -53,13 +67,25 @@
 int
 touchline(WINDOW *win, int start, int count)
 {
-       int y;
+       return wtouchln(win, start, count, 1);
+}
 
-       for (y = start; y < start + count; y++) {
-               __touchline(win, y, 0, (int) win->maxx - 1, 1);
+/*
+ * is_wintouched --
+ *      Check if the window has been touched.
+ */
+bool
+is_wintouched(WINDOW *win)
+{
+       int y, maxy;
+
+       maxy = win->maxy;
+       for (y = 0; y < maxy; y++) {
+               if (is_linetouched(win, y) == TRUE)
+                       return TRUE;
        }
 
-       return OK;
+       return FALSE;
 }
 
 /*
@@ -69,18 +95,46 @@
 int
 touchwin(WINDOW *win)
 {
-       int     y, maxy;
-
 #ifdef DEBUG
        __CTRACE("touchwin: (%0.2o)\n", win);
 #endif
-       maxy = win->maxy;
-       for (y = 0; y < maxy; y++)
-               __touchline(win, y, 0, (int) win->maxx - 1, 1);
-       return (OK);
+       return wtouchln(win, 0, win->maxy, 1);
+}
+
+/*
+ * untouchwin --
+ *     Make it look like the window has not been changed.
+ */



Home | Main Index | Thread Index | Old Index