- Timestamp:
- Oct 31, 2006, 3:04:22 PM (16 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca/caca0.c
r1257 r1269 268 268 } 269 269 270 char const *__caca0_get_color_name(unsigned char color) 271 { 272 static char const *color_names[] = 273 { 274 "black", 275 "blue", 276 "green", 277 "cyan", 278 "red", 279 "magenta", 280 "brown", 281 "light gray", 282 "dark gray", 283 "light blue", 284 "light green", 285 "light cyan", 286 "light red", 287 "light magenta", 288 "yellow", 289 "white", 290 }; 291 292 if(color > 15) 293 return "unknown"; 294 295 return color_names[(unsigned int)color]; 296 } 297 -
libcaca/trunk/caca/caca0.h
r1267 r1269 40 40 unsigned long int, unsigned long int); 41 41 extern void __caca0_free_bitmap(cucul_dither_t *); 42 extern char const *__caca0_get_color_name(unsigned char); 42 43 43 44 /* These variables are needed to emulate old non-thread safe behaviour */ … … 134 135 #define caca_get_fg_color() __caca0_fg 135 136 #define caca_get_bg_color() __caca0_bg 136 #define caca_get_color_name cucul_ansi_to_str137 #define caca_get_color_name __caca0_get_color_name 137 138 #define caca_putchar(x, y, c) cucul_putchar(__caca0_cv, x, y, c) 138 139 #define caca_putstr(x, y, s) cucul_putstr(__caca0_cv, x, y, s) -
libcaca/trunk/cucul/cucul.c
r1267 r1269 177 177 } 178 178 179 /** \brief Translate an ANSI colour index into the colour's name.180 *181 * Translate an ANSI colour index such as \e CUCUL_RED or \e CUCUL_WHITE182 * into a human-readable string describing the corresponding colour.183 *184 * This function never fails.185 *186 * \param color The colour value.187 * \return A static string containing the colour's name, or \c "unknown" if188 * the colour is unknown.189 */190 char const *cucul_ansi_to_str(unsigned char color)191 {192 static char const *color_names[] =193 {194 "black",195 "blue",196 "green",197 "cyan",198 "red",199 "magenta",200 "brown",201 "light gray",202 "dark gray",203 "light blue",204 "light green",205 "light cyan",206 "light red",207 "light magenta",208 "yellow",209 "white",210 };211 212 if(color > 15)213 return "unknown";214 215 return color_names[(unsigned int)color];216 }217 218 /* Legacy function for old programs */219 char const *cucul_get_color_name(unsigned int color)220 {221 return cucul_ansi_to_str(color > 15 ? 15 : color);222 }223 224 179 /** \brief Uninitialise \e libcucul. 225 180 * -
libcaca/trunk/cucul/cucul.h
r1267 r1269 239 239 240 240 #if !defined(_DOXYGEN_SKIP_ME) 241 /* Legacy stuff from beta versions */241 /* Legacy stuff from beta versions, will probably disappear in 1.0 */ 242 242 # ifdef __GNUC__ 243 243 # define CUCUL_DEPRECATED __attribute__ ((deprecated)) … … 249 249 int cucul_set_truecolor(cucul_canvas_t *, unsigned int, 250 250 unsigned int) CUCUL_DEPRECATED; 251 char const *cucul_get_color_name(unsigned int) CUCUL_DEPRECATED;252 251 # define CUCUL_COLOR_BLACK CUCUL_BLACK 253 252 # define CUCUL_COLOR_BLUE CUCUL_BLUE -
libcaca/trunk/cxx/cucul++.cpp
r1156 r1269 88 88 } 89 89 90 void Cucul::setColor(unsigned int f, unsigned int b) 91 { 92 cucul_set_color(cv, f, b); 93 } 94 95 int Cucul::setTruecolor(unsigned int f, unsigned int b) 96 { 97 return cucul_set_truecolor(cv, f, b); 98 } 99 100 char const * Cucul::getColorName(unsigned int color) 101 { 102 return cucul_get_color_name(color); 90 int Cucul::setColorANSI(unsigned char f, unsigned char b) 91 { 92 return cucul_set_color_ansi(cv, f, b); 93 } 94 95 int Cucul::setColorARGB(unsigned int f, unsigned int b) 96 { 97 return cucul_set_color_argb(cv, f, b); 103 98 } 104 99 … … 236 231 } 237 232 238 unsigned long int Cucul::getColor(int x, int y) 239 { 240 return cucul_get_color(cv, x, y); 233 int Cucul::setAttr(unsigned long int attr) 234 { 235 return cucul_set_attr(cv, attr); 236 } 237 238 unsigned long int Cucul::getAttr(int x, int y) 239 { 240 return cucul_get_attr(cv, x, y); 241 241 } 242 242 -
libcaca/trunk/cxx/cucul++.h
r1203 r1269 121 121 unsigned int getWidth(void); 122 122 unsigned int getHeight(void); 123 void setColor(unsigned int f, unsigned int b);124 int setTruecolor(unsigned int f, unsigned int b);125 unsigned long int getColor(int, int);126 char const * getColorName(unsigned int color);123 unsigned long int getAttr(int, int); 124 int setAttr(unsigned long int); 125 int setColorANSI(unsigned char f, unsigned char b); 126 int setColorARGB(unsigned int f, unsigned int b); 127 127 void Printf(int x , int y , char const * format,...); 128 128 void putChar(int x, int y, char ch); -
libcaca/trunk/cxx/cxxtest.cpp
r1268 r1269 4 4 * All Rights Reserved 5 5 * 6 * $Id $6 * $Id: cpptest.cpp 784 2006-06-10 11:35:18Z jylam $ 7 7 * 8 8 * This program is free software; you can redistribute it and/or … … 73 73 74 74 /* Draw pig */ 75 qq->setColor (CUCUL_LIGHTMAGENTA, CUCUL_BLACK);75 qq->setColorANSI(CUCUL_LIGHTMAGENTA, CUCUL_BLACK); 76 76 77 77 for(int i = 0; pig[i]; i++) … … 79 79 80 80 /* printf works */ 81 qq->setColor (CUCUL_LIGHTBLUE, CUCUL_BLACK);81 qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK); 82 82 qq->Printf(30,15, "Powered by libcaca %s", VERSION); 83 83 -
libcaca/trunk/doc/migrating.dox
r1017 r1269 54 54 caca_set_display_title(dp, "Window"); 55 55 /* Choose drawing colours */ 56 cucul_set_color (cv, CUCUL_COLOR_BLACK,57 CUCUL_COLOR_WHITE);56 cucul_set_color_ansi(cv, CUCUL_BLACK, 57 CUCUL_WHITE); 58 58 /* Draw a string at (0, 0) */ 59 59 cucul_putstr(cv, 0, 0, "Hello world!"); … … 142 142 \subsection bar3 Character printing 143 143 144 - \b caca_set_color(): use cucul_set_color() or cucul_set_truecolor(). 145 - \b caca_get_fg_color(): deprecated. 146 - \b caca_get_bg_color(): deprecated. 147 - \b caca_get_color_name(): use cucul_get_color_name(). 144 - \b caca_set_color(): use cucul_set_color_ansi() or cucul_set_color_argb(). 145 - \b caca_get_fg_color(): use cucul_get_attr(). 146 - \b caca_get_bg_color(): use cucul_get_attr(). 147 - \b caca_get_color_name(): this function is now deprecated due to major 148 uselessness. 148 149 - \b caca_putchar(): use cucul_putchar(). 149 150 - \b caca_putstr(): use cucul_putstr(). -
libcaca/trunk/doc/tutorial.dox
r923 r1269 18 18 caca_set_display_title(dp, "Hello!"); 19 19 /* Choose drawing colours */ 20 cucul_set_color (cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_WHITE);20 cucul_set_color_ansi(cv, CUCUL_BLACK, CUCUL_WHITE); 21 21 /* Draw a string at coordinates (0, 0) */ 22 22 cucul_putstr(cv, 0, 0, "This is a message"); -
libcaca/trunk/test/colors.c
r1267 r1269 41 41 { 42 42 cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK); 43 cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "'%cv': %i (%s)", 44 'a' + i, i, cucul_ansi_to_str(i)); 43 cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i); 45 44 for(j = 0; j < 16; j++) 46 45 { 47 46 cucul_set_color_ansi(cv, i, j); 48 cucul_putstr(cv, (j >= 8 ? 40 : 39) + j * 2, i + (i >= 8 ? 3 : 2),49 "Aa ");47 cucul_putstr(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2), 48 "Aaホ"); 50 49 } 51 50 } -
libcaca/trunk/test/demo.c
r1267 r1269 25 25 static void demo_all(void); 26 26 27 static void demo_color(void);28 27 static void demo_dots(void); 29 28 static void demo_lines(void); … … 114 113 break; 115 114 #endif 116 case 'c':117 demo = demo_color;118 break;119 115 case 'f': 120 116 case 'F': … … 364 360 } 365 361 366 static void demo_color(void)367 {368 int i, j;369 char buf[BUFSIZ];370 371 cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);372 cucul_clear_canvas(cv);373 for(i = 0; i < 16; i++)374 {375 sprintf(buf, "'%c': %i (%s)", 'a' + i, i, cucul_ansi_to_str(i));376 cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);377 cucul_putstr(cv, 4, i + (i >= 8 ? 4 : 3), buf);378 for(j = 0; j < 16; j++)379 {380 cucul_set_color_ansi(cv, i, j);381 cucul_putstr(cv, (j >= 8 ? 41 : 40) + j * 2, i + (i >= 8 ? 4 : 3), "# ");382 }383 }384 }385 386 362 static void demo_lines(void) 387 363 {
Note: See TracChangeset
for help on using the changeset viewer.