Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Add support for background characters and attr...



details:   https://anonhg.NetBSD.org/src/rev/25b641bd5acf
branches:  trunk
changeset: 485093:25b641bd5acf
user:      jdc <jdc%NetBSD.org@localhost>
date:      Tue Apr 18 22:47:01 2000 +0000

description:
Add support for background characters and attributes.
Add extra colour/attributes debugging.

diffstat:

 lib/libcurses/refresh.c |  323 ++++++++++++++++++++++++++++++++---------------
 1 files changed, 216 insertions(+), 107 deletions(-)

diffs (truncated from 512 to 300 lines):

diff -r 0a97887c89dd -r 25b641bd5acf lib/libcurses/refresh.c
--- a/lib/libcurses/refresh.c   Tue Apr 18 22:45:23 2000 +0000
+++ b/lib/libcurses/refresh.c   Tue Apr 18 22:47:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: refresh.c,v 1.19 2000/04/16 09:55:16 jdc Exp $ */
+/*     $NetBSD: refresh.c,v 1.20 2000/04/18 22:47:01 jdc Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)refresh.c  8.7 (Berkeley) 8/13/94";
 #else
-__RCSID("$NetBSD: refresh.c,v 1.19 2000/04/16 09:55:16 jdc Exp $");
+__RCSID("$NetBSD: refresh.c,v 1.20 2000/04/18 22:47:01 jdc Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -104,19 +104,54 @@
                                    (int) (win->maxx * __LDATASIZE));
                }
 
-       if (win->flags & __CLEAROK || curscr->flags & __CLEAROK || curwin) {
+       if ((win->flags & __CLEAROK) || (curscr->flags & __CLEAROK) || curwin) {
                if ((win->flags & __FULLWIN) || curscr->flags & __CLEAROK) {
-                       /* XXX: check for background colour and bce here */
-                       tputs(CL, 0, __cputchar);
-                       ly = 0;
-                       lx = 0;
-                       if (!curwin) {
-                               curscr->flags &= ~__CLEAROK;
-                               curscr->cury = 0;
-                               curscr->curx = 0;
-                               werase(curscr);
+                       if ((!(win->battr & __COLOR) ||
+                           ((win->battr & __COLOR) && BE)) &&
+                           win->bch == ' ') {
+                               if (win->battr & __COLOR) {
+                                       if ((win->battr & __COLOR) !=
+                                       (curscr->wattr & __COLOR)) {
+                                               __set_color(win->battr);
+                                               curscr->wattr &= ~__COLOR;
+                                               curscr->wattr |= win->battr &
+                                                   __COLOR;
+                                       }
+                               } else if (curscr->wattr & __COLOR) {
+                                       if (OC != NULL && CC == NULL)
+                                               tputs(OC, 0, __cputchar);
+                                       if (OP != NULL) {
+                                               tputs(OP, 0, __cputchar);
+                                               if (SE != NULL &&
+                                                   !strcmp(OP, SE))
+                                                       curscr->wattr &=
+                                                           ~__STANDOUT;
+                                               if (UE != NULL &&
+                                                   !strcmp(OP, UE))
+                                                       curscr->wattr &=
+                                                           ~__UNDERSCORE;
+                                               if (ME != NULL &&
+                                                   !strcmp(OP, ME))
+                                                       curscr->wattr &=
+                                                           ~__TERMATTR;
+                                       }
+                                       curscr->wattr &= ~__COLOR;
+                               }
+                               tputs(CL, 0, __cputchar);
+                               ly = 0;
+                               lx = 0;
+                               if (!curwin) {
+                                       curscr->flags &= ~__CLEAROK;
+                                       curscr->cury = 0;
+                                       curscr->curx = 0;
+                                       werase(curscr);
+                               }
+                               __touchwin(win);
+                       } else {
+                               if (!curwin)
+                                       curscr->flags &= ~__CLEAROK;
+                               touchwin(win);
                        }
-                       __touchwin(win);
                }
                win->flags &= ~__CLEAROK;
        }
@@ -174,6 +209,11 @@
                                        __CTRACE(" %x", win->lines[i - win
                                            ->begy]->line[j].attr);
                                __CTRACE("\n");
+                               __CTRACE(" battr:");
+                               for (j = 0; j < win->maxx; j++)
+                                       __CTRACE(" %x", win->lines[i - win
+                                           ->begy]->line[j].battr);
+                               __CTRACE("\n");
                        }
                }
        }
@@ -259,6 +299,7 @@
        int     clsp, nlsp;     /* Last space in lines. */
        int     lch, wx, y;
        char    *ce;
+       attr_t  lspb;           /* Last space background colour */
 
 #ifdef __GNUC__
        nlsp = 0;               /* XXX gcc -Wuninitialized */
