Ticket #152: remove-ncurses.patch
| File remove-ncurses.patch, 5.5 KB (added by josephpiche, 4 years ago) |
|---|
-
utils/gg_utils.h
old new 52 52 #include <io.h> 53 53 #endif 54 54 55 void gg_init_color(void);56 55 void write_color_char(int c, int x); 57 56 void write_color_string(int c, const char *str); 58 57 -
utils/gg_utils.c
old new 35 35 /* Avoid compiler warnings with unused parameters */ 36 36 #define UNUSED(x) (void)x 37 37 38 /* Define TERMINFO orANSI_COLOR to enable coloring of pieces.38 /* Define ANSI_COLOR to enable coloring of pieces. 39 39 * This is normally done in config.h. 40 40 */ 41 41 … … 52 52 * 7=white 53 53 */ 54 54 55 #ifdef TERMINFO56 57 #ifdef _AIX58 #define _TPARM_COMPAT59 #endif60 61 #if HAVE_CURSES_H62 #include <curses.h>63 #elif HAVE_NCURSES_CURSES_H64 #include <ncurses/curses.h>65 #else66 #endif67 68 #if HAVE_TERM_H69 #include <term.h>70 #elif HAVE_NCURSES_TERM_H71 #include <ncurses/term.h>72 #else73 #endif74 75 76 /* terminfo attributes */77 static char *setaf; /* terminfo string to set color */78 static int max_color; /* terminfo max colour */79 80 static int init = 0;81 82 #endif /* TERMINFO */83 84 55 /* for gg_cputime */ 85 56 86 57 #ifdef HAVE_UNISTD_H … … 92 63 #include <windows.h> 93 64 #endif 94 65 95 void96 gg_init_color()97 {98 #ifdef TERMINFO99 100 /* compiler is set to make string literals const char *101 * But system header files dont prototype things correctly.102 * These are equivalent to a non-const string literals103 */104 105 static char setaf_literal[] = "setaf";106 static char colors_literal[] = "colors";107 static char empty_literal[] = "";108 109 if (init)110 return;111 112 init = 1;113 114 setupterm(NULL, 2, NULL);115 setaf = tigetstr(setaf_literal);116 if (!setaf)117 setaf = empty_literal;118 max_color = tigetnum(colors_literal) - 1;119 if (max_color < 1)120 max_color = 1;121 else if (max_color > 30)122 max_color = 30;123 124 #endif /* TERMINFO */125 }126 127 128 66 129 67 #ifdef WIN32 130 68 #ifdef VC … … 154 92 void 155 93 write_color_char_no_space(int c, int x) 156 94 { 157 #ifdef TERMINFO 158 159 fprintf(stderr, "%s%c", tparm(setaf, c, 0, 0, 0, 0, 0, 0, 0, 0), x); 160 fputs(tparm(setaf, max_color, 0, 0, 0, 0, 0, 0, 0, 0), stderr); 161 162 #elif defined(ANSI_COLOR) 95 #ifdef ANSI_COLOR 163 96 164 97 fprintf(stderr, "\033[%dm%c\033[0m", 30+c, x); 165 98 -
engine/showbord.c
old new 100 100 void 101 101 start_draw_board() 102 102 { 103 gg_init_color();104 103 draw_letter_coordinates(stderr); 105 104 } 106 105 … … 266 265 showboard(int xo) 267 266 { 268 267 int i, j, ii; 269 gg_init_color();270 268 271 269 /* Set all dragon numbers to 0. */ 272 270 memset(dragon_num, 0, sizeof(dragon_num)); -
configure.in
old new 29 29 30 30 AM_MAINTAINER_MODE 31 31 32 dnl See if user has expressed a preference for use of c urses and/or color33 dnl These set variables $enable_color and $with_cursesto "no" if disabled32 dnl See if user has expressed a preference for use of color 33 dnl These set variables $enable_color to "no" if disabled 34 34 dnl "yes" if enabled, or undefined if not specified 35 35 36 36 AC_ARG_WITH(readline, 37 37 [ --with-readline try to use GNU Readline for command reading 38 38 --without-readline do not use GNU Readline (default)]) 39 39 40 AC_ARG_WITH(curses,41 [ --with-curses try to use curses for colored debugging output (default)42 --without-curses do not use curses for colored debugging output])43 44 40 AC_ARG_ENABLE(color, 45 [ --enable-color use curses oransi escape sequences for colored41 [ --enable-color use ansi escape sequences for colored 46 42 debug output 47 43 --disable-color do not try to generated colored debug output]) 48 44 … … 160 156 AC_C_CONST 161 157 162 158 AC_CHECK_HEADERS(unistd.h sys/time.h sys/times.h) 163 AC_CHECK_HEADERS(curses.h term.h ncurses/curses.h ncurses/term.h)164 165 if test "$ac_cv_header_curses_h" = "yes";then166 curses_header="curses.h"167 elif test "$ac_cv_header_ncurses_curses_h" = "yes";then168 curses_header="ncurses/curses.h"169 else170 curses_header="no"171 fi172 173 if test "$ac_cv_header_term_h" = "yes";then174 term_header="term.h"175 elif test "$ac_cv_header_ncurses_term_h" = "yes";then176 term_header="ncurses/term.h"177 else178 term_header="no"179 fi180 159 181 160 AC_CHECK_SIZEOF(long,,[#include <stdio.h>]) 182 161 … … 250 229 251 230 dnl -------- color debugging support ----------- 252 231 253 AH_TEMPLATE([TERMINFO],254 [Define to 1 if termcap/terminfo is available.])255 256 232 AH_TEMPLATE([ANSI_COLOR], 257 233 [Define to use ansi escape sequences for color debugging]) 258 234 259 235 tmp_color_result="none" 260 236 261 if test "$with_curses" != no -a "$enable_color" != no ; then 262 tmp_color_result="none (curses failed)" 263 264 dnl Do a separate test for curses and termcap 265 dnl DJGPP does have pdcurses, but not termcap 266 267 dnl make sure that both curses.h and term.h are available 268 dnl FIXME: better to actually figure out here what headers 269 dnl are really required 270 if test "$term_header" != "no" -a "$curses_header" != "no" ; then 271 272 dnl check for a working termcap library 273 AC_SEARCH_LIBS(tparm,ncurses curses pdcurses termcap terminfo termlib) 274 275 if test "$ac_cv_search_tparm" != "no" ; then 276 AC_DEFINE(TERMINFO) 277 tmp_color_result="curses" 278 fi 279 fi 280 fi 281 282 if test "$with_curses" = no -a "$enable_color" != no ; then 283 dnl we asked for color, but there is no termcap 237 if test "$enable_color" != no ; then 284 238 AC_DEFINE(ANSI_COLOR) 285 239 tmp_color_result="ANSI color" 286 240
