]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - tack/color.c
ncurses 5.4
[ncurses.git] / tack / color.c
index 479081c9fb38a7b4a9910566cb7ddc9fdd39ca12..17f71f0b4e62ed7c9f7c279504fdfe0bd4934a0c 100644 (file)
@@ -1,18 +1,18 @@
 /*
 ** Copyright (C) 1991, 1997 Free Software Foundation, Inc.
-** 
+**
 ** This file is part of TACK.
-** 
+**
 ** TACK is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation; either version 2, or (at your option)
 ** any later version.
-** 
+**
 ** TACK is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
-** 
+**
 ** You should have received a copy of the GNU General Public License
 ** along with TACK; see the file COPYING.  If not, write to
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
@@ -21,7 +21,7 @@
 
 #include <tack.h>
 
-MODULE_ID("$Id: color.c,v 1.2 2000/03/04 21:05:54 tom Exp $")
+MODULE_ID("$Id: color.c,v 1.5 2004/01/16 23:14:25 Jochen.Voss Exp $")
 
 /*
  * Color terminal tests.  Has only one entry point: test_color().
@@ -84,6 +84,12 @@ static int a_bright_color, bright_value;
 static int cookie_monster, color_step, colors_per_line;
 static int R, G, B;
 
+static void reset_colors(void)
+{
+       tc_putp(orig_colors);
+       tc_putp(tparm(orig_pair));
+}
+
 static int
 color_trans(int c)
 {                              /* translate or load the color */
@@ -405,6 +411,7 @@ ncv_display(int m)
        put_str(alt_modes[m].name);
        eat_cookie();
        set_attr(0);
+       reset_colors();
        put_crlf();
 }
 
@@ -517,10 +524,7 @@ color_setf(
        }
        /* initialize the color palette */
        pairs_used = max_colors >= 8 ? 8 : max_colors;
-       if (can_change) {
-               tc_putp(orig_colors);
-       }
-       tc_putp(tparm(orig_pair));
+       reset_colors();
        new_color(COLOR_WHITE, COLOR_BLACK, FALSE);
 
        ptextln("(setf) (setb) (scp) The following colors are predefined:");
@@ -528,8 +532,8 @@ color_setf(
        put_crlf();
        j = max_colors > 8 ? 8 : max_colors;
        /*
-          the black on white test is the same as the white on black test.
-       */
+        * the black on white test is the same as the white on black test.
+        */
        for (i = 1; i < j; i++) {
                putchp('0' + def_colors[i].index);
                putchp(' ');
@@ -547,6 +551,7 @@ color_setf(
                new_color(COLOR_WHITE, COLOR_BLACK, FALSE);
                put_crlf();
        }
+       reset_colors();
        put_crlf();
        generic_done_message(t, state, ch);
 }
@@ -589,10 +594,10 @@ color_matrix(
                }
                for (j = 0; j < matrix_area; j++) {
                        if (j % matrix_size == 0) {
-                               tc_putp(tparm(orig_pair));
+                               reset_colors();
                                put_crlf();
                                if (brightness) {
-                                       tc_putp(exit_standout_mode);
+                                       tc_putp(exit_attribute_mode);
                                }
                                (void) sprintf(temp, "%-8s", def_colors[j / matrix_size].name);
                                put_str(temp);
@@ -605,9 +610,9 @@ color_matrix(
                                FALSE);
                        put_str("  Hello ");
                }
-               tc_putp(tparm(orig_pair));
+               reset_colors();
                if (brightness) {
-                       tc_putp(exit_standout_mode);
+                       tc_putp(exit_attribute_mode);
                }
                put_crlf();
        }
@@ -649,7 +654,7 @@ color_ncv(
                        }
                }
        }
-       tc_putp(orig_pair);
+       reset_colors();
        put_crlf();
        generic_done_message(t, state, ch);
 }
@@ -665,11 +670,11 @@ color_bce(
        int *state,
        int *ch)
 {
-       new_color(COLOR_BLACK, COLOR_WHITE, FALSE);
+       new_color(COLOR_CYAN, COLOR_BLUE, FALSE);
        put_clear();
        put_newlines(2);
-       new_color(COLOR_WHITE, COLOR_BLACK, FALSE);
-       ptextln("If the two lines above are black then back_color_erase (bce) should be false.");
+       reset_colors();
+       ptextln("If the two lines above are blue then back_color_erase (bce) should be true.");
        sprintf(temp, "(bce) is %s in the data base.", back_color_erase ? "true" : "false");
        ptextln(temp);
        generic_done_message(t, state, ch);
@@ -693,7 +698,7 @@ color_ccc(
                generic_done_message(t, state, ch);
                return;
        }
-       tc_putp(orig_colors);
+       reset_colors();
        pairs_used = 0;
        new_color(COLOR_WHITE, COLOR_BLACK, FALSE);
        sprintf(temp, "Reloading colors (init%c) using %s method",
@@ -721,8 +726,7 @@ color_ccc(
        }
        generic_done_message(t, state, ch);
        if (*ch != 0 && *ch != 'n') {
-               tc_putp(orig_colors);
-               tc_putp(tparm(orig_pair));
+               reset_colors();
                return;
        }
 
@@ -756,12 +760,10 @@ color_ccc(
        }
        generic_done_message(t, state, ch);
        if (*ch != 0 && *ch != 'n') {
-               tc_putp(orig_colors);
-               tc_putp(tparm(orig_pair));
+               reset_colors();
                return;
        }
        dump_colors();
-       tc_putp(orig_colors);
-       tc_putp(tparm(orig_pair));
+       reset_colors();
        generic_done_message(t, state, ch);
 }