X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fsavescreen.c;h=408020a6a958f2673794140f3486ff5d86cbc866;hp=911c62fc0d1c76102ec73dfd91cd26abaa741991;hb=119b5a6788c26bf7dcc99fcfd54e072946352a93;hpb=bca50d0d8592defee6c584fdedd25f4b1a31345b diff --git a/test/savescreen.c b/test/savescreen.c index 911c62fc..408020a6 100644 --- a/test/savescreen.c +++ b/test/savescreen.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 2007-2017,2018 Free Software Foundation, Inc. * + * Copyright (c) 2007-2018,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,31 +26,22 @@ * authorization. * ****************************************************************************/ /* - * $Id: savescreen.c,v 1.50 2018/01/07 02:24:03 tom Exp $ + * $Id: savescreen.c,v 1.55 2019/01/20 15:59:28 tom Exp $ * * Demonstrate save/restore functions from the curses library. * Thomas Dickey - 2007/7/14 */ +#define NEED_TIME_H #include #include +#include #if HAVE_SCR_DUMP #include #include -#if TIME_WITH_SYS_TIME -# include -# include -#else -# if HAVE_SYS_TIME_H -# include -# else -# include -# endif -#endif - #if defined(__hpux) #define MyMarker 'X' #else @@ -68,10 +59,12 @@ static wchar_t BaseChar(cchar_t data) { wchar_t my_wchar[CCHARW_MAX]; + wchar_t result = 0; attr_t my_attr; short my_pair; - getcchar(&data, my_wchar, &my_attr, &my_pair, NULL); - return my_wchar[0]; + if (getcchar(&data, my_wchar, &my_attr, &my_pair, NULL) == OK) + result = my_wchar[0]; + return result; } #endif @@ -374,37 +367,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); -#if HAVE_INIT_EXTENDED_COLOR - init_extended_pair(pair, color, color); + 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 USE_EXTENDED_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 @@ -417,8 +410,8 @@ main(int argc, char *argv[]) mvprintw(2, 0, "System colors:\n"); for (n = 0; n < 16; ++n) { pair = n + MAX_ANSI; - addch(' ' | COLOR_PAIR(pair)); - addch(' ' | COLOR_PAIR(pair)); + addch((chtype) (' ' | COLOR_PAIR(pair))); + addch((chtype) (' ' | COLOR_PAIR(pair))); if (((n + 1) % 8) == 0) addch('\n'); } @@ -639,7 +632,7 @@ main(int argc, char *argv[]) chtype attr = A_REVERSE; chtype ch2 = (altchars ? MyMarker : '#'); if (use_colors) { - attr |= COLOR_PAIR(color); + attr |= (chtype) COLOR_PAIR(color); } move(y, x); AddCh(ch2 | attr);