3 Work with colors - backward compability
5 Copyright (C) 2009 The Free Software Foundation, Inc.
8 Slava Zanko <slavazanko@gmail.com>, 2009.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software; you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of the
15 License, or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be
18 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
30 #include <sys/types.h> /* size_t */
31 #include "lib/tty/color.h"
35 #include "src/setup.h"
38 /*** global variables ****************************************************************************/
40 /*** file scope macro definitions ****************************************************************/
42 /*** file scope type declarations ****************************************************************/
44 typedef struct mc_skin_colors_old_struct
{
45 const char *old_color
;
48 } mc_skin_colors_old_t
;
50 /*** file scope variables ************************************************************************/
52 mc_skin_colors_old_t old_colors
[] = {
53 {"normal", "core", "_default_"},
54 {"marked", "core", "marked"},
55 {"selected", "core", "selected"},
56 {"markselect", "core", "markselect"},
57 {"reverse", "core", "reverse"},
58 {"dnormal", "dialog", "_default_"},
59 {"dfocus", "dialog", "dfocus"},
60 {"dhotnormal", "dialog", "dhotnormal"},
61 {"dhotfocus", "dialog", "dhotfocus"},
62 {"errors", "error", "_default_"},
63 {"errdhotnormal", "error", "errdhotnormal"},
64 {"errdhotfocus", "error", "errdhotfocus"},
65 {"menu", "menu", "_default_"},
66 {"menuhot", "menu", "menuhot"},
67 {"menusel", "menu", "menusel"},
68 {"menuhotsel", "menu", "menuhotsel"},
69 {"menuinactive", "menu", "menuinactive"},
70 {"gauge", "core", "gauge"},
71 {"input", "core", "input"},
72 {"helpnormal", "help", "_default_"},
73 {"helpitalic", "help", "helpitalic"},
74 {"helpbold", "help", "helpbold"},
75 {"helplink", "help", "helplink"},
76 {"helpslink", "help", "helpslink"},
77 {"viewunderline", "viewer", "viewunderline"},
78 {"editnormal", "editor", "_default_"},
79 {"editbold", "editor", "editbold"},
80 {"editmarked", "editor", "editmarked"},
81 {"editwhitespace", "editor", "editwhitespace"},
82 {"editlinestate", "editor", "linestate"},
87 /*** file scope functions ************************************************************************/
88 /* --------------------------------------------------------------------------------------------- */
91 mc_skin_colors_old_transform (const char *old_color
, const char **group
, const char **key
)
95 if (old_color
!= NULL
)
96 for (lc_index
= 0; old_colors
[lc_index
].old_color
; lc_index
++) {
97 if (strcasecmp (old_color
, old_colors
[lc_index
].old_color
) == 0) {
99 *group
= old_colors
[lc_index
].group
;
101 *key
= old_colors
[lc_index
].key
;
108 /* --------------------------------------------------------------------------------------------- */
111 mc_skin_colors_old_configure_one (mc_skin_t
* mc_skin
, const char *the_color_string
)
113 gchar
**colors
, **orig_colors
;
115 const gchar
*skin_group
, *skin_key
;
118 if (the_color_string
== NULL
)
121 orig_colors
= colors
= g_strsplit (the_color_string
, ":", -1);
125 for (; *colors
; colors
++) {
126 key_val
= g_strsplit_set (*colors
, "=,", 3);
131 if (key_val
[1] == NULL
132 || !mc_skin_colors_old_transform (key_val
[0], &skin_group
, &skin_key
)) {
133 g_strfreev (key_val
);
136 if (key_val
[2] != NULL
)
137 skin_val
= g_strdup_printf ("%s;%s", key_val
[1], key_val
[2]);
139 skin_val
= g_strdup_printf ("%s;", key_val
[1]);
140 mc_config_set_string (mc_skin
->config
, skin_group
, skin_key
, skin_val
);
144 g_strfreev (key_val
);
146 g_strfreev (orig_colors
);
149 /* --------------------------------------------------------------------------------------------- */
150 /*** public functions ****************************************************************************/
151 /* --------------------------------------------------------------------------------------------- */
154 mc_skin_colors_old_configure (mc_skin_t
* mc_skin
)
156 mc_skin_colors_old_configure_one (mc_skin
, setup_color_string
);
157 mc_skin_colors_old_configure_one (mc_skin
, term_color_string
);
158 mc_skin_colors_old_configure_one (mc_skin
, getenv ("MC_COLOR_TABLE"));
159 mc_skin_colors_old_configure_one (mc_skin
, command_line_colors
);
162 /* --------------------------------------------------------------------------------------------- */