Module Name: src
Committed By: blymn
Date: Thu Sep 15 11:58:05 UTC 2011
Modified Files:
src/lib/libcurses: curses_window.3 mvwin.c
Log Message:
- Make mvderwin work as per the SUSv2 specification and other curses
implementations.
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcurses/curses_window.3
cvs rdiff -u -r1.15 -r1.16 src/lib/libcurses/mvwin.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libcurses/curses_window.3
diff -u src/lib/libcurses/curses_window.3:1.13 src/lib/libcurses/curses_window.3:1.14
--- src/lib/libcurses/curses_window.3:1.13 Mon May 18 09:30:31 2009
+++ src/lib/libcurses/curses_window.3 Thu Sep 15 11:58:05 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: curses_window.3,v 1.13 2009/05/18 09:30:31 wiz Exp $
+.\" $NetBSD: curses_window.3,v 1.14 2011/09/15 11:58:05 blymn Exp $
.\"
.\" Copyright (c) 2002
.\" Brett Lymn ([email protected], [email protected])
@@ -155,18 +155,28 @@
If the new position would cause the any part of the window to lie outside
the screen, it is an error and the window is not moved.
.Pp
-A subwindow can be moved relative to the parent window by calling the
+A mapping of a region relative to the parent window may be created by
+calling the
.Fn mvderwin
function, the
.Fa y
and
.Fa x
positions are relative to the origin of the parent window.
+The screen offset of
+.Fa win
+is not updated, the characters beginning at
+.Fa y ,
+.Fa x
+for the area the size of
+.Fa win
+will be displayed at the screen offset of
+.Fa win .
If the given window in
.Fa win
is not a subwindow then an error will be returned.
If the new position would cause the any part of the window to lie outside
-the parent window, it is an error and the window is not moved.
+the parent window, it is an error and the mapping is not updated.
.Pp
The
.Fn newwin
Index: src/lib/libcurses/mvwin.c
diff -u src/lib/libcurses/mvwin.c:1.15 src/lib/libcurses/mvwin.c:1.16
--- src/lib/libcurses/mvwin.c:1.15 Thu Aug 7 16:44:22 2003
+++ src/lib/libcurses/mvwin.c Thu Sep 15 11:58:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: mvwin.c,v 1.15 2003/08/07 16:44:22 agc Exp $ */
+/* $NetBSD: mvwin.c,v 1.16 2011/09/15 11:58:05 blymn Exp $ */
/*
* Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)mvwin.c 8.2 (Berkeley) 5/4/94";
#else
-__RCSID("$NetBSD: mvwin.c,v 1.15 2003/08/07 16:44:22 agc Exp $");
+__RCSID("$NetBSD: mvwin.c,v 1.16 2011/09/15 11:58:05 blymn Exp $");
#endif
#endif /* not lint */
@@ -43,14 +43,16 @@
/*
* mvderwin --
- * Move a derived window.
+ * Move a derived window. This does not change the physical screen
+ * coordinates of the subwin, rather maps the characters in the subwin
+ * sized part of the parent window starting at dy, dx into the subwin.
*
*/
int
mvderwin(WINDOW *win, int dy, int dx)
{
WINDOW *parent;
- int x, y;
+ int ox, oy, i;
if (win == NULL)
return ERR;
@@ -60,9 +62,25 @@
if (parent == NULL)
return ERR;
- x = parent->begx + dx;
- y = parent->begy + dy;
- return mvwin(win, y, x);
+ if (((win->maxx + dx) > parent->maxx) ||
+ ((win->maxy + dy) > parent->maxy))
+ return ERR;
+
+ ox = win->begx;
+ oy = win->begy;
+
+ win->begx = parent->begx + dx;
+ win->begy = parent->begy + dy;
+
+ __set_subwin(parent, win);
+
+ win->begx = ox;
+ win->begy = oy;
+
+ for (i = 0; i < win->maxy; i++)
+ win->alines[i]->flags = __ISDIRTY;
+
+ return OK;
}
/*