ncurses 6.1 - patch 20180203
[ncurses.git] / test / savescreen.c
index 722e4bb584ced4009ebdab983112e96da51a303b..610b86d041bd1dd07730b7d63fd03099c80ecdbb 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: savescreen.c,v 1.51 2018/01/14 17:39:47 tom Exp $
+ * $Id: savescreen.c,v 1.52 2018/02/03 23:18:50 tom Exp $
  *
  * Demonstrate save/restore functions from the curses library.
  * Thomas Dickey - 2007/7/14
@@ -34,6 +34,7 @@
 
 #include <test.priv.h>
 #include <popup_msg.h>
+#include <parse_rgb.h>
 
 #if HAVE_SCR_DUMP
 
@@ -374,37 +375,37 @@ main(int argc, char *argv[])
                    init_pair((short) (n + MAX_ANSI), (short) n, (short) n);
            }
 #if HAVE_TIGETSTR && USE_WIDEC_SUPPORT
-           else if (tigetflag("RGB") > 0) {
-               int rows = LINES - 1;
-               int cols = COLS - 1;
-               /* FIXME: test all 3 types of capability */
-               int b_max = 255;
-               int r_max = 255;
-               int g_max = 255;
-               int b_delta = (b_max / rows);
-               int r_delta = (r_max / cols);
-               int g_delta = (g_max / cols);
-               int row = 0;
-
-               b = 0;
-               using_rgb = TRUE;
-               while (row++ < rows) {
-                   int col = 0;
-                   r = 0;
-                   g = g_max;
-                   while (col++ < cols) {
-                       int color = (((r * (g_max + 1)) + g) * (b_max + 1)
-                                    + b + MAX_ANSI);
+           else {
+               int r_max, g_max, b_max;
+
+               if (parse_rgb(&r_max, &g_max, &b_max) > 0) {
+                   int rows = LINES - 1;
+                   int cols = COLS - 1;
+                   int b_delta = (b_max / rows);
+                   int r_delta = (r_max / cols);
+                   int g_delta = (g_max / cols);
+                   int row = 0;
+
+                   b = 0;
+                   using_rgb = TRUE;
+                   while (row++ < rows) {
+                       int col = 0;
+                       r = 0;
+                       g = g_max;
+                       while (col++ < cols) {
+                           int color = (((r * (g_max + 1)) + g) * (b_max + 1)
+                                        + b + MAX_ANSI);
 #if HAVE_INIT_EXTENDED_COLOR
-                       init_extended_pair(pair, color, color);
+                           init_extended_pair(pair, color, color);
 #else
-                       init_pair(pair, color, color);
+                           init_pair(pair, color, color);
 #endif
-                       pair++;
-                       r += r_delta;
-                       g -= g_delta;
+                           pair++;
+                           r += r_delta;
+                           g -= g_delta;
+                       }
+                       b += b_delta;
                    }
-                   b += b_delta;
                }
            }
 #endif