Package: cdebconf
Severity: normal
Tags: patch

Hi,

the attached patch changes colors in the newt frontend when
bg=dark is entered on command-line prompt, to provide a
white-on-black theme.  This is an accessibility issue, some
people can hardly read on a white background.
Ok to commit?

Denis
Index: debian/changelog
===================================================================
--- debian/changelog    (revision 31022)
+++ debian/changelog    (working copy)
@@ -1,9 +1,15 @@
 cdebconf (0.88) UNRELEASED; urgency=low
 
+  [ Colin Watson ]
   * Remove hardcoded limit on length of DATA commands.
 
- -- Colin Watson <[EMAIL PROTECTED]>  Mon, 26 Sep 2005 15:15:43 +0100
+  [ Denis Barbier ]
+  * Change colors in the newt frontend to have a black background if the
+    bg environment variable is set to "dark".  Some people can hardly
+    read on a white background.
 
+ -- Denis Barbier <[EMAIL PROTECTED]>  Tue, 27 Sep 2005 23:20:07 +0200
+
 cdebconf (0.87) unstable; urgency=low
 
   [ Attilio Fiandrotti ]
Index: src/modules/frontend/newt/newt.c
===================================================================
--- src/modules/frontend/newt/newt.c    (revision 31022)
+++ src/modules/frontend/newt/newt.c    (working copy)
@@ -72,6 +72,41 @@
     int           scale_textbox_height;
 };
 
+struct newtColors newtAltColorPalette = {
+       "white", "blue",                        /* root fg, bg */
+       /*"black", "lightgray",*/                       /* border fg, bg */
+       "white", "black",                       /* border fg, bg */
+       /*"black", "lightgray",*/                       /* window fg, bg */
+       "white", "black",                       /* window fg, bg */
+       /*"white", "black",*/                   /* shadow fg, bg */
+       "white", "blue",                        /* shadow fg, bg */
+       /*"red", "lightgray",*/                 /* title fg, bg */
+       "yellow", "black",                      /* title fg, bg */
+       "lightgray", "red",                     /* button fg, bg */
+       "red", "lightgray",                     /* active button fg, bg */
+       "yellow", "blue",                       /* checkbox fg, bg */
+       "blue", "brown",                        /* active checkbox fg, bg */
+       "yellow", "blue",                       /* entry box fg, bg */
+       /*"blue", "lightgray",*/                        /* label fg, bg */
+       "brightred", "black",                   /* label fg, bg */
+       /*"black", "lightgray",*/                       /* listbox fg, bg */
+       "lightgray", "black",                   /* listbox fg, bg */
+       "yellow", "blue",                       /* active listbox fg, bg */
+       /*"black", "lightgray",*/                       /* textbox fg, bg */
+       "white", "black",                       /* textbox fg, bg */
+       "lightgray", "black",                   /* active textbox fg, bg */
+       /*"white", "blue",*/                    /* help line */
+       "white", "black",                       /* help line */
+       "yellow", "blue",                       /* root text */
+       "blue",                                 /* scale full */
+       "red",                                  /* scale empty */
+       "blue", "lightgray",                    /* disabled entry fg, bg */
+       /*"black", "lightgray",*/                       /* compact button fg, 
bg */
+       "lightgray", "black",                   /* compact button fg, bg */
+       "yellow", "red",                        /* active & sel listbox */
+       "black", "brown"                        /* selected listbox */
+};
+
 typedef int (newt_handler)(struct frontend *obj, struct question *q);
 
 #define q_get_extended_description(q)   question_get_field((q), "", 
"extended_description")
@@ -957,15 +992,19 @@
 static int
 newt_handler_error(struct frontend *obj, struct question *q)
 {
-    char *oldcolor;
+    char *oldrootBg, *oldshadowBg;
     int ret;
-    struct newtColors palette = newtDefaultColorPalette;
+    struct newtColors palette = newtAltColorPalette;
 
-    oldcolor = palette.rootBg;
+    oldrootBg = palette.rootBg;
+    oldshadowBg = palette.shadowBg;
+    if (strcmp(oldrootBg, oldshadowBg) == 0)
+       palette.shadowBg = "red";
     palette.rootBg = "red";
     newtSetColors(palette);
     ret = newt_handler_note(obj, q);
-    palette.rootBg = oldcolor;
+    palette.rootBg = oldrootBg;
+    palette.shadowBg = oldshadowBg;
     newtSetColors(palette);
     return ret;
 }
@@ -1001,11 +1040,16 @@
 newt_initialize(struct frontend *obj, struct configuration *conf)
 {
     int i, width = 80, height = 24;
+    const char *palette;
 
     obj->interactive = 1;
     obj->data = calloc(1, sizeof(struct newt_data));
     SLang_init_tty(0, 1, 0); /* disable flow control */
     newtInit();
+    palette = getenv("bg");
+    if (palette == NULL || strcmp(palette, "dark") != 0)
+        newtAltColorPalette = newtDefaultColorPalette;
+    newtSetColors(newtAltColorPalette);
     newtGetScreenSize(&width, &height);
     // Fill the screen so people can shift-pgup properly
     for (i = 0; i < height; i++)
@@ -1053,6 +1097,7 @@
                     cleared = 1;
                     SLang_init_tty(0, 1, 0); /* disable flow control */
                     newtInit();
+                    newtSetColors(newtAltColorPalette);
                     newtCls();
                 }
                 if (obj->info != NULL) {
@@ -1112,6 +1157,7 @@
     obj->progress_cur = min;
     SLang_init_tty(0, 1, 0); /* disable flow control */
     newtInit();
+    newtSetColors(newtAltColorPalette);
     newtCls();
     if (obj->info != NULL) {
         char *text = q_get_description(obj->info);

Reply via email to