Source-Changes-HG archive

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

[src/trunk]: src/lib/libcurses Add a hack for xterm-like terminals where "\E[...



details:   https://anonhg.NetBSD.org/src/rev/023d294413e4
branches:  trunk
changeset: 536221:023d294413e4
user:      jdc <jdc%NetBSD.org@localhost>
date:      Wed Sep 11 15:23:24 2002 +0000

description:
Add a hack for xterm-like terminals where "\E[m" will turn off
other attributes.

diffstat:

 lib/libcurses/setterm.c |  48 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 33 insertions(+), 15 deletions(-)

diffs (110 lines):

diff -r 76b132585b66 -r 023d294413e4 lib/libcurses/setterm.c
--- a/lib/libcurses/setterm.c   Wed Sep 11 14:55:55 2002 +0000
+++ b/lib/libcurses/setterm.c   Wed Sep 11 15:23:24 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: setterm.c,v 1.32 2002/06/26 18:14:07 christos Exp $    */
+/*     $NetBSD: setterm.c,v 1.33 2002/09/11 15:23:24 jdc Exp $ */
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)setterm.c  8.8 (Berkeley) 10/25/94";
 #else
-__RCSID("$NetBSD: setterm.c,v 1.32 2002/06/26 18:14:07 christos Exp $");
+__RCSID("$NetBSD: setterm.c,v 1.33 2002/09/11 15:23:24 jdc Exp $");
 #endif
 #endif /* not lint */
 
@@ -114,6 +114,8 @@
 
 attr_t  __mask_op, __mask_me, __mask_ue, __mask_se;
 
+const char *__attroff = "\x1b[m";
+
 int
 setterm(char *type)
 {
@@ -222,53 +224,69 @@
            ((screen->tc_AL == NULL && screen->tc_al == NULL) ||
             (screen->tc_DL == NULL && screen->tc_dl == NULL));
 
-       /* Precalculate conflict info for color/attribute end commands. */
+       /*
+        * Precalculate conflict info for color/attribute end commands.
+        * Add a hack for xterm-like terminals where "\E[m" will turn off
+        * other attributes.
+        */
        screen->mask_op = __ATTRIBUTES & ~__COLOR;
        if (screen->tc_op != NULL) {
                if (screen->tc_se != NULL &&
-                   !strcmp(screen->tc_op, screen->tc_se))
+                   (!strcmp(screen->tc_op, screen->tc_se) ||
+                   !strcmp(screen->tc_op, __attroff)))
                        screen->mask_op &= ~__STANDOUT;
                if (screen->tc_ue != NULL &&
-                   !strcmp(screen->tc_op, screen->tc_ue))
+                   (!strcmp(screen->tc_op, screen->tc_ue) ||
+                   !strcmp(screen->tc_op, __attroff)))
                        screen->mask_op &= ~__UNDERSCORE;
                if (screen->tc_me != NULL &&
-                   !strcmp(screen->tc_op, screen->tc_me))
+                   (!strcmp(screen->tc_op, screen->tc_me) ||
+                   !strcmp(screen->tc_op, __attroff)))
                        screen->mask_op &= ~__TERMATTR;
        }
        screen->mask_me = __ATTRIBUTES & ~__TERMATTR;
        if (screen->tc_me != NULL) {
                if (screen->tc_se != NULL &&
-                   !strcmp(screen->tc_me, screen->tc_se))
+                   (!strcmp(screen->tc_me, screen->tc_se) ||
+                   !strcmp(screen->tc_me, __attroff)))
                        screen->mask_me &= ~__STANDOUT;
                if (screen->tc_ue != NULL &&
-                   !strcmp(screen->tc_me, screen->tc_ue))
+                   (!strcmp(screen->tc_me, screen->tc_ue) ||
+                   !strcmp(screen->tc_me, __attroff)))
                        screen->mask_me &= ~__UNDERSCORE;
                if (screen->tc_op != NULL &&
-                   !strcmp(screen->tc_me, screen->tc_op))
+                   (!strcmp(screen->tc_me, screen->tc_op) ||
+                   !strcmp(screen->tc_me, __attroff)))
                        screen->mask_me &= ~__COLOR;
        }
        screen->mask_ue = __ATTRIBUTES & ~__UNDERSCORE;
        if (screen->tc_ue != NULL) {
                if (screen->tc_se != NULL &&
-                   !strcmp(screen->tc_ue, screen->tc_se))
+                   (!strcmp(screen->tc_ue, screen->tc_se) ||
+                   !strcmp(screen->tc_ue, __attroff)))
                        screen->mask_ue &= ~__STANDOUT;
                if (screen->tc_me != NULL &&
-                   !strcmp(screen->tc_ue, screen->tc_me))
+                   (!strcmp(screen->tc_ue, screen->tc_me) ||
+                   !strcmp(screen->tc_ue, __attroff)))
                        screen->mask_ue &= ~__TERMATTR;
                if (screen->tc_op != NULL &&
-                   !strcmp(screen->tc_ue, screen->tc_op))
+                   (!strcmp(screen->tc_ue, screen->tc_op) ||
+                   !strcmp(screen->tc_ue, __attroff)))
                        screen->mask_ue &= ~__COLOR;
        }
        screen->mask_se = __ATTRIBUTES & ~__STANDOUT;
        if (screen->tc_se != NULL) {
                if (screen->tc_ue != NULL &&
-                   !strcmp(screen->tc_se, screen->tc_ue))
+                   (!strcmp(screen->tc_se, screen->tc_ue) ||
+                   !strcmp(screen->tc_se, __attroff)))
                        screen->mask_se &= ~__UNDERSCORE;
                if (screen->tc_me != NULL &&
-                   !strcmp(screen->tc_se, screen->tc_me))
+                   (!strcmp(screen->tc_se, screen->tc_me) ||
+                   !strcmp(screen->tc_se, __attroff)))
                        screen->mask_se &= ~__TERMATTR;
                if (screen->tc_op != NULL &&
-                   !strcmp(screen->tc_se, screen->tc_op))
+                   (!strcmp(screen->tc_se, screen->tc_op) ||
+                   !strcmp(screen->tc_se, __attroff)))
                        screen->mask_se &= ~__COLOR;
        }
 



Home | Main Index | Thread Index | Old Index