Ticket #2169: mc-4.7.0.5-I_can_has_256_colorz.patch
File mc-4.7.0.5-I_can_has_256_colorz.patch, 35.4 KB (added by egmont, 14 years ago) |
---|
-
doc/man/mc.1.in
diff -urN mc-4.7.0.5.orig/doc/man/mc.1.in mc-4.7.0.5/doc/man/mc.1.in
old new 3210 3210 The format for the color definition is: 3211 3211 .PP 3212 3212 .nf 3213 <keyword>=< foregroundcolor>,<backgroundcolor>:<keyword>=...3213 <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>=... 3214 3214 .fi 3215 3215 .PP 3216 3216 The colors are optional, and the keywords are: normal, selected, marked, … … 3257 3257 .PP 3258 3258 The possible colors are: black, gray, red, brightred, green, 3259 3259 brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, 3260 cyan, brightcyan, lightgray and white. And there is a special keyword 3261 for transparent background. It is 'default'. The 'default' can only be 3262 used for background color. Example: 3260 cyan, brightcyan, lightgray and white. The special keyword "default" means 3261 the terminal's default. Another special keyword "base" means mc's main 3262 colors. When 256 colors are available, they can be specified either as 3263 color16 to color255, or as rgb000 to rgb555 and gray0 to gray23. Example: 3263 3264 .PP 3264 3265 .nf 3265 3266 [Colors] 3266 3267 base_color=normal=white,default:marked=magenta,default 3267 3268 .fi 3269 .PP 3270 Attributes can be any of bold, underline, reverse and blink, appended by a 3271 plus sign if more than one are desired. The special word "none" menas no 3272 attributes, without attempting to fall back to base_color. Example: 3273 .PP 3274 .nf 3275 menuhotsel=yellow;black;bold+underline 3276 .fi 3268 3277 3269 3278 .\"NODE "Skins" 3270 3279 .SH "Skins" … … 3497 3506 .SH " Color pair definitions" 3498 3507 Any parameter in skin\-file contain definition of color pair. 3499 3508 .PP 3500 Color pairs described as two colors separated by ';'. First color 3501 sets the foreground color, second color sets background color. 3502 One of the colors may be omitted, in this case color will be 3503 taken from default color pair (global color pair or 3504 from default color pair of this section). 3509 Color pairs described as two colors and the optional attributes 3510 separated by ';'. First field sets the foreground color, second 3511 field sets background color, third field sets the attributes. 3512 Any of the fields may be omitted, in this case value will be 3513 taken from default color pair (global color pair or from default 3514 color pair of this section). 3505 3515 .PP 3506 3516 Example: 3507 3517 .br … … 3509 3519 [core] 3510 3520 # green on black 3511 3521 _default_=green;black 3512 # green (default) 3522 # green (default) on blue 3513 3523 selected=;blue 3514 # yellow on black (default)3515 marked=yellow; 3524 # underlined yellow on black (default) 3525 marked=yellow;;underline 3516 3526 .fi 3517 3527 3518 3528 .PP 3519 Possible colors (names) described in3529 Possible colors (names) and attributes are described in 3520 3530 .\"LINK2" 3521 3531 Colors\&. 3522 3532 .\"Colors" -
doc/man/mcedit.1.in
diff -urN mc-4.7.0.5.orig/doc/man/mcedit.1.in mc-4.7.0.5/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 Because of the simplicity of the implementation, there are a few -
doc/man/mcview.1.in
diff -urN mc-4.7.0.5.orig/doc/man/mcview.1.in mc-4.7.0.5/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.0.5.orig/lib/skin/colors-old.c mc-4.7.0.5/lib/skin/colors-old.c
old new 123 123 return; 124 124 125 125 for (; *colors; colors++) { 126 key_val = g_strsplit_set (*colors, "=,", 3);126 key_val = g_strsplit_set (*colors, "=,", 4); 127 127 128 128 if (!key_val) 129 129 continue; … … 133 133 g_strfreev (key_val); 134 134 continue; 135 135 } 136 if (key_val[2] != NULL) 136 if (key_val[3] != NULL) 137 skin_val = g_strdup_printf ("%s;%s;%s", key_val[1], key_val[2], key_val[3]); 138 else if (key_val[2] != NULL) 137 139 skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]); 138 140 else 139 141 skin_val = g_strdup_printf ("%s;", key_val[1]); -
lib/skin/colors.c
diff -urN mc-4.7.0.5.orig/lib/skin/colors.c mc-4.7.0.5/lib/skin/colors.c
old new 138 138 return NULL; 139 139 } 140 140 141 switch (items_count) { 142 case 0: 143 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 144 if (tmp) { 145 mc_skin_color->fgcolor = g_strdup (tmp->fgcolor); 146 mc_skin_color->bgcolor = g_strdup (tmp->bgcolor); 147 } else { 148 g_strfreev (values); 149 g_free (mc_skin_color); 150 return NULL; 151 } 152 break; 153 case 1: 154 mc_skin_color->fgcolor = (values[0]) ? g_strstrip (g_strdup (values[0])) : NULL; 155 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 156 mc_skin_color->bgcolor = (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; 157 break; 158 case 2: 159 mc_skin_color->fgcolor = (values[0]) ? g_strstrip (g_strdup (values[0])) : NULL; 160 mc_skin_color->bgcolor = (values[1]) ? g_strstrip (g_strdup (values[1])) : NULL; 161 break; 162 } 141 tmp = mc_skin_color_get_with_defaults (group, "_default_"); 142 mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ? g_strstrip (g_strdup (values[0])) : 143 (tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL; 144 mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? g_strstrip (g_strdup (values[1])) : 145 (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; 146 mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? g_strstrip (g_strdup (values[2])) : 147 (tmp != NULL) ? g_strdup (tmp->attrs) : NULL; 148 163 149 g_strfreev (values); 164 150 165 151 mc_skin_color->pair_index = 166 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);152 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs, FALSE); 167 153 168 154 return mc_skin_color; 169 155 } … … 178 164 if (mc_skin_color != NULL) { 179 165 mc_skin_color->fgcolor = g_strdup ("default"); 180 166 mc_skin_color->bgcolor = g_strdup ("default"); 167 mc_skin_color->attrs = NULL; 181 168 mc_skin_color->pair_index = 182 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, FALSE);169 tty_try_alloc_color_pair2 (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs, FALSE); 183 170 mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color); 184 171 } 185 172 } … … 296 283 if (mc_skin_color == NULL) 297 284 return FALSE; 298 285 299 tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor );286 tty_color_set_defaults (mc_skin_color->fgcolor, mc_skin_color->bgcolor, mc_skin_color->attrs); 300 287 mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color); 301 288 302 289 for (; *groups != NULL; groups++) { -
lib/skin/common.c
diff -urN mc-4.7.0.5.orig/lib/skin/common.c mc-4.7.0.5/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.0.5.orig/lib/skin/internal.h mc-4.7.0.5/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.0.5.orig/lib/tty/color-internal.c mc-4.7.0.5/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.0.5.orig/lib/tty/color-internal.h mc-4.7.0.5/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 int 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.0.5.orig/lib/tty/color-ncurses.c mc-4.7.0.5/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.0.5.orig/lib/tty/color-slang.c mc-4.7.0.5/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.0.5.orig/lib/tty/color-slang.h mc-4.7.0.5/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.0.5.orig/lib/tty/color.c mc-4.7.0.5/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.0.5.orig/lib/tty/color.h mc-4.7.0.5/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.0.5.orig/lib/tty/tty-slang.c mc-4.7.0.5/lib/tty/tty-slang.c
old new 275 275 276 276 tty_reset_prog_mode (); 277 277 load_terminfo_keys (); 278 SLtt_Blink_Mode = 0;278 SLtt_Blink_Mode = 1; 279 279 280 280 tty_start_interrupt_key (); 281 281 -
misc/skins/Makefile.am
diff -urN mc-4.7.0.5.orig/misc/skins/Makefile.am mc-4.7.0.5/misc/skins/Makefile.am
old new 5 5 gotar.ini \ 6 6 darkfar.ini \ 7 7 featured.ini \ 8 double-lines.ini 8 double-lines.ini \ 9 sand256.ini 9 10 10 11 EXTRA_DIST = \ 11 12 $(skin_DATA) 13 No newline at end of file -
misc/skins/Makefile.in
diff -urN mc-4.7.0.5.orig/misc/skins/Makefile.in mc-4.7.0.5/misc/skins/Makefile.in
old new 310 310 gotar.ini \ 311 311 darkfar.ini \ 312 312 featured.ini \ 313 double-lines.ini 313 double-lines.ini \ 314 sand256.ini 314 315 315 316 EXTRA_DIST = \ 316 317 $(skin_DATA) -
misc/skins/sand256.ini
diff -urN mc-4.7.0.5.orig/misc/skins/sand256.ini mc-4.7.0.5/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 lefttop=┌ 59 righttop=┐ 60 centertop=─ 61 centerbottom=─ 62 leftbottom=└ 63 rightbottom=┘ 64 leftmiddle=├ 65 rightmiddle=┤ 66 centermiddle=┼ 67 horiz=─ 68 vert=│ 69 thinhoriz=─ 70 thinvert=│ 71 72 [core] 73 _default_=black;rgb554 74 selected=;rgb452 75 marked=rgb400 76 markselect=rgb400;rgb452 77 gauge=;rgb452 78 input=;rgb452 79 reverse=;rgb452 80 81 [dialog] 82 _default_=black;rgb553 83 dfocus=;rgb452 84 dhotnormal=;;underline 85 dhotfocus=;rgb452;underline 86 87 [error] 88 _default_=rgb554;rgb320;bold 89 errdhotnormal=;;bold+underline 90 errdhotfocus=black;rgb452;underline 91 92 [filehighlight] 93 directory= 94 executable=rgb030 95 symlink=rgb202 96 # 404 Not Found :) 97 stalelink=rgb404 98 device=rgb231 99 special=rgb331 100 core=rgb430 101 temp=gray15 102 archive=rgb012 103 doc=rgb103 104 source=rgb310 105 media=rgb024 106 graph=rgb033 107 database=rgb421 108 109 [menu] 110 _default_=black;rgb452 111 menuhot=;;underline 112 menusel=;rgb551 113 menuhotsel=;rgb551;underline 114 menuinactive= 115 116 [buttonbar] 117 hotkey=black;rgb554 118 button=black;rgb452 119 120 [help] 121 _default_=black;rgb553 122 helpitalic=green 123 helpbold=red 124 helplink=blue;;underline 125 helpslink=blue;;reverse 126 127 [editor] 128 _default_=black;rgb554 129 editbold=rgb400 130 editmarked=;rgb452 131 editwhitespace=rgb400;rgb553 132 editlinestate=;rgb553 133 bookmark=;rgb551 134 bookmarkfound=;rgb530 135 136 [viewer] 137 viewunderline=;;underline 138 139 [widget-common] 140 sort-sign-up = ↓ 141 sort-sign-down = ↑ 142 143 [widget-panel] 144 hiddenfiles-sign-show = • 145 hiddenfiles-sign-hide = ○ 146 history-prev-item-sign = « 147 history-next-item-sign = » 148 history-show-list-sign = ^ 149 150 [widget-scollbar] 151 first-vert-char=↑ 152 last-vert-char=↓ 153 first-horiz-char=« 154 last-horiz-char=» 155 current-char=■ 156 background-char=▒ -
src/args.c
diff -urN mc-4.7.0.5.orig/src/args.c mc-4.7.0.5/src/args.c
old new 300 300 301 301 mc_args__loc__colors_string = g_strdup_printf("%s%s", 302 302 /* TRANSLATORS: don't translate keywords and names of colors */ 303 _( "--colors KEYWORD={FORE},{BACK} \n\n"304 "{FORE} and {BACK} can be omitted, and the default will be used\n"303 _( "--colors KEYWORD={FORE},{BACK},{ATTR}:KEYWORD2=...\n\n" 304 "{FORE}, {BACK} and {ATTR} can be omitted, and the default will be used\n" 305 305 "\n" "Keywords:\n" 306 306 " Global: errors, reverse, gauge, input, viewunderline\n" 307 307 " File display: normal, selected, marked, markselect\n" … … 310 310 " Menus: menunormal, menuhot, menusel, menuhotsel, menuinactive\n" 311 311 " Editor: editnormal, editbold, editmarked, editwhitespace,\n" 312 312 " editlinestate\n"), 313 /* TRANSLATORS: don't translate keywords and names of colors */313 /* TRANSLATORS: don't translate keywords and names of colors and attributes */ 314 314 _( " Help: helpnormal, helpitalic, helpbold, helplink, helpslink\n" 315 "\n" " Colors:\n"315 "\n" "Standard colors:\n" 316 316 " black, gray, red, brightred, green, brightgreen, brown,\n" 317 317 " yellow, blue, brightblue, magenta, brightmagenta, cyan,\n" 318 " brightcyan, lightgray and white\n\n") 318 " brightcyan, lightgray and white\n\n" 319 "Extended colors, when 256 colors are available:\n" 320 " color16 to color255, or rgb000 to rgb555 and gray0 to gray23\n\n" 321 "Attributes:\n" 322 " bold, underline, reverse, blink; append more with '+'\n") 319 323 ); 320 324 321 325 return g_option_group_new ("color", mc_args__loc__colors_string, -
src/editor/syntax.c
diff -urN mc-4.7.0.5.orig/src/editor/syntax.c mc-4.7.0.5/src/editor/syntax.c
old new 646 646 #define check_not_a {if(*a){result=line;break;}} 647 647 648 648 static int 649 this_try_alloc_color_pair (const char *fg, const char *bg )649 this_try_alloc_color_pair (const char *fg, const char *bg, const char *attrs) 650 650 { 651 char f[80], b[80], *p;651 char f[80], b[80], a[80], *p; 652 652 653 653 if (bg) 654 654 if (!*bg) … … 656 656 if (fg) 657 657 if (!*fg) 658 658 fg = 0; 659 if (attrs) 660 if (!*attrs) 661 attrs = 0; 659 662 if (fg) { 660 663 g_strlcpy (f, fg, sizeof (f)); 661 664 p = strchr (f, '/'); … … 670 673 *p = '\0'; 671 674 bg = b; 672 675 } 673 return tty_try_alloc_color_pair (fg, bg); 676 if (attrs) { 677 g_strlcpy (a, attrs, sizeof (a)); 678 p = strchr (a, '/'); 679 if (p) 680 *p = '\0'; 681 // get_args() mangles the + signs, unmangle 'em 682 p = a; 683 while ((p = strchr (p, SYNTAX_TOKEN_PLUS)) != NULL) 684 *p++ = '+'; 685 attrs = a; 686 } 687 return tty_try_alloc_color_pair (fg, bg, attrs); 674 688 } 675 689 676 690 static char *error_file_name = 0; … … 710 724 edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) 711 725 { 712 726 FILE *g = NULL; 713 char *fg, *bg ;714 char last_fg[32] = "", last_bg[32] = "" ;727 char *fg, *bg, *attrs; 728 char last_fg[32] = "", last_bg[32] = "", last_attrs[64] = ""; 715 729 char whole_right[512]; 716 730 char whole_left[512]; 717 731 char *l = 0; … … 844 858 bg = *a; 845 859 if (*a) 846 860 a++; 861 attrs = *a; 862 if (*a) 863 a++; 847 864 g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); 848 865 g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg)); 849 c->keyword[0]->color = this_try_alloc_color_pair (fg, bg); 866 g_strlcpy (last_attrs, attrs ? attrs : "", sizeof (last_attrs)); 867 c->keyword[0]->color = this_try_alloc_color_pair (fg, bg, attrs); 850 868 c->keyword[0]->keyword = g_strdup (" "); 851 869 check_not_a; 852 870 … … 900 918 bg = *a; 901 919 if (*a) 902 920 a++; 921 attrs = *a; 922 if (*a) 923 a++; 903 924 if (!fg) 904 925 fg = last_fg; 905 926 if (!bg) 906 927 bg = last_bg; 907 k->color = this_try_alloc_color_pair (fg, bg); 928 if (!attrs) 929 attrs = last_attrs; 930 k->color = this_try_alloc_color_pair (fg, bg, attrs); 908 931 check_not_a; 909 932 910 933 if (++num_words >= alloc_words_per_context) {