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 which was copying more ...



details:   https://anonhg.NetBSD.org/src/rev/9b8129f677a6
branches:  trunk
changeset: 485256:9b8129f677a6
user:      blymn <blymn%NetBSD.org@localhost>
date:      Sun Apr 23 14:14:49 2000 +0000

description:
* Fixed bug in copywin which was copying more than it should.
* Changed call to wrefresh in wgetch to be before input read.
* Changed default old cursor mode to be high vis in curs_set
* Added documentation for various new functions to fns.doc.

diffstat:

 lib/libcurses/PSD.doc/fns.doc |  84 +++++++++++++++++++++++++++++++++++++++++++
 lib/libcurses/copywin.c       |  51 +++++++++----------------
 lib/libcurses/getch.c         |   7 ++-
 3 files changed, 107 insertions(+), 35 deletions(-)

diffs (230 lines):

diff -r 6062df3b9a60 -r 9b8129f677a6 lib/libcurses/PSD.doc/fns.doc
--- a/lib/libcurses/PSD.doc/fns.doc     Sun Apr 23 10:20:50 2000 +0000
+++ b/lib/libcurses/PSD.doc/fns.doc     Sun Apr 23 14:14:49 2000 +0000
@@ -236,6 +236,48 @@
 Get the red, green and blue values of color
 .Vn color .
 .Ds