@@ -291,10 +332,15 @@
        nsp = &win->lines[wy]->line[wx];
        force = win->lines[wy]->flags & __FORCEPAINT;
        win->lines[wy]->flags &= ~__FORCEPAINT;
+       /* XXX: Check for background character here */
        if (CE && !curwin) {
-               for (cp = &win->lines[wy]->line[win->maxx - 1];
-                   cp->ch == ' ' && cp->attr == 0; cp--)
-                       if (cp <= win->lines[wy]->line)
+               cp = &win->lines[wy]->line[win->maxx - 1];
+               if (cp->attr & __COLOR)
+                       lspb = cp->attr & __COLOR;
+               else
+                       lspb = cp->battr & __COLOR;
+               while (cp->ch == ' ' && cp->attr == lspb && cp->battr == lspb)
+                       if (cp-- <= win->lines[wy]->line)
                                break;
                nlsp = cp - win->lines[wy]->line;
        }
@@ -342,19 +388,28 @@
                            wx >= nlsp && nsp->ch == ' ' && nsp->attr == 0) {
                                /* Check for clear to end-of-line. */
                                cep = &curscr->lines[wy]->line[win->maxx - 1];
-                               while (cep->ch == ' ' && cep->attr == 0)
+                               while (cep->ch == ' ' && cep->attr == lspb)
                                        if (cep-- <= csp)
                                                break;
                                clsp = cep - curscr->lines[wy]->line -
                                    win->begx * __LDATASIZE;
 #ifdef DEBUG
-                               __CTRACE("makech: clsp = %d, nlsp = %d\n", clsp, nlsp);
+                               __CTRACE("makech: clsp = %d, nlsp = %d\n",
+                                   clsp, nlsp);
 #endif
-                               /* XXX: check for background colour and bce here */
-                               if ((clsp - nlsp >= strlen(CE)
-                                   && clsp < win->maxx * __LDATASIZE) ||
-                                   wy == win->maxy - 1) {
+                               if (((clsp - nlsp >= strlen(CE) &&
+                                   clsp < win->maxx * __LDATASIZE) ||
+                                   wy == win->maxy - 1) &&
+                                   (!(lspb & __COLOR) ||
+                                   ((lspb & __COLOR) && BE)) &&
+                                   win->bch == ' ') {
                                        unsetattr(0);
+                                       if ((lspb & __COLOR) !=
+                                           (curscr->wattr & __COLOR)) {
+                                               __set_color(lspb);
+                                               curscr->wattr &= ~__COLOR;
+                                               curscr->wattr |= lspb & __COLOR;
+                                       }
                                        tputs(CE, 0, __cputchar);
                                        lx = wx + win->begx;
                                        while (wx++ <= clsp) {
@@ -373,17 +428,24 @@
                         * attributes.
                         */
                        if (!(nsp->attr & __COLOR) &&
+                           !(nsp->battr & __COLOR) &&
                            (curscr->wattr & __COLOR)) {
                                        if (OC != NULL && CC == NULL)
                                                tputs(OC, 0, __cputchar);
                                        if (OP != NULL) {
                                                tputs(OP, 0, __cputchar);
-                                               if (SE != NULL && !strcmp(OP, SE))
-                                                       curscr->wattr &= ~__STANDOUT;
-                                               if (UE != NULL && !strcmp(OP, UE))
-                                                       curscr->wattr &= ~__UNDERSCORE;
-                                               if (ME != NULL && !strcmp(OP, ME))
-                                                       curscr->wattr &= ~__ATTRIBUTES | __ALTCHARSET | __COLOR;
+                                               if (SE != NULL &&
+                                                   !strcmp(OP, SE))
+                                                       curscr->wattr &=
+                                                           ~__STANDOUT;
+                                               if (UE != NULL &&
+                                                   !strcmp(OP, UE))
+                                                       curscr->wattr &=
+                                                           ~__UNDERSCORE;
+                                               if (ME != NULL &&
+                                                   !strcmp(OP, ME))
+                                                       curscr->wattr &=
+                                                           ~__TERMATTR;
                                        }
                                        curscr->wattr &= ~__COLOR;
                                }
@@ -395,21 +457,11 @@
                         * 'mp' and 'mr').  Check to see if we also turn off
                         * standout, attributes and colour.
                         */
-                       if ((!(nsp->attr & __BLINK) &&
-                           curscr->wattr & __BLINK) ||
-                           (!(nsp->attr & __BOLD) &&
-                           curscr->wattr & __BOLD) ||
-                           (!(nsp->attr & __DIM) &&
-                           curscr->wattr & __DIM) ||
-                           (!(nsp->attr & __BLANK) &&
-                           curscr->wattr & __BLANK) ||
-                           (!(nsp->attr & __PROTECT) &&
-                           curscr->wattr & __PROTECT) ||
-                           (!(nsp->attr & __REVERSE) &&
-                           curscr->wattr & __REVERSE)) {
+                       if (((nsp->attr & __TERMATTR) |
+                           (nsp->battr & __TERMATTR)) !=
+                           (curscr->wattr & __TERMATTR)) {
                                tputs(ME, 0, __cputchar);
-                               curscr->wattr &= ~__ATTRIBUTES | __ALTCHARSET
-                                   | __COLOR;
+                               curscr->wattr &= ~__TERMATTR;
                                if (SE != NULL && !strcmp(ME, SE))
                                        curscr->wattr &= ~__STANDOUT;
                                if (UE != NULL && !strcmp(ME, UE))
@@ -424,14 +476,14 @@
                         * attributes and colour.
                         */
                        if (!(nsp->attr & __UNDERSCORE) &&
+                           !(nsp->battr & __UNDERSCORE) &&
                            (curscr->wattr & __UNDERSCORE)) {
                                tputs(UE, 0, __cputchar);
                                curscr->wattr &= ~__UNDERSCORE;
                                if (SE != NULL && !strcmp(UE, SE))
                                        curscr->wattr &= ~__STANDOUT;
                                if (ME != NULL && !strcmp(UE, ME))
-                                       curscr->wattr &= ~__ATTRIBUTES |
-                                           __ALTCHARSET | __COLOR;
+                                       curscr->wattr &= ~__TERMATTR;
                                if (OP != NULL && !strcmp(UE, OP))
                                        curscr->wattr &= ~__COLOR;
                        }
@@ -443,7 +495,8 @@
                         * XXX
                         * Should use UC if SO/SE not available.
                         */
-                       if (nsp->attr & __STANDOUT) {
+                       if ((nsp->attr & __STANDOUT) ||
+                           (nsp->battr & __STANDOUT)) {
                                if (!(curscr->wattr & __STANDOUT) &&
                                    SO != NULL && SE != NULL) {
                                        tputs(SO, 0, __cputchar);
@@ -457,8 +510,7 @@
                                                curscr->wattr &=
                                                    ~__UNDERSCORE;
                                        if (ME != NULL && !strcmp(SE, ME))
-                                               curscr->wattr &= ~__ATTRIBUTES |
-                                                   __ALTCHARSET | __COLOR;
+                                               curscr->wattr &= ~__TERMATTR;
                                        if (OP != NULL && !strcmp(SE, OP))
                                                curscr->wattr &= ~__COLOR;
                                }
@@ -469,7 +521,8 @@
                         * XXX
                         * Should use UC if US/UE not available.
                         */
-                       if (nsp->attr & __UNDERSCORE &&
+                       if (((nsp->attr & __UNDERSCORE) ||
+                           (nsp->battr & __UNDERSCORE)) &&
                            !(curscr->wattr & __UNDERSCORE) &&
                            US != NULL && UE != NULL) {
                                tputs(US, 0, __cputchar);
@@ -479,63 +532,75 @@
                        /*
                         * Set other attributes as appropriate.
                         */
-                       if (nsp->attr & __BLINK) {
-                               if (!(curscr->wattr & __BLINK) &&
-                                   MB != NULL && ME != NULL) {
-                                       tputs(MB, 0, __cputchar);
-                                       curscr->wattr |= __BLINK;
-                               }
+                       if (((nsp->attr & __BLINK) ||
+                           (nsp->battr & __BLINK)) &&
+                           !(curscr->wattr & __BLINK) &&
+                           MB != NULL && ME != NULL) {
+                               tputs(MB, 0, __cputchar);
+                               curscr->wattr |= __BLINK;
                        }
-                       if (nsp->attr & __BOLD) {
-                               if (!(curscr->wattr & __BOLD) &&
-                                   MD != NULL && ME != NULL) {
-                                       tputs(MD, 0, __cputchar);
-                                       curscr->wattr |= __BOLD;
-                               }
+                       if (((nsp->attr & __BOLD) ||
+                           (nsp->battr & __BOLD)) &&
+                           !(curscr->wattr & __BOLD) &&
+                           MD != NULL && ME != NULL) {
+                               tputs(MD, 0, __cputchar);
+                               curscr->wattr |= __BOLD;
                        }
-                       if (nsp->attr & __DIM) {
-                               if (!(curscr->wattr & __DIM) &&
-                                   MH != NULL && ME != NULL) {
-                                       tputs(MH, 0, __cputchar);
-                                       curscr->wattr |= __DIM;
-                               }
+                       if (((nsp->attr & __DIM) ||
+                           (nsp->battr & __DIM)) &&



Home | Main Index | Thread Index | Old Index