Ticket #2169: mc-4.7.2-I_can_has_256_colorz.patch
File mc-4.7.2-I_can_has_256_colorz.patch, 37.1 KB (added by egmont, 15 years ago) |
---|
-
doc/man/mc.1.in
diff -urN mc-4.7.2.orig/doc/man/mc.1.in mc-4.7.2/doc/man/mc.1.in
old new 3327 3327 The format for the color definition is: 3328 3328 .PP 3329 3329 .nf 3330 <keyword>=< foregroundcolor>,<backgroundcolor>:<keyword>=...3330 <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>=... 3331 3331 .fi 3332 3332 .PP 3333 3333 The colors are optional, and the keywords are: normal, selected, marked, … … 3374 3374 .PP 3375 3375 The possible colors are: black, gray, red, brightred, green, 3376 3376 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, 3377 cyan, brightcyan, lightgray and white. And there is a special keyword 3378 for transparent background. It is 'default'. The 'default' can only be 3379 used for background color. Example: 3377 cyan, brightcyan, lightgray and white. The special keyword "default" means 3378 the terminal's default. Another special keyword "base" means mc's main 3379 colors. When 256 colors are available, they can be specified either as 3380 color16 to color255, or as rgb000 to rgb555 and gray0 to gray23. Example: 3380 3381 .PP 3381 3382 .nf 3382 3383 [Colors] 3383 3384 base_color=normal=white,default:marked=magenta,default 3384 3385 .fi 3386 .PP 3387 Attributes can be any of bold, underline, reverse and blink, appended by a 3388 plus sign if more than one are desired. The special word "none" menas no 3389 attributes, without attempting to fall back to base_color. Example: 3390 .PP 3391 .nf 3392 menuhotsel=yellow;black;bold+underline 3393 .fi 3385 3394 3386 3395 .\"NODE "Skins" 3387 3396 .SH "Skins" … … 3614 3623 .SH " Color pair definitions" 3615 3624 Any parameter in skin\-file contain definition of color pair. 3616 3625 .PP 3617 Color pairs described as two colors separated by ';'. First color 3618 sets the foreground color, second color sets background color. 3619 One of the colors may be omitted, in this case color will be 3620 taken from default color pair (global color pair or 3621 from default color pair of this section). 3626 Color pairs described as two colors and the optional attributes 3627 separated by ';'. First field sets the foreground color, second 3628 field sets background color, third field sets the attributes. 3629 Any of the fields may be omitted, in this case value will be 3630 taken from default color pair (global color pair or from default 3631 color pair of this section). 3622 3632 .PP 3623 3633 Example: 3624 3634 .br … … 3626 3636 [core] 3627 3637 # green on black 3628 3638 _default_=green;black 3629 # green (default) 3639 # green (default) on blue 3630 3640 selected=;blue 3631 # yellow on black (default)3632 marked=yellow; 3641 # underlined yellow on black (default) 3642 marked=yellow;;underline 3633 3643 .fi 3634 3644 3635 3645 .PP 3636 Possible colors (names) described in3646 Possible colors (names) and attributes are described in 3637 3647 .\"LINK2" 3638 3648 Colors\&. 3639 3649 .\"Colors" -
doc/man/mcedit.1.in
diff -urN mc-4.7.2.orig/doc/man/mcedit.1.in mc-4.7.2/doc/man/mcedit.1.in
old new 33 33 Force ANSI color mode on terminals that don't seem to have color 34 34 support. 35 35 .TP 36 .I "\-C <keyword>=<FGcolor>,<BGcolor> :<keyword>= ..."36 .I "\-C <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>= ..." 37 37 Specify a different color set. See the 38 38 .B Colors 39 39 section in mc(1) for more information. … … 249 249 .I delim 250 250 .RI [ foreground ] 251 251 .RI [ background ] 252 .RI [ attributes ] 252 253 .PP 253 254 The first context is an exception. It must start with the command 254 255 .PP 255 256 .B context default 256 257 .RI [ foreground ] 257 258 .RI [ background ] 259 .RI [ attributes ] 258 260 .PP 259 261 otherwise 260 262 .B mcedit … … 294 296 .RB [ linestart ] 295 297 .I string foreground 296 298 .RI [ background ] 299 .RI [ attributes ] 297 300 .PP 298 301 Context or keyword strings are interpreted, so that you can include tabs 299 302 and spaces with the sequences \\t and \\s. Newlines and backslashes are … … 331 334 .PP 332 335 The possible colors are: black, gray, red, brightred, green, 333 336 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, 334 cyan, brightcyan, lightgray and white. If the syntax file is shared 337 cyan, brightcyan, lightgray and white. The special keyword "default" means 338 the terminal's default. Another special keyword "base" means mc's main 339 colors, it is useful as a placeholder if you want to specify attributes 340 without modifying the background color. When 256 colors are available, 341 they can be specified either as color16 to color255, or as rgb000 to rgb555 342 and gray0 to gray23. 343 .PP 344 If the syntax file is shared 335 345 with 336 346 .BR cooledit , 337 347 it is possible to specify different colors for … … 349 359 .B cooledit 350 360 colors. 351 361 .PP 362 Attributes can be any of bold, underline, reverse and blink, appended by a 363 plus sign if more than one are desired. 364 .PP 352 365 Comments may be put on a separate line starting with the hash sign (#). 353 366 .PP 354 367 If you are describing case insensitive language you need to use -
doc/man/mcview.1.in
diff -urN mc-4.7.2.orig/doc/man/mcview.1.in mc-4.7.2/doc/man/mcview.1.in
old new 23 23 .B mcview 24 24 defaults to black and white. 25 25 .TP 26 .I "\-C <keyword>=<FGcolor>,<BGcolor> :<keyword>= ..."26 .I "\-C <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>= ..." 27 27 Specify a different color set. See the 28 28 .B Colors 29 29 section in mc(1) for more information. -
lib/skin/colors-old.c
diff -urN mc-4.7.2.orig/lib/skin/colors-old.c mc-4.7.2/lib/skin/colors-old.c
old new 125 125 126 126 for (; *colors; colors++) 127 127 { 128 key_val = g_strsplit_set (*colors, "=,", 3);128 key_val = g_strsplit_set (*colors, "=,", 4); 129 129 130 130 if (!key_val) 131 131 continue; … … 137 137 continue; 138 138 } 139 139 140 if (key_val[2] != NULL) 140 if (key_val[3] != NULL) 141 skin_val = g_strdup_printf ("%s;%s;%s", key_val[1], key_val[2], key_val[3]); 142 else if (key_val[2] != NULL) 141 143 skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]); 142 144 else 143 145 skin_val = g_strdup_printf ("%s;", key_val[1]); -
lib/skin/colors.c
diff -urN mc-4.7.2.orig/lib/skin/colors.c mc-4.7.2/lib/skin/colors.c
old new 141 141 return NULL; 142 142 } 143 143 144 switch (items_count) 145 { 146 case 0: 147 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 148 if (tmp) 149 { 150 mc_skin_color->fgcolor = g_strdup (tmp->fgcolor); 151 mc_skin_color->bgcolor = g_strdup (tmp->bgcolor); 152 } 153 else 154 { 155 g_strfreev (values); 156 g_free (mc_skin_color); 157 return NULL; 158 } 159 break; 160 case 1: 161 mc_skin_color->fgcolor = (values[0]) ? g_strstrip (g_strdup (values[0])) : NULL; 162 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 163 mc_skin_color->bgcolor = (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; 164 break; 165 case 2: 166 mc_skin_color->fgcolor = (values[0]) ? g_strstrip (g_strdup (values[0])) : NULL; 167 mc_skin_color->bgcolor = (values[1]) ? g_strstrip (g_strdup (values[1])) : NULL; 168 break; 169 } 144 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 145 mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ? g_strstrip (g_strdup (values[0])) : 146 (tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL; 147 mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? g_strstrip (g_strdup (values[1])) : 148 (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; 149 mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? g_strstrip (g_strdup (values[2])) : 150 (tmp != NULL) ? g_strdup (tmp->attrs) : NULL; 151 170 152 g_strfreev (values); 171 153 172 154 mc_skin_color->pair_index = 173 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);155 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs, FALSE); 174 156 175 157 return mc_skin_color; 176 158 } … … 186 168 { 187 169 mc_skin_color->fgcolor = g_strdup ("default"); 188 170 mc_skin_color->bgcolor = g_strdup ("default"); 171 mc_skin_color->attrs = NULL; 189 172 mc_skin_color->pair_index = 190 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);173 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs, FALSE); 191 174 mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color); 192 175 } 193 176 } … … 314 297 if (mc_skin_color == NULL) 315 298 return FALSE; 316 299 317 tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor );300 tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs); 318 301 mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color); 319 302 320 303 for (; *groups != NULL; groups++) -
lib/skin/common.c
diff -urN mc-4.7.2.orig/lib/skin/common.c mc-4.7.2/lib/skin/common.c
old new 62 62 mc_skin_color_t *mc_skin_color = (mc_skin_color_t *) data; 63 63 g_free (mc_skin_color->fgcolor); 64 64 g_free (mc_skin_color->bgcolor); 65 g_free (mc_skin_color->attrs); 65 66 g_free (mc_skin_color); 66 67 } 67 68 -
lib/skin/internal.h
diff -urN mc-4.7.2.orig/lib/skin/internal.h mc-4.7.2/lib/skin/internal.h
old new 13 13 typedef struct mc_skin_color_struct { 14 14 gchar *fgcolor; 15 15 gchar *bgcolor; 16 gchar *attrs; 16 17 int pair_index; 17 18 } mc_skin_color_t; 18 19 -
lib/tty/color-internal.c
diff -urN mc-4.7.2.orig/lib/tty/color-internal.c mc-4.7.2/lib/tty/color-internal.c
old new 47 47 /*** file scope variables ************************************************************************/ 48 48 49 49 mc_tty_color_table_t const color_table[] = { 50 { "black", COLOR_BLACK },51 { "gray", COLOR_BLACK | A_BOLD},52 { "red", COLOR_RED },53 { "brightred", COLOR_RED | A_BOLD},54 { "green", COLOR_GREEN },55 { "brightgreen", COLOR_GREEN | A_BOLD},56 { "brown", COLOR_YELLOW },57 { "yellow", COLOR_YELLOW | A_BOLD},58 { "blue", COLOR_BLUE },59 { "brightblue", COLOR_BLUE | A_BOLD},60 { "magenta", COLOR_MAGENTA },61 { "brightmagenta", COLOR_MAGENTA | A_BOLD},62 { "cyan", COLOR_CYAN },63 { "brightcyan", COLOR_CYAN | A_BOLD},64 { "lightgray", COLOR_WHITE },65 { "white", COLOR_WHITE | A_BOLD},50 { "black", COLOR_BLACK }, 51 { "gray", COLOR_BLACK + 8 }, 52 { "red", COLOR_RED }, 53 { "brightred", COLOR_RED + 8 }, 54 { "green", COLOR_GREEN }, 55 { "brightgreen", COLOR_GREEN + 8 }, 56 { "brown", COLOR_YELLOW }, 57 { "yellow", COLOR_YELLOW + 8 }, 58 { "blue", COLOR_BLUE }, 59 { "brightblue", COLOR_BLUE + 8 }, 60 { "magenta", COLOR_MAGENTA }, 61 { "brightmagenta", COLOR_MAGENTA + 8 }, 62 { "cyan", COLOR_CYAN }, 63 { "brightcyan", COLOR_CYAN + 8 }, 64 { "lightgray", COLOR_WHITE }, 65 { "white", COLOR_WHITE + 8 }, 66 66 { "default", -1 }, /* default color of the terminal */ 67 67 /* special colors */ 68 68 { "A_REVERSE", SPEC_A_REVERSE }, … … 73 73 { NULL, 0} 74 74 }; 75 75 76 mc_tty_color_table_t const attributes_table[] = { 77 { "bold", A_BOLD }, 78 { "underline", A_UNDERLINE }, 79 { "reverse", A_REVERSE }, 80 { "blink", A_BLINK }, 81 /* End of list */ 82 { NULL, 0} 83 }; 84 76 85 /*** file scope functions ************************************************************************/ 77 86 /* --------------------------------------------------------------------------------------------- */ 78 87 88 static int 89 parse_256_color_name (const char *color_name) 90 { 91 int i; 92 char dummy; 93 if (sscanf(color_name, "color%d%c", &i, &dummy) == 1 && i >= 0 && i < 256) { 94 return i; 95 } 96 if (sscanf(color_name, "gray%d%c", &i, &dummy) == 1 && i >= 0 && i < 24) { 97 return 232 + i; 98 } 99 if (strncmp(color_name, "rgb", 3) == 0 && 100 color_name[3] >= '0' && color_name[3] < '6' && 101 color_name[4] >= '0' && color_name[4] < '6' && 102 color_name[5] >= '0' && color_name[5] < '6' && 103 color_name[6] == '\0') { 104 return 16 + 36 * (color_name[3] - '0') + 6 * (color_name[4] - '0') + (color_name[5] - '0'); 105 } 106 return -1; 107 } 108 79 109 /*** public functions ****************************************************************************/ 80 110 /* --------------------------------------------------------------------------------------------- */ 81 111 82 112 const char * 83 tty_color_get_ valid_name (const char *color_name)113 tty_color_get_name_by_index (int idx) 84 114 { 115 static char **color_N_names = NULL; 85 116 int i; 86 117 87 if (color_name != NULL) 88 for (i = 0; color_table[i].name != NULL; i++) 89 if (strcmp (color_name, color_table[i].name) == 0) 90 return color_table[i].name; 91 return NULL; 118 /* Find the real English name of the first 16 colors, */ 119 /* as well as the A_* special values. */ 120 for (i = 0; color_table[i].name != NULL; i++) 121 if (idx == color_table[i].value) 122 return color_table[i].name; 123 /* Create and return the strings "color16" to "color255". */ 124 if (idx >= 16 && idx < 256) { 125 if (color_N_names == NULL) { 126 color_N_names = g_try_malloc0(240 * sizeof(char *)); 127 } 128 if (color_N_names[idx - 16] == NULL) { 129 color_N_names[idx - 16] = g_try_malloc(9); 130 sprintf(color_N_names[idx - 16], "color%d", idx); 131 } 132 return color_N_names[idx - 16]; 133 } 134 return "default"; 92 135 } 93 136 94 137 /* --------------------------------------------------------------------------------------------- */ … … 98 141 { 99 142 int i; 100 143 101 if (color_name != NULL) 144 if (color_name != NULL) { 102 145 for (i = 0; color_table[i].name != NULL; i++) 103 146 if (strcmp (color_name, color_table[i].name) == 0) 104 147 return color_table[i].value; 148 return parse_256_color_name(color_name); 149 } 105 150 return -1; 106 151 } 107 152 108 153 /* --------------------------------------------------------------------------------------------- */ 154 155 int 156 tty_attr_get_bits (const char *attrs) 157 { 158 int attr_bits = 0; 159 gchar **attr_list; 160 int i, j; 161 162 if (attrs != NULL) { 163 attr_list = g_strsplit(attrs, "+", -1); 164 for (i = 0; attr_list[i] != NULL; i++) { 165 for (j = 0; attributes_table[j].name != NULL; j++) { 166 if (strcmp(attr_list[i], attributes_table[j].name) == 0) { 167 attr_bits |= attributes_table[j].value; 168 break; 169 } 170 } 171 } 172 g_strfreev(attr_list); 173 } 174 return attr_bits; 175 } 176 177 /* --------------------------------------------------------------------------------------------- */ -
lib/tty/color-internal.h
diff -urN mc-4.7.2.orig/lib/tty/color-internal.h mc-4.7.2/lib/tty/color-internal.h
old new 21 21 22 22 typedef struct mc_color_pair_struct 23 23 { 24 const char *cfg;25 const char *cbg;26 24 int ifg; 27 25 int ibg; 26 int attr; 28 27 size_t pair_index; 29 28 gboolean is_temp; 30 29 } tty_color_pair_t; … … 38 37 } tty_special_color_t; 39 38 /* *INDENT-ON* */ 40 39 41 const char *tty_color_get_ valid_name (const char *);40 const char *tty_color_get_name_by_index (int); 42 41 int tty_color_get_index_by_name (const char *); 42 int tty_attr_get_bits (const char *); 43 43 44 44 void tty_color_init_lib (gboolean, gboolean); 45 45 void tty_color_deinit_lib (void); -
lib/tty/color-ncurses.c
diff -urN mc-4.7.2.orig/lib/tty/color-ncurses.c mc-4.7.2/lib/tty/color-ncurses.c
old new 57 57 58 58 /* --------------------------------------------------------------------------------------------- */ 59 59 60 static int61 mc_tty_color_save_attr _lib(int color_pair, int color_attr)60 static void 61 mc_tty_color_save_attr (int color_pair, int color_attr) 62 62 { 63 63 int *attr, *key; 64 64 attr = g_try_new0 (int, 1); 65 65 if (attr == NULL) 66 return color_attr;66 return; 67 67 68 68 key = g_try_new (int, 1); 69 69 if (key == NULL) { 70 70 g_free (attr); 71 return color_attr;71 return; 72 72 } 73 73 74 74 *key = color_pair; 75 *attr = color_attr; 75 76 76 if (color_attr != -1)77 *attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE);78 77 g_hash_table_replace (mc_tty_color_color_pair_attrs, (gpointer) key, (gpointer) attr); 79 return color_attr & (~(*attr));80 78 } 81 79 82 80 /* --------------------------------------------------------------------------------------------- */ … … 95 93 96 94 static void 97 95 mc_tty_color_pair_init_special (tty_color_pair_t * mc_color_pair, 98 int fg1, int bg1, int fg2, int bg2, int mask)96 int fg1, int bg1, int fg2, int bg2, int attr) 99 97 { 100 98 if (has_colors () && !mc_tty_color_disable) 101 init_pair (mc_color_pair->pair_index, 102 mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg1 | mask), bg1); 99 init_pair (mc_color_pair->pair_index, fg1, bg1); 103 100 else 104 init_pair (mc_color_pair->pair_index, 105 mc_tty_color_save_attr_lib (mc_color_pair->pair_index, fg2 | mask), bg2);101 init_pair (mc_color_pair->pair_index, fg2, bg2); 102 mc_tty_color_save_attr (mc_color_pair->pair_index, attr); 106 103 } 107 104 108 105 /* --------------------------------------------------------------------------------------------- */ … … 138 135 void 139 136 tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair) 140 137 { 141 if (mc_color_pair->ifg <= (int) SPEC_A_REVERSE) { 142 switch (mc_color_pair->ifg) { 138 int ifg, ibg, attr; 139 140 ifg = mc_color_pair->ifg; 141 ibg = mc_color_pair->ibg; 142 attr = mc_color_pair->attr; 143 144 if (ifg <= (int) SPEC_A_REVERSE) { 145 switch (ifg) { 143 146 case SPEC_A_REVERSE: 144 147 mc_tty_color_pair_init_special (mc_color_pair, 145 148 COLOR_BLACK, COLOR_WHITE, … … 162 165 break; 163 166 } 164 167 } else { 165 int mask_fg = (mc_color_pair->ifg == -1) ? mc_color_pair->ifg : 0xff; 166 int mask_bg = (mc_color_pair->ibg == -1) ? mc_color_pair->ibg : 0xff; 168 /* In 8 color mode, change bright colors into bold */ 169 if (COLORS == 8 && ifg >= 8 && ifg < 16) { 170 ifg &= 0x07; 171 attr |= A_BOLD; 172 } 167 173 168 init_pair (mc_color_pair->pair_index, 169 mc_tty_color_save_attr_lib (mc_color_pair->pair_index, 170 mc_color_pair->ifg) & mask_fg, 171 mc_color_pair->ibg & mask_bg); 174 init_pair (mc_color_pair->pair_index, ifg, ibg); 175 mc_tty_color_save_attr (mc_color_pair->pair_index, attr); 172 176 } 173 177 } 174 178 -
lib/tty/color-slang.c
diff -urN mc-4.7.2.orig/lib/tty/color-slang.c mc-4.7.2/lib/tty/color-slang.c
old new 133 133 break; 134 134 } 135 135 } else { 136 fg = (mc_color_pair->cfg) ? mc_color_pair->cfg : "default";137 bg = (mc_color_pair->cbg) ? mc_color_pair->cbg : "default";136 fg = tty_color_get_name_by_index(mc_color_pair->ifg); 137 bg = tty_color_get_name_by_index(mc_color_pair->ibg); 138 138 SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg, (char *) bg); 139 SLtt_add_color_attribute (mc_color_pair->pair_index, mc_color_pair->attr); 139 140 } 140 141 } 141 142 -
lib/tty/color-slang.h
diff -urN mc-4.7.2.orig/lib/tty/color-slang.h mc-4.7.2/lib/tty/color-slang.h
old new 20 20 }; 21 21 22 22 /* When using Slang with color, we have all the indexes free but 23 * those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_B OLD_REVERSE)23 * those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BLINK) 24 24 */ 25 25 26 26 #ifndef A_BOLD 27 27 #define A_BOLD SLTT_BOLD_MASK 28 28 #endif /* A_BOLD */ 29 #ifndef A_UNDERLINE 30 #define A_UNDERLINE SLTT_ULINE_MASK 31 #endif /* A_UNDERLINE */ 32 #ifndef A_REVERSE 33 #define A_REVERSE SLTT_REV_MASK 34 #endif /* A_REVERSE */ 35 #ifndef A_BLINK 36 #define A_BLINK SLTT_BLINK_MASK 37 #endif /* A_BLINK */ 29 38 30 39 #endif /* MC_COLOR_SLANG_H */ -
lib/tty/color.c
diff -urN mc-4.7.2.orig/lib/tty/color.c mc-4.7.2/lib/tty/color.c
old new 46 46 47 47 static char *tty_color_defaults__fg = NULL; 48 48 static char *tty_color_defaults__bg = NULL; 49 static char *tty_color_defaults__attrs = NULL; 49 50 50 51 /* Set if we are actually using colors */ 51 52 gboolean use_colors = FALSE; … … 155 156 tty_color_deinit_lib (); 156 157 g_free (tty_color_defaults__fg); 157 158 g_free (tty_color_defaults__bg); 159 g_free (tty_color_defaults__attrs); 158 160 159 161 g_hash_table_destroy (mc_tty_color__hashtable); 160 162 } … … 170 172 /* --------------------------------------------------------------------------------------------- */ 171 173 172 174 int 173 tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_color)175 tty_try_alloc_color_pair2 (const char *fg, const char *bg, const char *attrs, gboolean is_temp_color) 174 176 { 175 177 gchar *color_pair; 176 178 tty_color_pair_t *mc_color_pair; 177 const char *c_fg, *c_bg;179 int ifg, ibg, attr; 178 180 179 if (fg == NULL )181 if (fg == NULL || !strcmp(fg, "base")) 180 182 fg = tty_color_defaults__fg; 181 182 if (bg == NULL) 183 { 183 if (bg == NULL || !strcmp(bg, "base")) 184 184 bg = tty_color_defaults__bg; 185 } 186 c_fg = tty_color_get_valid_name (fg); 187 c_bg = tty_color_get_valid_name (bg); 185 if (attrs == NULL || !strcmp(attrs, "base")) 186 attrs = tty_color_defaults__attrs; 187 188 ifg = tty_color_get_index_by_name (fg); 189 ibg = tty_color_get_index_by_name (bg); 190 attr = tty_attr_get_bits (attrs); 188 191 189 color_pair = g_strdup_printf ("% s.%s", c_fg, c_bg);192 color_pair = g_strdup_printf ("%d.%d.%d", ifg, ibg, attr); 190 193 if (color_pair == NULL) 191 194 return 0; 192 195 … … 207 210 } 208 211 209 212 mc_color_pair->is_temp = is_temp_color; 210 mc_color_pair->cfg = c_fg; 211 mc_color_pair->cbg = c_bg; 212 mc_color_pair->ifg = tty_color_get_index_by_name (c_fg); 213 mc_color_pair->ibg = tty_color_get_index_by_name (c_bg); 213 mc_color_pair->ifg = ifg; 214 mc_color_pair->ibg = ibg; 215 mc_color_pair->attr = attr; 214 216 mc_color_pair->pair_index = tty_color_get_next__color_pair_number (); 215 217 216 218 tty_color_try_alloc_pair_lib (mc_color_pair); … … 223 225 /* --------------------------------------------------------------------------------------------- */ 224 226 225 227 int 226 tty_try_alloc_color_pair (const char *fg, const char *bg )228 tty_try_alloc_color_pair (const char *fg, const char *bg, const char *attrs) 227 229 { 228 return tty_try_alloc_color_pair2 (fg, bg, TRUE);230 return tty_try_alloc_color_pair2 (fg, bg, attrs, TRUE); 229 231 } 230 232 231 233 /* --------------------------------------------------------------------------------------------- */ … … 247 249 /* --------------------------------------------------------------------------------------------- */ 248 250 249 251 void 250 tty_color_set_defaults (const char *fgcolor, const char *bgcolor )252 tty_color_set_defaults (const char *fgcolor, const char *bgcolor, const char *attrs) 251 253 { 252 254 g_free (tty_color_defaults__fg); 253 255 g_free (tty_color_defaults__fg); 256 g_free (tty_color_defaults__attrs); 254 257 255 258 tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL; 256 259 tty_color_defaults__bg = (bgcolor != NULL) ? g_strdup (bgcolor) : NULL; 260 tty_color_defaults__attrs = (attrs != NULL) ? g_strdup (attrs) : NULL; 257 261 } 258 262 259 263 /* --------------------------------------------------------------------------------------------- */ -
lib/tty/color.h
diff -urN mc-4.7.2.orig/lib/tty/color.h mc-4.7.2/lib/tty/color.h
old new 27 27 void tty_colors_done (void); 28 28 29 29 gboolean tty_use_colors (void); 30 int tty_try_alloc_color_pair (const char *, const char * );31 int tty_try_alloc_color_pair2 (const char *, const char *, gboolean);30 int tty_try_alloc_color_pair (const char *, const char *, const char *); 31 int tty_try_alloc_color_pair2 (const char *, const char *, const char *, gboolean); 32 32 33 33 void tty_color_free_all_tmp (void); 34 34 void tty_color_free_all_non_tmp (void); … … 37 37 void tty_lowlevel_setcolor (int color); 38 38 void tty_set_normal_attrs (void); 39 39 40 void tty_color_set_defaults (const char *, const char * );40 void tty_color_set_defaults (const char *, const char *, const char *); 41 41 42 42 #define ALLOC_COLOR_PAIR_INDEX 1 43 43 -
lib/tty/tty-slang.c
diff -urN mc-4.7.2.orig/lib/tty/tty-slang.c mc-4.7.2/lib/tty/tty-slang.c
old new 284 284 285 285 tty_reset_prog_mode (); 286 286 load_terminfo_keys (); 287 SLtt_Blink_Mode = 0;287 SLtt_Blink_Mode = 1; 288 288 289 289 tty_start_interrupt_key (); 290 290 -
misc/skins/Makefile.am
diff -urN mc-4.7.2.orig/misc/skins/Makefile.am mc-4.7.2/misc/skins/Makefile.am
old new 6 6 double-lines.ini \ 7 7 featured.ini \ 8 8 gotar.ini \ 9 nicedark.ini 9 nicedark.ini \ 10 sand256.ini 10 11 11 12 EXTRA_DIST = \ 12 13 $(skin_DATA) -
misc/skins/Makefile.in
diff -urN mc-4.7.2.orig/misc/skins/Makefile.in mc-4.7.2/misc/skins/Makefile.in
old new 318 318 double-lines.ini \ 319 319 featured.ini \ 320 320 gotar.ini \ 321 nicedark.ini 321 nicedark.ini \ 322 sand256.ini 322 323 323 324 EXTRA_DIST = \ 324 325 $(skin_DATA) -
misc/skins/sand256.ini
diff -urN mc-4.7.2.orig/misc/skins/sand256.ini mc-4.7.2/misc/skins/sand256.ini
old new 1 # This skin demonstrates how to use 256 colors in mc. 2 # 3 # As a prerequisite, you will need to: 4 # 1) Have a terminal emulator that supports 256 colors (a few examples: 5 # xterm, Gnome terminal and other VTE derivatives, KDE's Konsole; 6 # iTerm for Mac OS X, PuTTY for Windows). 7 # 2) Adjust your TERM variable accordingly, e.g.: export TERM=xterm-256color 8 # Verify by running tput colors 9 # 10 # Each of the 256 colors has two names, you can use whichever you prefer. 11 # 12 # One possibility is to use the names "color0" to "color255" to access every 13 # color directly based on their number. 14 # 15 # The first 16 colors ("color0" to "color15") can also be specified by their 16 # names (these names are already being used by mc for 8/16 color terminals): 17 # black gray 18 # red brightred 19 # green brightgreen 20 # brown yellow 21 # blue brightblue 22 # magenta brightmagenta 23 # cyan brightcyan 24 # lightgray white 25 # Note that with 8/16 color terminal settings (such as TERM=xterm), colors 26 # of the second column can only be used for the foreground, and their actual 27 # interpretation varies across terminals. Some terminals show the colors 28 # from the first column instead (that is, you only have 8 colors), but make 29 # them bold. Others show the brighter version (16 foreground colors). Yet 30 # others make them bold and bright at the same time. Switching to 256 colors 31 # should end this ambiguity: you should have 16 separate colors according to 32 # their names, none of them are bold by default but any of them can be 33 # switched to bold, and all of them are available for background, too. This 34 # is the intended behavior, the actual behavior might vary across terminals. 35 # 36 # Colors of the 6x6x6 cube ("color16" to "color231") can alternatively be 37 # referred to as "rgb000" to "rgb555", all three digits ranging from 0 to 5, 38 # corresponding to the R, G and B color components. 39 # 40 # The 24 grayscale colors ("color232" to "color255") have the aliases "gray0" 41 # to "gray23". 42 # 43 # In addition to the 256 colors, the special word "default" means the 44 # default foreground or background color of your terminal, while "base" means 45 # mc's main colors. A missing value means falling back to the _default_ of the 46 # given section. 47 # 48 # Following the foreground and background colors, the third (optional) value 49 # can specify special attributes to enable. Valid values are bold, underline, 50 # reverse and blink. Append more with a plus sign, e.g. "underline+bold". 51 # Leaving the field empty makes it fall back to the attributes of _default_. 52 # Use any other word (e.g. "none") to prevent fallback and disable all flags. 53 54 [skin] 55 description=Sand skin using 256 colors 56 57 [Lines] 58 horiz=─ 59 vert=│ 60 lefttop=┌ 61 righttop=┐ 62 leftbottom=└ 63 rightbottom=┘ 64 topmiddle=─ 65 bottommiddle=─ 66 leftmiddle=├ 67 rightmiddle=┤ 68 cross=┼ 69 dhoriz=─ 70 dvert=│ 71 dlefttop=┌ 72 drighttop=┐ 73 dleftbottom=└ 74 drightbottom=┘ 75 dtopmiddle=─ 76 dbottommiddle=─ 77 dleftmiddle=├ 78 drightmiddle=┤ 79 80 [core] 81 _default_=black;rgb554 82 selected=;rgb452 83 marked=rgb400 84 markselect=rgb400;rgb452 85 gauge=;rgb452 86 input=;rgb452 87 reverse=;rgb452 88 89 [dialog] 90 _default_=black;rgb553 91 dfocus=;rgb452 92 dhotnormal=;;underline 93 dhotfocus=;rgb452;underline 94 95 [error] 96 _default_=rgb554;rgb320;bold 97 errdhotnormal=;;bold+underline 98 errdhotfocus=black;rgb452;underline 99 100 [filehighlight] 101 directory= 102 executable=rgb030 103 symlink=rgb202 104 # 404 Not Found :) 105 stalelink=rgb404 106 device=rgb231 107 special=rgb331 108 core=rgb430 109 temp=gray15 110 archive=rgb012 111 doc=rgb103 112 source=rgb310 113 media=rgb024 114 graph=rgb033 115 database=rgb421 116 117 [menu] 118 _default_=black;rgb452 119 menuhot=;;underline 120 menusel=;rgb551 121 menuhotsel=;rgb551;underline 122 menuinactive= 123 124 [buttonbar] 125 hotkey=black;rgb554 126 button=black;rgb452 127 128 [help] 129 _default_=black;rgb553 130 helpitalic=green 131 helpbold=red 132 helplink=blue;;underline 133 helpslink=blue;;reverse 134 135 [editor] 136 _default_=black;rgb554 137 editbold=rgb400 138 editmarked=;rgb452 139 editwhitespace=rgb400;rgb553 140 editlinestate=;rgb553 141 bookmark=;rgb551 142 bookmarkfound=;rgb530 143 editrightmargin=rgb400;rgb553 144 145 [viewer] 146 viewunderline=;;underline 147 148 [diffviewer] 149 added=;rgb450 150 changedline=blue;rgb553 151 changednew=rgb400;rgb553 152 changed=;rgb553 153 removed=;rgb511 154 folder=;rgb530 155 error=rgb554;rgb320 156 157 [widget-common] 158 sort-sign-up = ↓ 159 sort-sign-down = ↑ 160 161 [widget-panel] 162 hiddenfiles-sign-show = • 163 hiddenfiles-sign-hide = ○ 164 history-prev-item-sign = « 165 history-next-item-sign = » 166 history-show-list-sign = ^ 167 168 [widget-scollbar] 169 first-vert-char=↑ 170 last-vert-char=↓ 171 first-horiz-char=« 172 last-horiz-char=» 173 current-char=■ 174 background-char=▒ -
src/args.c
diff -urN mc-4.7.2.orig/src/args.c mc-4.7.2/src/args.c
old new 312 312 313 313 mc_args__loc__colors_string = g_strdup_printf ("%s%s", 314 314 /* TRANSLATORS: don't translate keywords and names of colors */ 315 _("--colors KEYWORD={FORE},{BACK} \n\n"316 "{FORE} and {BACK} can be omitted, and the default will be used\n"315 _("--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n" 316 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n" 317 317 "\n" "Keywords:\n" 318 318 " Global: errors, reverse, gauge, input, viewunderline\n" 319 319 " File display: normal, selected, marked, markselect\n" … … 322 322 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n" 323 323 " Editor: editnormal, editbold, editmarked, editwhitespace,\n" 324 324 " editlinestate\n"), 325 /* TRANSLATORS: don't translate keywords and names of colors */325 /* TRANSLATORS: don't translate keywords and names of colors and attributes */ 326 326 _ 327 327 (" Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n" 328 "\n" " Colors:\n"328 "\n" "Standard colors:\n" 329 329 " black, gray, red, brightred, green, brightgreen, brown,\n" 330 330 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n" 331 " brightcyan, lightgray and white\n\n")); 331 " brightcyan, lightgray and white\n\n" 332 "Extended colors, when 256 colors are available:\n" 333 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n" 334 "Attributes:\n" 335 " bold, underline, reverse, blink; append more with '+'\n")); 332 336 333 337 return g_option_group_new ("color", mc_args__loc__colors_string, 334 338 _("Color options"), NULL, NULL); -
src/editor/syntax.c
diff -urN mc-4.7.2.orig/src/editor/syntax.c mc-4.7.2/src/editor/syntax.c
old new 736 736 #define check_not_a {if(*a){result=line;break;}} 737 737 738 738 static int 739 this_try_alloc_color_pair (const char *fg, const char *bg )739 this_try_alloc_color_pair (const char *fg, const char *bg, const char *attrs) 740 740 { 741 char f[80], b[80], *p;741 char f[80], b[80], a[80], *p; 742 742 743 743 if (bg != NULL && *bg == '\0') 744 744 bg = NULL; 745 745 if (fg != NULL && *fg == '\0') 746 746 fg = NULL; 747 if (attrs != NULL && *attrs == '\0') 748 attrs = NULL; 747 749 if (fg != NULL) 748 750 { 749 751 g_strlcpy (f, fg, sizeof (f)); … … 760 762 *p = '\0'; 761 763 bg = b; 762 764 } 763 return tty_try_alloc_color_pair (fg, bg); 765 if (attrs != NULL) 766 { 767 g_strlcpy (a, attrs, sizeof (a)); 768 p = strchr (a, '/'); 769 if (p != NULL) 770 *p = '\0'; 771 // get_args() mangles the + signs, unmangle 'em 772 p = a; 773 while ((p = strchr (p, SYNTAX_TOKEN_PLUS)) != NULL) 774 *p++ = '+'; 775 attrs = a; 776 } 777 return tty_try_alloc_color_pair (fg, bg, attrs); 764 778 } 765 779 766 780 static char *error_file_name = NULL; … … 812 826 edit_read_syntax_rules (WEdit * edit, FILE * f, char **args, int args_size) 813 827 { 814 828 FILE *g = NULL; 815 char *fg, *bg ;816 char last_fg[32] = "", last_bg[32] = "" ;829 char *fg, *bg, *attrs; 830 char last_fg[32] = "", last_bg[32] = "", last_attrs[64] = ""; 817 831 char whole_right[512]; 818 832 char whole_left[512]; 819 833 char *l = 0; … … 992 1006 bg = *a; 993 1007 if (*a) 994 1008 a++; 1009 attrs = *a; 1010 if (*a) 1011 a++; 995 1012 g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); 996 1013 g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg)); 997 c->keyword[0]->color = this_try_alloc_color_pair (fg, bg); 1014 g_strlcpy (last_attrs, attrs ? attrs : "", sizeof (last_attrs)); 1015 c->keyword[0]->color = this_try_alloc_color_pair (fg, bg, attrs); 998 1016 c->keyword[0]->keyword = g_strdup (" "); 999 1017 check_not_a; 1000 1018 … … 1061 1079 bg = *a; 1062 1080 if (*a) 1063 1081 a++; 1082 attrs = *a; 1083 if (*a) 1084 a++; 1064 1085 if (!fg) 1065 1086 fg = last_fg; 1066 1087 if (!bg) 1067 1088 bg = last_bg; 1068 k->color = this_try_alloc_color_pair (fg, bg); 1089 if (!attrs) 1090 attrs = last_attrs; 1091 k->color = this_try_alloc_color_pair (fg, bg, attrs); 1069 1092 check_not_a; 1070 1093 1071 1094 if (++num_words >= alloc_words_per_context)