+.Fn copywin "const WINDOW *src" "WINDOW *dst" "int sminrow" "int smincol" "int dminrow" "int dmincol" "int dmaxrow" "int dmaxcol" "int overlay"
+.De
+Copies the contents of the window
+.Vn src
+starting at (
+.Vn sminrow ,
+.Vn smincol )
+to the destination window
+.Vn dst
+starting at (
+.Vn dminrow ,
+.Vn dmincol )
+and ending at either the end of the source window or (
+.Vn dmaxrow ,
+.Vn dmaxcol )
+whichever is the lesser.  The parameter
+.Vn overlay
+determines the nature of the copy.  If 
+.Vn overlay
+is TRUE then only the non-space characters from
+.Vn src
+are copied to
+.Vn dst .
+If 
+.Vn overlay
+is FALSE then all characters are copied from
+.Vn src
+to
+.Vn dst.
+.Ds
+.Fn curs_set "int visibility"
+.De
+Sets the visibility of the screen cursor.  The parameter
+.Vn visibility
+can be one of three values, 0 means make the cursor invisible, 1 means
+set the cursor to normal visibility and 2 sets the cursor to high
+visibility.  In all cases the old mode of the cursor is returned if
+the call was successful and
+.b ERR
+is returned if the terminal cannot support the requested visibility
+mode.
+.Ds
 .Fn crmode "" \(dg
 .De
 Identical to
@@ -285,6 +327,25 @@
 subwindows should be deleted before their
 outer windows are.
 .Ds
+.Fn derwin "WINDOW *orig" "int nlines" "int ncols" "int by" "int bx"
+.De
+Performs a function very similar to that of
+.Fn subwin .
+The difference being that with
+.Fn derwin
+the origin of the child window given by (
+.Vn by ,
+.Vn bx )
+is relative to the origin of the parent window
+.Vn orig
+instead of being absolute screen coordinates as they are in
+.Fn subwin .
+.Ds
+.Fn dupwin "WINDOW *win"
+.De
+Creates an exact copy of the window
+.Vn win .
+.Ds
 .Fn echo "" \(dg
 .De
 Sets the terminal to echo characters.
@@ -562,6 +623,17 @@
 (initially 0)
 retains its value until changed by the user.
 .Ds
+.Fn longname "" \(dg
+.De
+Returns a string containing the verbose description of the terminal.
+.Ds
+.Fn meta "WINDOW *win" "bool bf"
+.De
+Manipulates the meta mode on terminals that support this capability.
+Note that 
+.Vn win
+is always ignored.
+.Ds
 .Fn move "int y" "int x"
 .De
 Change the current \*y of the window to
@@ -1038,6 +1110,18 @@
 This is equivalent to
 .Fn attron "A_UNDERLINE" .
 .Ds
+.Fn ungetch "int c"
+.De
+Places the contents of
+.Vn c
+converted to a character back into the input queue.  Only one
+character of push back before a subsequent call to
+.Fn getch
+or
+.Fn wgetch
+is guaranteed to function correctly.  The results of attempting more
+than one character of push back is undefined.
+.Ds
 .Fn vwprintw "WINDOW *win" "const char *fmt" "va_list ap"
 .De
 Identical to
diff -r 6062df3b9a60 -r 9b8129f677a6 lib/libcurses/copywin.c
--- a/lib/libcurses/copywin.c   Sun Apr 23 10:20:50 2000 +0000
+++ b/lib/libcurses/copywin.c   Sun Apr 23 14:14:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: copywin.c,v 1.3 2000/04/20 13:12:14 blymn Exp $        */
+/*     $NetBSD: copywin.c,v 1.4 2000/04/23 14:14:49 blymn Exp $        */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -49,8 +49,8 @@
        int starty, startx, endy, endx, x, y, y1, y2, smaxrow, smaxcol;
        __LDATA *sp, *end;
        
-       smaxrow = sminrow + dmaxrow - dminrow;
-       smaxcol = smincol + dmaxcol - dmincol;
+       smaxrow = min(sminrow + dmaxrow - dminrow, srcwin->maxy - sminrow);
+       smaxcol = min(smincol + dmaxcol - dmincol, srcwin->maxx - smincol);
        starty = max(sminrow, dminrow);
        startx = max(smincol, dmincol);
        endy = min(sminrow + smaxrow, dminrow + dmaxrow);
@@ -58,43 +58,30 @@
        if (starty >= endy || startx >= endx)
                return (OK);
        
+#ifdef DEBUG
        if (overlay == TRUE) {
-                 /* non destructive copy */
-#ifdef DEBUG
                __CTRACE("copywin overlay mode: from (%d,%d) to (%d,%d)\n",
                         starty, startx, endy, endx);
-#endif
-               y1 = starty - sminrow;
-               y2 = starty - dminrow;
-               for (y = starty; y < endy; y++, y1++, y2++) {
-                       end = &srcwin->lines[y1]->line[endx - srcwin->begx];
-                       x = startx - dstwin->begx;
-                       for (sp = &srcwin->lines[y1]->line[startx - srcwin->begx];
-                            sp < end; sp++) {
-                               if (!isspace(sp->ch)) {
-                                       wmove(dstwin, y2, x);
-                                       __waddch(dstwin, sp);
-                               }
-                               x++;
-                       }
-               }
-               return (OK);
        } else {
-                 /* destructive copy */
-#ifdef DEBUG
                __CTRACE("copywin overwrite mode: from (%d,%d) to (%d,%d)\n",
                         starty, startx, endy, endx);
+       }
+       
 #endif
-               x = endx - startx;
-               for (y = starty; y < endy; y++) {
-                       (void) memcpy(
-                               &dstwin->lines[y - dstwin->begy]->line[startx - dstwin->begx],
-                               &srcwin->lines[y - srcwin->begy]->line[startx - srcwin->begx],
-                               (size_t) x * __LDATASIZE);
-                       __touchline(dstwin, y - dstwin->begy, (int) (startx - dstwin->begx),
-                                   (int) (endx - dstwin->begx), 0);
+       y1 = starty - sminrow;
+       y2 = starty - dminrow;
+       for (y = starty; y < endy; y++, y1++, y2++) {
+               end = &srcwin->lines[y1]->line[endx - srcwin->begx];
+               x = startx - dstwin->begx;
+               for (sp = &srcwin->lines[y1]->line[startx - srcwin->begx];
+                    sp < end; sp++) {
+                       if ((!isspace(sp->ch)) || (overlay == FALSE)){
+                               wmove(dstwin, y2, x);
+                               __waddch(dstwin, sp);
+                       }
+                       x++;
                }
-               return (OK);
        }
+       return (OK);
 }
 
diff -r 6062df3b9a60 -r 9b8129f677a6 lib/libcurses/getch.c
--- a/lib/libcurses/getch.c     Sun Apr 23 10:20:50 2000 +0000
+++ b/lib/libcurses/getch.c     Sun Apr 23 14:14:49 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: getch.c,v 1.23 2000/04/22 21:14:19 thorpej Exp $       */
+/*     $NetBSD: getch.c,v 1.24 2000/04/23 14:14:49 blymn Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)getch.c    8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: getch.c,v 1.23 2000/04/22 21:14:19 thorpej Exp $");
+__RCSID("$NetBSD: getch.c,v 1.24 2000/04/23 14:14:49 blymn Exp $");
 #endif
 #endif                                 /* not lint */
 
@@ -568,6 +568,8 @@
            && win->curx == win->maxx - 1 && win->cury == win->maxy - 1
            && __echoit)
                return (ERR);
+       
+       wrefresh(win);
 #ifdef DEBUG
        __CTRACE("wgetch: __echoit = %d, __rawmode = %d, flags = %0.2o\n",
            __echoit, __rawmode, win->flags);
@@ -654,7 +656,6 @@
        if (weset)
                nocbreak();
 
-       wrefresh(win);
        return ((inp < 0) || (inp == ERR) ? ERR : inp);
 }
 



Home | Main Index | Thread Index | Old Index