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, 15 years ago)

Ze patch for 4.7.0.5

  • 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  
    32103210The format for the color definition is: 
    32113211.PP 
    32123212.nf 
    3213   <keyword>=<foregroundcolor>,<backgroundcolor>:<keyword>= ... 
     3213  <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>=... 
    32143214.fi 
    32153215.PP 
    32163216The colors are optional, and the keywords are: normal, selected, marked, 
     
    32573257.PP 
    32583258The possible colors are: black, gray, red, brightred, green, 
    32593259brightgreen, 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: 
     3260cyan, brightcyan, lightgray and white. The special keyword "default" means 
     3261the terminal's default. Another special keyword "base" means mc's main 
     3262colors.  When 256 colors are available, they can be specified either as 
     3263color16 to color255, or as rgb000 to rgb555 and gray0 to gray23. Example: 
    32633264.PP 
    32643265.nf 
    32653266[Colors] 
    32663267base_color=normal=white,default:marked=magenta,default 
    32673268.fi 
     3269.PP 
     3270Attributes can be any of bold, underline, reverse and blink, appended by a 
     3271plus sign if more than one are desired.  The special word "none" menas no 
     3272attributes, without attempting to fall back to base_color.  Example: 
     3273.PP 
     3274.nf 
     3275menuhotsel=yellow;black;bold+underline 
     3276.fi 
    32683277 
    32693278.\"NODE "Skins" 
    32703279.SH "Skins" 
     
    34973506.SH "  Color pair definitions" 
    34983507Any parameter in skin\-file contain definition of color pair. 
    34993508.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). 
     3509Color pairs described as two colors and the optional attributes 
     3510separated by ';'. First field sets the foreground color, second 
     3511field sets background color, third field sets the attributes. 
     3512Any of the fields may be omitted, in this case value will be 
     3513taken from default color pair (global color pair or from default 
     3514color pair of this section). 
    35053515.PP 
    35063516Example: 
    35073517.br 
     
    35093519[core] 
    35103520    # green on black 
    35113521    _default_=green;black 
    3512     # green (default)  on blue 
     3522    # green (default) on blue 
    35133523    selected=;blue 
    3514     # yellow on black (default) 
    3515     marked=yellow; 
     3524    # underlined yellow on black (default) 
     3525    marked=yellow;;underline 
    35163526.fi 
    35173527 
    35183528.PP 
    3519 Possible colors (names) described in 
     3529Possible colors (names) and attributes are described in 
    35203530.\"LINK2" 
    35213531Colors\&. 
    35223532.\"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  
    3333Force ANSI color mode on terminals that don't seem to have color 
    3434support. 
    3535.TP 
    36 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..." 
     36.I "\-C <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>= ..." 
    3737Specify a different color set.  See the 
    3838.B Colors 
    3939section in mc(1) for more information. 
     
    249249.I delim 
    250250.RI [ foreground ] 
    251251.RI [ background ] 
     252.RI [ attributes ] 
    252253.PP 
    253254The first context is an exception.  It must start with the command 
    254255.PP 
    255256.B context default 
    256257.RI [ foreground ] 
    257258.RI [ background ] 
     259.RI [ attributes ] 
    258260.PP 
    259261otherwise 
    260262.B mcedit 
     
    294296.RB [ linestart ] 
    295297.I string foreground 
    296298.RI [ background ] 
     299.RI [ attributes ] 
    297300.PP 
    298301Context or keyword strings are interpreted, so that you can include tabs 
    299302and spaces with the sequences \\t and \\s.  Newlines and backslashes are 
     
    331334.PP 
    332335The possible colors are: black, gray, red, brightred, green, 
    333336brightgreen, brown, yellow, blue, brightblue, magenta, brightmagenta, 
    334 cyan, brightcyan, lightgray and white.  If the syntax file is shared 
     337cyan, brightcyan, lightgray and white. The special keyword "default" means 
     338the terminal's default. Another special keyword "base" means mc's main 
     339colors, it is useful as a placeholder if you want to specify attributes 
     340without modifying the background color. When 256 colors are available, 
     341they can be specified either as color16 to color255, or as rgb000 to rgb555 
     342and gray0 to gray23. 
     343.PP 
     344If the syntax file is shared 
    335345with 
    336346.BR cooledit , 
    337347it is possible to specify different colors for 
     
    349359.B cooledit 
    350360colors. 
    351361.PP 
     362Attributes can be any of bold, underline, reverse and blink, appended by a 
     363plus sign if more than one are desired. 
     364.PP 
    352365Comments may be put on a separate line starting with the hash sign (#). 
    353366.PP 
    354367Because 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  
    2323.B mcview 
    2424defaults to black and white. 
    2525.TP 
    26 .I "\-C <keyword>=<FGcolor>,<BGcolor>:<keyword>= ..." 
     26.I "\-C <keyword>=<FGcolor>,<BGcolor>,<Attributes>:<keyword>= ..." 
    2727Specify a different color set.  See the 
    2828.B Colors 
    2929section 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  
    123123        return; 
    124124 
    125125    for (; *colors; colors++) { 
    126         key_val = g_strsplit_set (*colors, "=,", 3); 
     126        key_val = g_strsplit_set (*colors, "=,", 4); 
    127127 
    128128        if (!key_val) 
    129129            continue; 
     
    133133            g_strfreev (key_val); 
    134134            continue; 
    135135        } 
    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) 
    137139            skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]); 
    138140        else 
    139141            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  
    138138        return NULL; 
    139139    } 
    140140 
    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 
    163149    g_strfreev (values); 
    164150 
    165151    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); 
    167153 
    168154    return mc_skin_color; 
    169155} 
     
    178164    if (mc_skin_color != NULL) { 
    179165        mc_skin_color->fgcolor = g_strdup ("default"); 
    180166        mc_skin_color->bgcolor = g_strdup ("default"); 
     167        mc_skin_color->attrs = NULL; 
    181168        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); 
    183170        mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color); 
    184171    } 
    185172} 
     
    296283    if (mc_skin_color == NULL) 
    297284        return FALSE; 
    298285 
    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); 
    300287    mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color); 
    301288 
    302289    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  
    6262    mc_skin_color_t *mc_skin_color = (mc_skin_color_t *) data; 
    6363    g_free (mc_skin_color->fgcolor); 
    6464    g_free (mc_skin_color->bgcolor); 
     65    g_free (mc_skin_color->attrs); 
    6566    g_free (mc_skin_color); 
    6667} 
    6768 
  • 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  
    1313typedef struct mc_skin_color_struct { 
    1414    gchar *fgcolor; 
    1515    gchar *bgcolor; 
     16    gchar *attrs; 
    1617    int pair_index; 
    1718} mc_skin_color_t; 
    1819 
  • 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  
    4747/*** file scope variables ************************************************************************/ 
    4848 
    4949mc_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  }, 
    6666    { "default",       -1 }, /* default color of the terminal */ 
    6767    /* special colors */ 
    6868    { "A_REVERSE",      SPEC_A_REVERSE }, 
     
    7373    { NULL, 0} 
    7474}; 
    7575 
     76mc_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 
    7685/*** file scope functions ************************************************************************/ 
    7786/* --------------------------------------------------------------------------------------------- */ 
    7887 
     88static int 
     89parse_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 
    79109/*** public functions ****************************************************************************/ 
    80110/* --------------------------------------------------------------------------------------------- */ 
    81111 
    82112const char * 
    83 tty_color_get_valid_name (const char *color_name) 
     113tty_color_get_name_by_index (int idx) 
    84114{ 
     115    static char **color_N_names = NULL; 
    85116    int i; 
    86117 
    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"; 
    92135} 
    93136 
    94137/* --------------------------------------------------------------------------------------------- */ 
     
    98141{ 
    99142    int i; 
    100143 
    101     if (color_name != NULL) 
     144    if (color_name != NULL) { 
    102145        for (i = 0; color_table[i].name != NULL; i++) 
    103146            if (strcmp (color_name, color_table[i].name) == 0) 
    104147                return color_table[i].value; 
     148        return parse_256_color_name(color_name); 
     149    } 
    105150    return -1; 
    106151} 
    107152 
    108153/* --------------------------------------------------------------------------------------------- */ 
     154 
     155int 
     156tty_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  
    2121 
    2222typedef struct mc_color_pair_struct 
    2323{ 
    24     const char *cfg; 
    25     const char *cbg; 
    2624    int ifg; 
    2725    int ibg; 
     26    int attr; 
    2827    int pair_index; 
    2928    gboolean is_temp; 
    3029} tty_color_pair_t; 
     
    3837} tty_special_color_t; 
    3938/* *INDENT-ON* */ 
    4039 
    41 const char *tty_color_get_valid_name (const char *); 
     40const char *tty_color_get_name_by_index (int); 
    4241int tty_color_get_index_by_name (const char *); 
     42int tty_attr_get_bits (const char *); 
    4343 
    4444void tty_color_init_lib (gboolean, gboolean); 
    4545void 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  
    5757 
    5858/* --------------------------------------------------------------------------------------------- */ 
    5959 
    60 static int 
    61 mc_tty_color_save_attr_lib (int color_pair, int color_attr) 
     60static void 
     61mc_tty_color_save_attr (int color_pair, int color_attr) 
    6262{ 
    6363    int *attr, *key; 
    6464    attr = g_try_new0 (int, 1); 
    6565    if (attr == NULL) 
    66         return color_attr; 
     66        return; 
    6767 
    6868    key = g_try_new (int, 1); 
    6969    if (key == NULL) { 
    7070        g_free (attr); 
    71         return color_attr; 
     71        return; 
    7272    } 
    7373 
    7474    *key = color_pair; 
     75    *attr = color_attr; 
    7576 
    76     if (color_attr != -1) 
    77         *attr = color_attr & (A_BOLD | A_REVERSE | A_UNDERLINE); 
    7877    g_hash_table_replace (mc_tty_color_color_pair_attrs, (gpointer) key, (gpointer) attr); 
    79     return color_attr & (~(*attr)); 
    8078} 
    8179 
    8280/* --------------------------------------------------------------------------------------------- */ 
     
    9593 
    9694static void 
    9795mc_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) 
    9997{ 
    10098    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); 
    103100    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); 
    106103} 
    107104 
    108105/* --------------------------------------------------------------------------------------------- */ 
     
    138135void 
    139136tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair) 
    140137{ 
    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) { 
    143146        case SPEC_A_REVERSE: 
    144147            mc_tty_color_pair_init_special (mc_color_pair, 
    145148                                            COLOR_BLACK, COLOR_WHITE, 
     
    162165            break; 
    163166        } 
    164167    } 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        } 
    167173 
    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); 
    172176    } 
    173177} 
    174178 
  • 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  
    133133            break; 
    134134        } 
    135135    } 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); 
    138138        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); 
    139140    } 
    140141} 
    141142 
  • 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  
    2020}; 
    2121 
    2222/* When using Slang with color, we have all the indexes free but 
    23  * those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BOLD_REVERSE) 
     23 * those defined here (A_BOLD, A_UNDERLINE, A_REVERSE, A_BLINK) 
    2424 */ 
    2525 
    2626#ifndef A_BOLD 
    2727#define A_BOLD SLTT_BOLD_MASK 
    2828#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 */ 
    2938 
    3039#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  
    4646 
    4747static char *tty_color_defaults__fg = NULL; 
    4848static char *tty_color_defaults__bg = NULL; 
     49static char *tty_color_defaults__attrs = NULL; 
    4950 
    5051/* Set if we are actually using colors */ 
    5152gboolean use_colors = FALSE; 
     
    155156    tty_color_deinit_lib (); 
    156157    g_free (tty_color_defaults__fg); 
    157158    g_free (tty_color_defaults__bg); 
     159    g_free (tty_color_defaults__attrs); 
    158160 
    159161    g_hash_table_destroy (mc_tty_color__hashtable); 
    160162} 
     
    170172/* --------------------------------------------------------------------------------------------- */ 
    171173 
    172174int 
    173 tty_try_alloc_color_pair2 (const char *fg, const char *bg, gboolean is_temp_color) 
     175tty_try_alloc_color_pair2 (const char *fg, const char *bg, const char *attrs, gboolean is_temp_color) 
    174176{ 
    175177    gchar *color_pair; 
    176178    tty_color_pair_t *mc_color_pair; 
    177     const char *c_fg, *c_bg; 
     179    int ifg, ibg, attr; 
    178180 
    179     if (fg == NULL) 
     181    if (fg == NULL || !strcmp(fg, "base")) 
    180182        fg = tty_color_defaults__fg; 
    181  
    182     if (bg == NULL) 
    183     { 
     183    if (bg == NULL || !strcmp(bg, "base")) 
    184184        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); 
    188191 
    189     color_pair = g_strdup_printf ("%s.%s", c_fg, c_bg); 
     192    color_pair = g_strdup_printf ("%d.%d.%d", ifg, ibg, attr); 
    190193    if (color_pair == NULL) 
    191194        return 0; 
    192195 
     
    207210    } 
    208211 
    209212    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; 
    214216    mc_color_pair->pair_index = tty_color_get_next__color_pair_number (); 
    215217 
    216218    tty_color_try_alloc_pair_lib (mc_color_pair); 
     
    223225/* --------------------------------------------------------------------------------------------- */ 
    224226 
    225227int 
    226 tty_try_alloc_color_pair (const char *fg, const char *bg) 
     228tty_try_alloc_color_pair (const char *fg, const char *bg, const char *attrs) 
    227229{ 
    228     return tty_try_alloc_color_pair2 (fg, bg, TRUE); 
     230    return tty_try_alloc_color_pair2 (fg, bg, attrs, TRUE); 
    229231} 
    230232 
    231233/* --------------------------------------------------------------------------------------------- */ 
     
    247249/* --------------------------------------------------------------------------------------------- */ 
    248250 
    249251void 
    250 tty_color_set_defaults (const char *fgcolor, const char *bgcolor) 
     252tty_color_set_defaults (const char *fgcolor, const char *bgcolor, const char *attrs) 
    251253{ 
    252254    g_free (tty_color_defaults__fg); 
    253255    g_free (tty_color_defaults__fg); 
     256    g_free (tty_color_defaults__attrs); 
    254257 
    255258    tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL; 
    256259    tty_color_defaults__bg = (bgcolor != NULL) ? g_strdup (bgcolor) : NULL; 
     260    tty_color_defaults__attrs = (attrs != NULL) ? g_strdup (attrs) : NULL; 
    257261} 
    258262 
    259263/* --------------------------------------------------------------------------------------------- */ 
  • 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  
    2727void tty_colors_done (void); 
    2828 
    2929gboolean 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); 
     30int tty_try_alloc_color_pair (const char *, const char *, const char *); 
     31int tty_try_alloc_color_pair2 (const char *, const char *, const char *, gboolean); 
    3232 
    3333void tty_color_free_all_tmp (void); 
    3434void tty_color_free_all_non_tmp (void); 
     
    3737void tty_lowlevel_setcolor (int color); 
    3838void tty_set_normal_attrs (void); 
    3939 
    40 void tty_color_set_defaults (const char *, const char *); 
     40void tty_color_set_defaults (const char *, const char *, const char *); 
    4141 
    4242#define ALLOC_COLOR_PAIR_INDEX 1 
    4343 
  • 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  
    275275 
    276276    tty_reset_prog_mode (); 
    277277    load_terminfo_keys (); 
    278     SLtt_Blink_Mode = 0; 
     278    SLtt_Blink_Mode = 1; 
    279279 
    280280    tty_start_interrupt_key (); 
    281281 
  • 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  
    55        gotar.ini \ 
    66        darkfar.ini \ 
    77        featured.ini \ 
    8         double-lines.ini 
     8        double-lines.ini \ 
     9        sand256.ini 
    910 
    1011EXTRA_DIST = \ 
    1112    $(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  
    310310        gotar.ini \ 
    311311        darkfar.ini \ 
    312312        featured.ini \ 
    313         double-lines.ini 
     313        double-lines.ini \ 
     314        sand256.ini 
    314315 
    315316EXTRA_DIST = \ 
    316317    $(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  
    300300 
    301301    mc_args__loc__colors_string = g_strdup_printf("%s%s", 
    302302        /* 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" 
    305305            "\n" "Keywords:\n" 
    306306            "   Global:       errors, reverse, gauge, input, viewunderline\n" 
    307307            "   File display: normal, selected, marked, markselect\n" 
     
    310310            "   Menus:        menunormal, menuhot, menusel, menuhotsel, menuinactive\n" 
    311311            "   Editor:       editnormal, editbold, editmarked, editwhitespace,\n" 
    312312            "                 editlinestate\n"), 
    313         /* TRANSLATORS: don't translate keywords and names of colors */ 
     313        /* TRANSLATORS: don't translate keywords and names of colors and attributes */ 
    314314        _(  "   Help:         helpnormal, helpitalic, helpbold, helplink, helpslink\n" 
    315             "\n" "Colors:\n" 
     315            "\n" "Standard colors:\n" 
    316316            "   black, gray, red, brightred, green, brightgreen, brown,\n" 
    317317            "   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") 
    319323    ); 
    320324 
    321325    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  
    646646#define check_not_a {if(*a){result=line;break;}} 
    647647 
    648648static int 
    649 this_try_alloc_color_pair (const char *fg, const char *bg) 
     649this_try_alloc_color_pair (const char *fg, const char *bg, const char *attrs) 
    650650{ 
    651     char f[80], b[80], *p; 
     651    char f[80], b[80], a[80], *p; 
    652652 
    653653    if (bg) 
    654654        if (!*bg) 
     
    656656    if (fg) 
    657657        if (!*fg) 
    658658            fg = 0; 
     659    if (attrs) 
     660        if (!*attrs) 
     661            attrs = 0; 
    659662    if (fg) { 
    660663        g_strlcpy (f, fg, sizeof (f)); 
    661664        p = strchr (f, '/'); 
     
    670673            *p = '\0'; 
    671674        bg = b; 
    672675    } 
    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); 
    674688} 
    675689 
    676690static char *error_file_name = 0; 
     
    710724edit_read_syntax_rules (WEdit *edit, FILE *f, char **args, int args_size) 
    711725{ 
    712726    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] = ""; 
    715729    char whole_right[512]; 
    716730    char whole_left[512]; 
    717731    char *l = 0; 
     
    844858            bg = *a; 
    845859            if (*a) 
    846860                a++; 
     861            attrs = *a; 
     862            if (*a) 
     863                a++; 
    847864            g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); 
    848865            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); 
    850868            c->keyword[0]->keyword = g_strdup (" "); 
    851869            check_not_a; 
    852870 
     
    900918            bg = *a; 
    901919            if (*a) 
    902920                a++; 
     921            attrs = *a; 
     922            if (*a) 
     923                a++; 
    903924            if (!fg) 
    904925                fg = last_fg; 
    905926            if (!bg) 
    906927                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); 
    908931            check_not_a; 
    909932 
    910933            if (++num_words >= alloc_words_per_context) {