Module Name: src
Committed By: uwe
Date: Mon Oct 26 23:09:50 UTC 2015
Added Files:
src/lib/libpanel: Makefile _deck.c above.c below.c bottom.c del.c
getuser.c hidden.c hide.c move.c new.c panel.h panel_impl.h
replace.c setuser.c shlib_version show.c top.c update.c window.c
Log Message:
First cut at ETI libpanel. Lacks man pages and tests.
Not hooked into the build yet.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/lib/libpanel/Makefile src/lib/libpanel/_deck.c \
src/lib/libpanel/above.c src/lib/libpanel/below.c \
src/lib/libpanel/bottom.c src/lib/libpanel/del.c \
src/lib/libpanel/getuser.c src/lib/libpanel/hidden.c \
src/lib/libpanel/hide.c src/lib/libpanel/move.c src/lib/libpanel/new.c \
src/lib/libpanel/panel.h src/lib/libpanel/panel_impl.h \
src/lib/libpanel/replace.c src/lib/libpanel/setuser.c \
src/lib/libpanel/shlib_version src/lib/libpanel/show.c \
src/lib/libpanel/top.c src/lib/libpanel/update.c \
src/lib/libpanel/window.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: src/lib/libpanel/Makefile
diff -u /dev/null src/lib/libpanel/Makefile:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/Makefile Mon Oct 26 23:09:49 2015
@@ -0,0 +1,31 @@
+# $NetBSD: Makefile,v 1.1 2015/10/26 23:09:49 uwe Exp $
+
+WARNS= 4
+
+LIB= panel
+
+INCS= panel.h
+
+SRCS= #
+
+SRCS+= _deck.c
+
+SRCS+= above.c
+SRCS+= below.c
+SRCS+= bottom.c
+SRCS+= del.c
+SRCS+= getuser.c
+SRCS+= hidden.c
+SRCS+= hide.c
+SRCS+= move.c
+SRCS+= new.c
+SRCS+= replace.c
+SRCS+= setuser.c
+SRCS+= show.c
+SRCS+= top.c
+SRCS+= update.c
+SRCS+= window.c
+
+#LIBDPLIBS+= curses ${.CURDIR}/../libcurses
+
+.include <bsd.lib.mk>
Index: src/lib/libpanel/_deck.c
diff -u /dev/null src/lib/libpanel/_deck.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/_deck.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,34 @@
+/* $NetBSD: _deck.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: _deck.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+struct deck _deck __dso_hidden = TAILQ_HEAD_INITIALIZER(_deck);
+PANEL _stdscr_panel __dso_hidden;
Index: src/lib/libpanel/above.c
diff -u /dev/null src/lib/libpanel/above.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/above.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,45 @@
+/* $NetBSD: above.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: above.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+PANEL *
+panel_above(PANEL *p)
+{
+
+ if (__predict_false(p == NULL))
+ return NULL;
+
+ if (__predict_false(PANEL_HIDDEN(p)))
+ return NULL;
+
+ return PANEL_ABOVE(p);
+}
Index: src/lib/libpanel/below.c
diff -u /dev/null src/lib/libpanel/below.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/below.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,50 @@
+/* $NetBSD: below.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: below.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+PANEL *
+panel_below(PANEL *p)
+{
+ PANEL *below;
+
+ if (__predict_false(p == NULL))
+ return NULL;
+
+ if (__predict_false(PANEL_HIDDEN(p)))
+ return NULL;
+
+ below = PANEL_BELOW(p);
+ if (below == &_stdscr_panel)
+ return NULL;
+ else
+ return below;
+}
Index: src/lib/libpanel/bottom.c
diff -u /dev/null src/lib/libpanel/bottom.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/bottom.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,48 @@
+/* $NetBSD: bottom.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: bottom.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+bottom_panel(PANEL *p)
+{
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ if (__predict_false(PANEL_HIDDEN(p)))
+ return ERR;
+
+ (void) hide_panel(p);
+
+ DECK_INSERT_BOTTOM(p);
+ return OK;
+}
Index: src/lib/libpanel/del.c
diff -u /dev/null src/lib/libpanel/del.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/del.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,63 @@
+/* $NetBSD: del.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: del.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+
+int
+del_panel(PANEL *p)
+{
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ (void) hide_panel(p);
+ free(p);
+
+ /*
+ * If the last panel is removed, remove the phantom stdscr
+ * panel as well.
+ *
+ * A program that wants to switch to a different screen with
+ * set_term(3), or ends and recreates curses session with
+ * endwin(3)/initscr(3), must delete all panels first, since
+ * their windows will become invalid. When it will create its
+ * first new panel afterwards, it will pick up new stdscr.
+ */
+ if (TAILQ_LAST(&_deck, deck) == &_stdscr_panel) {
+ (void) hide_panel(&_stdscr_panel);
+ assert(TAILQ_EMPTY(&_deck));
+ }
+
+ return OK;
+}
Index: src/lib/libpanel/getuser.c
diff -u /dev/null src/lib/libpanel/getuser.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/getuser.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,41 @@
+/* $NetBSD: getuser.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: getuser.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+char *
+panel_userptr(PANEL *p)
+{
+ if (p == NULL)
+ return NULL;
+
+ return p->user;
+}
Index: src/lib/libpanel/hidden.c
diff -u /dev/null src/lib/libpanel/hidden.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/hidden.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,45 @@
+/* $NetBSD: hidden.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: hidden.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+panel_hidden(PANEL *p)
+{
+
+ if (p == NULL)
+ return ERR;
+
+ if (PANEL_HIDDEN(p))
+ return TRUE;
+ else
+ return FALSE;
+}
Index: src/lib/libpanel/hide.c
diff -u /dev/null src/lib/libpanel/hide.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/hide.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,56 @@
+/* $NetBSD: hide.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: hide.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+hide_panel(PANEL *p)
+{
+ PANEL *other;
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ if (__predict_false(PANEL_HIDDEN(p)))
+ return OK;
+
+ DECK_REMOVE(p);
+
+ /*
+ * The panel is no longer in the deck, so update_panels() will
+ * not handle it. Touch exposed areas now.
+ */
+ FOREACH_PANEL (other) {
+ touchoverlap(p->win, other->win);
+ }
+
+ return OK;
+}
Index: src/lib/libpanel/move.c
diff -u /dev/null src/lib/libpanel/move.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/move.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,58 @@
+/* $NetBSD: move.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: move.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+move_panel(PANEL *p, int y, int x)
+{
+ int oldy, oldx;
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ getbegyx(p->win, oldy, oldx);
+ if (__predict_false(y == oldy && x == oldx))
+ return OK;
+
+ if (!PANEL_HIDDEN(p)) {
+ PANEL *other;
+
+ /* touch exposed areas at the old location now */
+ FOREACH_PANEL (other) {
+ if (other != p) {
+ touchoverlap(p->win, other->win);
+ }
+ }
+ }
+
+ return mvwin(p->win, y, x);
+}
Index: src/lib/libpanel/new.c
diff -u /dev/null src/lib/libpanel/new.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/new.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,75 @@
+/* $NetBSD: new.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: new.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+#include <assert.h>
+#include <stdlib.h>
+
+
+static PANEL *
+_new_panel(WINDOW *w)
+{
+ PANEL *p;
+
+ p = (PANEL *)malloc(sizeof(PANEL));
+ if (p == NULL)
+ return NULL;
+
+ p->win = w;
+ p->user = NULL;
+
+ DECK_INSERT_TOP(p);
+ return p;
+}
+
+
+PANEL *
+new_panel(WINDOW *w)
+{
+ if (__predict_false(w == NULL))
+ return NULL;
+
+ if (__predict_false(w == stdscr))
+ return NULL;
+
+ /*
+ * Ensure there's phantom panel for stdscr at (below) the
+ * bottom. We explicitly re-assign stdscr in case it changed.
+ */
+ if (TAILQ_EMPTY(&_deck)) {
+ assert(PANEL_HIDDEN(&_stdscr_panel));
+
+ _stdscr_panel.win = stdscr;
+ DECK_INSERT_TOP(&_stdscr_panel);
+ }
+
+ return _new_panel(w);
+}
Index: src/lib/libpanel/panel.h
diff -u /dev/null src/lib/libpanel/panel.h:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/panel.h Mon Oct 26 23:09:49 2015
@@ -0,0 +1,62 @@
+/* $NetBSD: panel.h,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _PANEL_H_
+#define _PANEL_H_
+
+#include <sys/cdefs.h>
+#include <curses.h>
+
+typedef struct __panel PANEL;
+
+__BEGIN_DECLS
+
+PANEL *new_panel(WINDOW *);
+int del_panel(PANEL *);
+
+int replace_panel(PANEL *, WINDOW *);
+WINDOW *panel_window(PANEL *);
+
+int set_panel_userptr(PANEL *, char *);
+char *panel_userptr(PANEL *);
+
+int hide_panel(PANEL *);
+int show_panel(PANEL *);
+int panel_hidden(PANEL *);
+
+int top_panel(PANEL *);
+int bottom_panel(PANEL *);
+
+PANEL *panel_above(PANEL *);
+PANEL *panel_below(PANEL *);
+
+int move_panel(PANEL *, int, int);
+
+void update_panels(void);
+__END_DECLS
+
+#endif /* _PANEL_H_ */
Index: src/lib/libpanel/panel_impl.h
diff -u /dev/null src/lib/libpanel/panel_impl.h:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/panel_impl.h Mon Oct 26 23:09:49 2015
@@ -0,0 +1,92 @@
+/* $NetBSD: panel_impl.h,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _PANEL_IMPL_H_
+#define _PANEL_IMPL_H_
+
+#include "panel.h"
+
+#include <sys/queue.h>
+
+#define DECK_HEAD(head) TAILQ_HEAD(head, __panel)
+#define DECK_ENTRY TAILQ_ENTRY(__panel)
+
+
+/*
+ * Panels are just curses windows with Z-order added.
+ * See update_panels() for details.
+ */
+struct __panel {
+ WINDOW *win;
+ void *user;
+ DECK_ENTRY zorder;
+};
+
+
+/* Deck of panels in Z-order from bottom to top. */
+DECK_HEAD(deck);
+extern struct deck _deck __dso_hidden;
+
+/* Fake stdscr panel at the bottom, not user visible */
+extern PANEL _stdscr_panel __dso_hidden;
+
+
+/*
+ * Hidden panels are not in the deck. <sys/queue.h> macros don't have
+ * a concept of an entry not on the list, so provide a kludge that
+ * digs into internals.
+ */
+#define TAILQ_REMOVE_NP(head, elm, field) do { \
+ TAILQ_REMOVE((head), (elm), field); \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = NULL; \
+} while (/*CONSTCOND*/ 0)
+
+#define TAILQ_LINKED_NP(elm, field) \
+ (((elm)->field.tqe_prev) != NULL)
+
+
+#define DECK_INSERT_TOP(p) do { \
+ TAILQ_INSERT_TAIL(&_deck, (p), zorder); \
+} while (/*CONSTCOND*/ 0)
+
+#define DECK_INSERT_BOTTOM(p) do { \
+ TAILQ_INSERT_AFTER(&_deck, &_stdscr_panel, (p), zorder); \
+} while (/*CONSTCOND*/ 0)
+
+#define DECK_REMOVE(p) do { \
+ TAILQ_REMOVE_NP(&_deck, (p), zorder); \
+} while (/*CONSTCOND*/ 0)
+
+
+#define PANEL_ABOVE(p) (TAILQ_NEXT((p), zorder))
+#define PANEL_BELOW(p) (TAILQ_PREV((p), deck, zorder))
+#define PANEL_HIDDEN(p) (!TAILQ_LINKED_NP((p), zorder))
+
+#define FOREACH_PANEL(var) TAILQ_FOREACH(var, &_deck, zorder)
+
+#endif /* _PANEL_IMPL_H_ */
Index: src/lib/libpanel/replace.c
diff -u /dev/null src/lib/libpanel/replace.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/replace.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,53 @@
+/* $NetBSD: replace.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: replace.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+replace_panel(PANEL *p, WINDOW *w)
+{
+
+ if (__predict_false(p == NULL || w == NULL))
+ return ERR;
+
+ if (!PANEL_HIDDEN(p)) {
+ PANEL *other;
+
+ /* touch exposed areas at the old location now */
+ FOREACH_PANEL (other) {
+ if (other != p)
+ touchoverlap(p->win, other->win);
+ }
+ }
+
+ p->win = w;
+ return OK;
+}
Index: src/lib/libpanel/setuser.c
diff -u /dev/null src/lib/libpanel/setuser.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/setuser.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,42 @@
+/* $NetBSD: setuser.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: setuser.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+set_panel_userptr(PANEL *p, char *u)
+{
+ if (p == NULL)
+ return ERR;
+
+ p->user = u;
+ return OK;
+}
Index: src/lib/libpanel/shlib_version
diff -u /dev/null src/lib/libpanel/shlib_version:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/shlib_version Mon Oct 26 23:09:49 2015
@@ -0,0 +1,5 @@
+# $NetBSD: shlib_version,v 1.1 2015/10/26 23:09:49 uwe Exp $
+# Remember to update distrib/sets/lists/base/shl.* when changing
+#
+major=1
+minor=0
Index: src/lib/libpanel/show.c
diff -u /dev/null src/lib/libpanel/show.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/show.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,47 @@
+/* $NetBSD: show.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: show.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+show_panel(PANEL *p)
+{
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ /* unlike top_panel() */
+ if (__predict_false(!PANEL_HIDDEN(p)))
+ return ERR;
+
+ DECK_INSERT_TOP(p);
+ return OK;
+}
Index: src/lib/libpanel/top.c
diff -u /dev/null src/lib/libpanel/top.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/top.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,49 @@
+/* $NetBSD: top.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: top.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+int
+top_panel(PANEL *p)
+{
+
+ if (__predict_false(p == NULL))
+ return ERR;
+
+ /* unlike show_panel() */
+ if (__predict_false(PANEL_HIDDEN(p)))
+ return ERR;
+
+ /* XXX: use common internal functions instead */
+ (void) hide_panel(p);
+ (void) show_panel(p);
+ return OK;
+}
Index: src/lib/libpanel/update.c
diff -u /dev/null src/lib/libpanel/update.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/update.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,62 @@
+/* $NetBSD: update.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: update.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+void
+update_panels(void)
+{
+ PANEL *p;
+
+ /*
+ * For each panel tell panels above it they need to refresh
+ * regions that overlap (are above) this panel. This ensures
+ * that even if a panel below was touched, it's still
+ * overwritten by a panel above.
+ *
+ * Note that we also need to do this during "destructive"
+ * operations (hide, move, replace window - which see).
+ */
+ FOREACH_PANEL (p) {
+ PANEL *above = p;
+ while ((above = PANEL_ABOVE(above)) != NULL) {
+ touchoverlap(p->win, above->win);
+ }
+ }
+
+ /*
+ * This is what effects Z-order: the window updated later
+ * overwrites contents of the windows below (before) it.
+ */
+ FOREACH_PANEL (p) {
+ wnoutrefresh(p->win);
+ }
+}
Index: src/lib/libpanel/window.c
diff -u /dev/null src/lib/libpanel/window.c:1.1
--- /dev/null Mon Oct 26 23:09:50 2015
+++ src/lib/libpanel/window.c Mon Oct 26 23:09:49 2015
@@ -0,0 +1,43 @@
+/* $NetBSD: window.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */
+
+/*
+ * Copyright (c) 2015 Valery Ushakov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: window.c,v 1.1 2015/10/26 23:09:49 uwe Exp $");
+
+#include "panel_impl.h"
+
+
+WINDOW *
+panel_window(PANEL *p)
+{
+
+ if (p == NULL)
+ return NULL;
+
+ return p->win;
+}
+