Source-Changes-HG archive

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

[src/trunk]: src/lib/libpanel First cut at ETI libpanel. Lacks man pages and...



details:   https://anonhg.NetBSD.org/src/rev/17da896b997b
branches:  trunk
changeset: 811364:17da896b997b
user:      uwe <uwe%NetBSD.org@localhost>
date:      Mon Oct 26 23:09:49 2015 +0000

description:
First cut at ETI libpanel.  Lacks man pages and tests.
Not hooked into the build yet.

diffstat:

 lib/libpanel/Makefile      |  31 +++++++++++++++
 lib/libpanel/_deck.c       |  34 +++++++++++++++++
 lib/libpanel/above.c       |  45 ++++++++++++++++++++++
 lib/libpanel/below.c       |  50 +++++++++++++++++++++++++
 lib/libpanel/bottom.c      |  48 ++++++++++++++++++++++++
 lib/libpanel/del.c         |  63 +++++++++++++++++++++++++++++++
 lib/libpanel/getuser.c     |  41 ++++++++++++++++++++
 lib/libpanel/hidden.c      |  45 ++++++++++++++++++++++
 lib/libpanel/hide.c        |  56 ++++++++++++++++++++++++++++
 lib/libpanel/move.c        |  58 +++++++++++++++++++++++++++++
 lib/libpanel/new.c         |  75 +++++++++++++++++++++++++++++++++++++
 lib/libpanel/panel.h       |  62 +++++++++++++++++++++++++++++++
 lib/libpanel/panel_impl.h  |  92 ++++++++++++++++++++++++++++++++++++++++++++++
 lib/libpanel/replace.c     |  53 ++++++++++++++++++++++++++
 lib/libpanel/setuser.c     |  42 +++++++++++++++++++++
 lib/libpanel/shlib_version |   5 ++
 lib/libpanel/show.c        |  47 +++++++++++++++++++++++
 lib/libpanel/top.c         |  49 ++++++++++++++++++++++++
 lib/libpanel/update.c      |  62 +++++++++++++++++++++++++++++++
 lib/libpanel/window.c      |  43 +++++++++++++++++++++
 20 files changed, 1001 insertions(+), 0 deletions(-)

diffs (truncated from 1081 to 300 lines):

diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/Makefile     Mon Oct 26 23:09:49 2015 +0000
@@ -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>
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/_deck.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/_deck.c      Mon Oct 26 23:09:49 2015 +0000
@@ -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;
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/above.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/above.c      Mon Oct 26 23:09:49 2015 +0000
@@ -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);
+}
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/below.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/below.c      Mon Oct 26 23:09:49 2015 +0000
@@ -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;
+}
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/bottom.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/bottom.c     Mon Oct 26 23:09:49 2015 +0000
@@ -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;
+}
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/del.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/del.c        Mon Oct 26 23:09:49 2015 +0000
@@ -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;
+}
diff -r e3f17eb78c74 -r 17da896b997b lib/libpanel/getuser.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libpanel/getuser.c    Mon Oct 26 23:09:49 2015 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: getuser.c,v 1.1 2015/10/26 23:09:49 uwe Exp $ */



Home | Main Index | Thread Index | Old Index