Source-Changes-HG archive

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

[src/curses-v3]: src/lib/libcurses wborder() implementation - draw border aro...



details:   https://anonhg.NetBSD.org/src/rev/a3d528429596
branches:  curses-v3
changeset: 479967:a3d528429596
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sun Mar 05 23:26:12 2000 +0000

description:
wborder() implementation - draw border around window, c.f. box().

diffstat:

 lib/libcurses/border.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diffs (118 lines):

diff -r 21ab44775479 -r a3d528429596 lib/libcurses/border.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libcurses/border.c    Sun Mar 05 23:26:12 2000 +0000
@@ -0,0 +1,114 @@
+/*     $NetBSD: border.c,v 1.1.2.1 2000/03/05 23:26:12 jdc Exp $       */
+
+/*
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Julian Coleman.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 "curses.h"
+
+/*
+ * wborder --
+ *     Draw a border around the given window using the specified delimiting
+ *     characters.
+ */
+int
+wborder(win, left, right, top, bottom, topleft, topright, botleft, botright)
+       WINDOW  *win;
+       chtype   left, right, top, bottom;
+       chtype   topleft, topright, botleft, botright;
+{
+       int      endy, endx, i;
+       __LDATA *fp, *lp;
+
+       if (!(left & __CHARTEXT)) left = ACS_VLINE;
+       if (!(right & __CHARTEXT)) right = ACS_VLINE;
+       if (!(top & __CHARTEXT)) top = ACS_HLINE;
+       if (!(bottom & __CHARTEXT)) bottom = ACS_HLINE;
+       if (!(topleft & __CHARTEXT)) topleft = ACS_ULCORNER;
+       if (!(topright & __CHARTEXT)) topright = ACS_URCORNER;
+       if (!(botleft & __CHARTEXT)) botleft = ACS_LLCORNER;
+       if (!(botright & __CHARTEXT)) botright = ACS_LRCORNER;
+
+#ifdef DEBUG
+       __CTRACE("wborder: left = %c%s", left,
+           left & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: right = %c%s", right,
+           right & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: top = %c%s", top,
+           top & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: bottom = %c%s", bottom,
+           bottom & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: topleft = %c%s", topleft,
+           topleft & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: topright = %c%s", topright,
+           topright & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: botleft = %c%s", botleft,
+           botleft & __ALTCHARSET ? " (A)\n" : "\n");
+       __CTRACE("wborder: botright = %c%s", botright,
+           botright & __ALTCHARSET ? " (A)\n" : "\n");
+#endif
+       endx = win->maxx - 1;
+       endy = win->maxy - 1;
+       fp = win->lines[0]->line;
+       lp = win->lines[endy]->line;
+
+       /* Sides */
+       for (i = 1; i < endy; i++) {
+               win->lines[i]->line[0].ch = (wchar_t) left & __CHARTEXT;
+               win->lines[i]->line[0].attr = (attr_t) left & __ATTRIBUTES;
+               win->lines[i]->line[endx].ch = (wchar_t) right & __CHARTEXT;
+               win->lines[i]->line[endx].attr = (attr_t) right & __ATTRIBUTES;
+       }
+       for (i = 1; i < endx; i++) {
+               fp[i].ch = (wchar_t) top & __CHARTEXT;
+               fp[i].attr = (attr_t) top & __ATTRIBUTES;
+               lp[i].ch = (wchar_t) bottom & __CHARTEXT;
+               lp[i].attr = (attr_t) bottom & __ATTRIBUTES;
+       }
+
+       /* Corners */
+       if (!(win->flags & __SCROLLOK) && (win->flags & __SCROLLWIN)) {
+               fp[0].ch = (wchar_t) topleft & __CHARTEXT;
+               fp[0].attr = (attr_t) topleft & __ATTRIBUTES;
+               fp[endx].ch = (wchar_t) topright & __CHARTEXT;
+               fp[endx].attr = (attr_t) topright & __ATTRIBUTES;
+               lp[0].ch = (wchar_t) botleft & __CHARTEXT;
+               lp[0].attr = (attr_t) botleft & __ATTRIBUTES;
+               lp[endx].ch = (wchar_t) botright & __CHARTEXT;
+               lp[endx].attr = (attr_t) botright & __ATTRIBUTES;
+       }
+       __touchwin(win);
+       return (OK);
+}



Home | Main Index | Thread Index | Old Index