Ticket #3711: mc-3711-color-aliases.patch

File mc-3711-color-aliases.patch, 10.8 KB (added by egmont, 7 years ago)
  • doc/man/mc.1.in

    diff --git a/doc/man/mc.1.in b/doc/man/mc.1.in
    index 2413b1e..3c8f4a9 100644
    a b Color pair definitions 
    37083708.\"Skins colors" 
    37093709.br 
    37103710.\"LINK2" 
     3711Color and attribute aliases 
     3712.\"Skins aliases" 
     3713.br 
     3714.\"LINK2" 
    37113715Draw lines 
    37123716.\"Skins lines" 
    37133717.br 
    Colors\&. 
    39153919.\"Colors" 
    39163920section. 
    39173921 
     3922.\"NODE "  Skins aliases" 
     3923.SH "  Color and attribute aliases" 
     3924This optional section might define aliases for single colors (not color pairs) 
     3925as well as combination of attributes; in other words, for semicolon-separated 
     3926fragments of parameters. Aliases are not recursive, they might not refer to 
     3927other aliases. 
     3928.PP 
     3929Example: 
     3930.br 
     3931.nf 
     3932[aliases] 
     3933    myfavfg=green 
     3934    myfavbg=black 
     3935    myfavattr=bold+italic 
     3936[core] 
     3937    _default_=myfavfg;myfavbg;myfavattr 
     3938.fi 
     3939 
    39183940.\"NODE "  Skins lines" 
    39193941.SH "  Draw lines" 
    39203942Lines sets in section 
  • lib/skin/colors.c

    diff --git a/lib/skin/colors.c b/lib/skin/colors.c
    index 7f55684..ccbfb76 100644
    a b mc_skin_color_get_with_defaults (const gchar * group, const gchar * name) 
    120120 
    121121/* --------------------------------------------------------------------------------------------- */ 
    122122 
     123/* If an alias is found, alloc a new string for the resolved value and free the input parameter. 
     124   Otherwise it's a no-op returning the original string. */ 
     125static gchar * 
     126mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str) 
     127{ 
     128    gsize items_count; 
     129    gchar **values; 
     130    gchar *ret = str; 
     131 
     132    values = mc_config_get_string_list (mc_skin->config, "aliases", str, &items_count); 
     133    if (items_count == 1) 
     134    { 
     135        g_free (str); 
     136        ret = g_strdup (values[0]); 
     137    } 
     138    g_strfreev (values); 
     139    return ret; 
     140} 
     141 
     142/* --------------------------------------------------------------------------------------------- */ 
     143 
    123144static mc_skin_color_t * 
    124145mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key) 
    125146{ 
    mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const 
    142163    } 
    143164 
    144165    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])) : 
     166    mc_skin_color->fgcolor = (items_count > 0 && values[0][0]) ? 
     167        mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[0]))) : 
    146168        (tmp != NULL) ? g_strdup (tmp->fgcolor) : NULL; 
    147     mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? g_strstrip (g_strdup (values[1])) : 
     169    mc_skin_color->bgcolor = (items_count > 1 && values[1][0]) ? 
     170        mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[1]))) : 
    148171        (tmp != NULL) ? g_strdup (tmp->bgcolor) : NULL; 
    149     mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? g_strstrip (g_strdup (values[2])) : 
     172    mc_skin_color->attrs = (items_count > 2 && values[2][0]) ? 
     173        mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[2]))) : 
    150174        (tmp != NULL) ? g_strdup (tmp->attrs) : NULL; 
    151175 
    152176    g_strfreev (values); 
    mc_skin_color_cache_init (void) 
    265289static gboolean 
    266290mc_skin_color_check_inisection (const gchar * group) 
    267291{ 
    268     return !((strcasecmp ("skin", group) == 0) 
     292    return !((strcasecmp ("skin", group) == 0) || (strcasecmp ("aliases", group) == 0) 
    269293             || (strcasecmp ("lines", group) == 0) || (strncasecmp ("widget-", group, 7) == 0)); 
    270294} 
    271295 
  • misc/skins/gray-green-purple256.ini

    diff --git a/misc/skins/gray-green-purple256.ini b/misc/skins/gray-green-purple256.ini
    index 964b26f..f6ea39a 100644
    a b  
    2525    dleftmiddle = ╟ 
    2626    drightmiddle = ╢ 
    2727 
     28[aliases] 
     29    bgmain = gray22 
     30    bgbitdarker = gray21 
     31    bgdarker = gray20 
     32    main1 = rgb141 
     33    main2 = rgb303 
     34 
    2835[core] 
    29     _default_ = black;gray22 
    30     selected = ;rgb141 
    31     marked = rgb303;;bold 
    32     markselect = rgb303;rgb141;bold 
    33     gauge = ;rgb141 
     36    _default_ = black;bgmain 
     37    selected = ;main1 
     38    marked = main2;;bold 
     39    markselect = main2;main1;bold 
     40    gauge = ;main1 
    3441    input = 
    3542    inputunchanged = gray 
    36     inputmark = ;rgb141 
    37     disabled = gray8;gray20 
     43    inputmark = ;main1 
     44    disabled = gray8;bgdarker 
    3845    reverse = 
    39     commandlinemark = ;rgb141 
    40     header = rgb303 
     46    commandlinemark = ;main1 
     47    header = main2 
    4148 
    4249[dialog] 
    43     _default_ = black;gray20 
    44     dfocus = ;rgb141 
    45     dhotnormal = rgb303 
    46     dhotfocus = rgb303;rgb141 
    47     dtitle = rgb303 
     50    _default_ = black;bgdarker 
     51    dfocus = ;main1 
     52    dhotnormal = main2 
     53    dhotfocus = main2;main1 
     54    dtitle = main2 
    4855 
    4956[error] 
    5057    # "white" might change color when going bold, so use "rgb555" instead 
    5158    _default_ = rgb555;rgb400;bold 
    52     errdfocus = ;rgb303 
    53     errdhotnormal = rgb141 
    54     errdhotfocus = rgb141;rgb303 
    55     errdtitle = rgb141 
     59    errdfocus = ;main2 
     60    errdhotnormal = main1 
     61    errdhotfocus = main1;main2 
     62    errdtitle = main1 
    5663 
    5764[filehighlight] 
    5865    directory = 
     
    7279    database = rgb421 
    7380 
    7481[menu] 
    75     _default_ = black;gray20 
    76     menusel = ;rgb141 
    77     menuhot = rgb303 
    78     menuhotsel = rgb303;rgb141 
     82    _default_ = black;bgdarker 
     83    menusel = ;main1 
     84    menuhot = main2 
     85    menuhotsel = main2;main1 
    7986    menuinactive = 
    8087 
    8188[popupmenu] 
    82     _default_ = black;gray20 
    83     menusel = ;rgb141 
    84     menutitle = rgb303 
     89    _default_ = black;bgdarker 
     90    menusel = ;main1 
     91    menutitle = main2 
    8592 
    8693[buttonbar] 
    87     hotkey = black;gray22 
    88     button = black;gray20 
     94    hotkey = black;bgmain 
     95    button = black;bgdarker 
    8996 
    9097[statusbar] 
    91     _default_ = black;gray20 
     98    _default_ = black;bgdarker 
    9299 
    93100[help] 
    94     _default_ = black;gray20 
     101    _default_ = black;bgdarker 
    95102    helpitalic = rgb020 
    96103    helpbold = rgb300 
    97     helplink = rgb303;;underline 
    98     helpslink = gray20;rgb303 
    99     helptitle = rgb303 
     104    helplink = main2;;underline 
     105    helpslink = bgdarker;main2 
     106    helptitle = main2 
    100107 
    101108[editor] 
    102     _default_ = black;gray22 
     109    _default_ = black;bgmain 
    103110    editbold = rgb400 
    104     editmarked = ;rgb141 
    105     editwhitespace = rgb400;gray20 
    106     editlinestate = ;gray20 
     111    editmarked = ;main1 
     112    editwhitespace = rgb400;bgdarker 
     113    editlinestate = ;bgdarker 
    107114    bookmark = ;rgb531 
    108     bookmarkfound = ;rgb303 
    109     editrightmargin = rgb400;gray20 
     115    bookmarkfound = ;main2 
     116    editrightmargin = rgb400;bgdarker 
    110117#    editbg = 
    111     editframe = rgb303; 
     118    editframe = main2; 
    112119    editframeactive = black; 
    113120    editframedrag = rgb400; 
    114121    window-state-char = ↕ 
    115122    window-close-char = ✕ 
    116123 
    117124[viewer] 
    118     _default_ = black;gray22 
     125    _default_ = black;bgmain 
    119126    # "black" might change color when going bold, so use "rgb000" instead 
    120127    viewbold = rgb000;;bold 
    121128    viewunderline = ;;underline 
    122     viewselected = rgb303;rgb141;bold 
     129    viewselected = main2;main1;bold 
    123130 
    124131[diffviewer] 
    125132    added = ;rgb340 
    126     changedline = ;gray20 
    127     changednew = rgb303;gray20 
    128     changed = ;gray21 
     133    changedline = ;bgdarker 
     134    changednew = main2;bgdarker 
     135    changed = ;bgbitdarker 
    129136    removed = ;rgb511 
    130137    # "white" might change color when going bold, so use "rgb555" instead 
    131138    error = rgb555;rgb400;bold 
  • misc/skins/gray-orange-blue256.ini

    diff --git a/misc/skins/gray-orange-blue256.ini b/misc/skins/gray-orange-blue256.ini
    index f8426f1..027b679 100644
    a b  
    2525    dleftmiddle = ╟ 
    2626    drightmiddle = ╢ 
    2727 
     28[aliases] 
     29    bgmain = gray22 
     30    bgbitdarker = gray21 
     31    bgdarker = gray20 
     32    main1 = rgb530 
     33    main2 = rgb004 
     34 
    2835[core] 
    29     _default_ = black;gray22 
    30     selected = ;rgb530 
    31     marked = rgb004;;bold 
    32     markselect = rgb004;rgb530;bold 
    33     gauge = ;rgb530 
     36    _default_ = black;bgmain 
     37    selected = ;main1 
     38    marked = main2;;bold 
     39    markselect = main2;main1;bold 
     40    gauge = ;main1 
    3441    input = 
    3542    inputunchanged = gray 
    36     inputmark = ;rgb530 
    37     disabled = gray8;gray20 
     43    inputmark = ;main1 
     44    disabled = gray8;bgdarker 
    3845    reverse = 
    39     commandlinemark = ;rgb530 
    40     header = rgb004 
     46    commandlinemark = ;main1 
     47    header = main2 
    4148 
    4249[dialog] 
    43     _default_ = black;gray20 
    44     dfocus = ;rgb530 
    45     dhotnormal = rgb004 
    46     dhotfocus = rgb004;rgb530 
    47     dtitle = rgb004 
     50    _default_ = black;bgdarker 
     51    dfocus = ;main1 
     52    dhotnormal = main2 
     53    dhotfocus = main2;main1 
     54    dtitle = main2 
    4855 
    4956[error] 
    5057    # "white" might change color when going bold, so use "rgb555" instead 
    5158    _default_ = rgb555;rgb400;bold 
    52     errdfocus = ;rgb004 
    53     errdhotnormal = rgb530 
    54     errdhotfocus = rgb530;rgb004 
    55     errdtitle = rgb530 
     59    errdfocus = ;main2 
     60    errdhotnormal = main1 
     61    errdhotfocus = main1;main2 
     62    errdtitle = main1 
    5663 
    5764[filehighlight] 
    5865    directory = 
     
    7279    database = rgb421 
    7380 
    7481[menu] 
    75     _default_ = black;gray20 
    76     menusel = ;rgb530 
    77     menuhot = rgb004 
    78     menuhotsel = rgb004;rgb530 
     82    _default_ = black;bgdarker 
     83    menusel = ;main1 
     84    menuhot = main2 
     85    menuhotsel = main2;main1 
    7986    menuinactive = 
    8087 
    8188[popupmenu] 
    82     _default_ = black;gray20 
    83     menusel = ;rgb530 
    84     menutitle = rgb004 
     89    _default_ = black;bgdarker 
     90    menusel = ;main1 
     91    menutitle = main2 
    8592 
    8693[buttonbar] 
    87     hotkey = black;gray22 
    88     button = black;gray20 
     94    hotkey = black;bgmain 
     95    button = black;bgdarker 
    8996 
    9097[statusbar] 
    91     _default_ = black;gray20 
     98    _default_ = black;bgdarker 
    9299 
    93100[help] 
    94     _default_ = black;gray20 
     101    _default_ = black;bgdarker 
    95102    helpitalic = rgb020 
    96103    helpbold = rgb300 
    97     helplink = rgb004;;underline 
    98     helpslink = gray20;rgb004 
    99     helptitle = rgb004 
     104    helplink = main2;;underline 
     105    helpslink = bgdarker;main2 
     106    helptitle = main2 
    100107 
    101108[editor] 
    102     _default_ = black;gray22 
     109    _default_ = black;bgmain 
    103110    editbold = rgb400 
    104     editmarked = ;rgb530 
    105     editwhitespace = rgb400;gray20 
    106     editlinestate = ;gray20 
     111    editmarked = ;main1 
     112    editwhitespace = rgb400;bgdarker 
     113    editlinestate = ;bgdarker 
    107114    bookmark = ;rgb531 
    108     bookmarkfound = ;rgb004 
    109     editrightmargin = rgb400;gray20 
     115    bookmarkfound = ;main2 
     116    editrightmargin = rgb400;bgdarker 
    110117#    editbg = 
    111     editframe = rgb004; 
     118    editframe = main2; 
    112119    editframeactive = black; 
    113120    editframedrag = rgb400; 
    114121    window-state-char = ↕ 
    115122    window-close-char = ✕ 
    116123 
    117124[viewer] 
    118     _default_ = black;gray22 
     125    _default_ = black;bgmain 
    119126    # "black" might change color when going bold, so use "rgb000" instead 
    120127    viewbold = rgb000;;bold 
    121128    viewunderline = ;;underline 
    122     viewselected = rgb004;rgb530;bold 
     129    viewselected = main2;main1;bold 
    123130 
    124131[diffviewer] 
    125132    added = ;rgb340 
    126     changedline = ;gray20 
    127     changednew = rgb004;gray20 
    128     changed = ;gray21 
     133    changedline = ;bgdarker 
     134    changednew = main2;bgdarker 
     135    changed = ;bgbitdarker 
    129136    removed = ;rgb511 
    130137    # "white" might change color when going bold, so use "rgb555" instead 
    131138    error = rgb555;rgb400;bold