2009-09-04 18:22:49 +04:00
|
|
|
/*
|
|
|
|
Skins engine.
|
|
|
|
Work with colors
|
|
|
|
|
2024-01-01 09:46:17 +03:00
|
|
|
Copyright (C) 2009-2024
|
2014-02-12 10:33:10 +04:00
|
|
|
Free Software Foundation, Inc.
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
Written by:
|
2010-12-29 12:58:10 +03:00
|
|
|
Slava Zanko <slavazanko@gmail.com>, 2009
|
|
|
|
Egmont Koblinger <egmont@gmail.com>, 2010
|
2011-10-28 13:57:00 +04:00
|
|
|
Andrew Borodin <aborodin@vmail.ru>, 2012
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
This file is part of the Midnight Commander.
|
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is free software: you can redistribute it
|
2009-09-04 18:22:49 +04:00
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
2011-10-15 14:56:47 +04:00
|
|
|
published by the Free Software Foundation, either version 3 of the License,
|
|
|
|
or (at your option) any later version.
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2011-10-15 14:56:47 +04:00
|
|
|
The Midnight Commander is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2011-10-15 14:56:47 +04:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-09-04 18:22:49 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
2010-11-11 14:05:34 +03:00
|
|
|
|
2010-01-21 16:06:15 +03:00
|
|
|
#include "lib/tty/color.h"
|
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
/*** global variables ****************************************************************************/
|
|
|
|
|
|
|
|
int mc_skin_color__cache[MC_SKIN_COLOR_CACHE_COUNT];
|
|
|
|
|
|
|
|
/*** file scope macro definitions ****************************************************************/
|
|
|
|
|
|
|
|
/*** file scope type declarations ****************************************************************/
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/*** forward declarations (file scope functions) *************************************************/
|
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
/*** file scope variables ************************************************************************/
|
|
|
|
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2009-09-04 18:22:49 +04:00
|
|
|
/*** file scope functions ************************************************************************/
|
Update template for .c files.
Add section for forward declarations of local functions. This section is
located before file scope variables because functions can be used in
strucutres (see find.c for example):
/*** forward declarations (file scope functions) *************************************************/
/* button callbacks */
static int start_stop (WButton * button, int action);
static int find_do_view_file (WButton * button, int action);
static int find_do_edit_file (WButton * button, int action);
/*** file scope variables ************************************************************************/
static struct
{
...
bcback_fn callback;
} fbuts[] =
{
...
{ B_STOP, NORMAL_BUTTON, N_("S&uspend"), 0, 0, NULL, start_stop },
...
{ B_VIEW, NORMAL_BUTTON, N_("&View - F3"), 0, 0, NULL, find_do_view_file },
{ B_VIEW, NORMAL_BUTTON, N_("&Edit - F4"), 0, 0, NULL, find_do_edit_file }
};
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
2023-02-24 09:27:11 +03:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2023-09-10 12:57:40 +03:00
|
|
|
static tty_color_pair_t *
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_get_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2010-02-02 13:48:08 +03:00
|
|
|
gchar kname[BUF_TINY];
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
if (group == NULL || key == NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
return NULL;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
if (mc_skin == NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin = &mc_skin__default;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2010-02-02 13:48:08 +03:00
|
|
|
g_snprintf (kname, sizeof (kname), "%s.%s", group, key);
|
2023-09-10 12:57:40 +03:00
|
|
|
mc_skin_color = (tty_color_pair_t *) g_hash_table_lookup (mc_skin->colors, (gpointer) kname);
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
return mc_skin_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2009-09-14 17:43:03 +04:00
|
|
|
#if 0
|
2009-09-04 18:22:49 +04:00
|
|
|
static void
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_remove_from_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2010-02-02 13:48:08 +03:00
|
|
|
gchar kname[BUF_TINY];
|
2009-09-04 18:22:49 +04:00
|
|
|
if (group == NULL || key == NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
return;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
if (mc_skin == NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin = &mc_skin__default;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2010-02-02 13:48:08 +03:00
|
|
|
g_snprintf (kname, sizeof (kname), "%s.%s", group, key);
|
|
|
|
g_hash_table_remove (mc_skin->colors, (gpointer) kname);
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
2009-09-14 17:43:03 +04:00
|
|
|
#endif
|
2010-11-08 21:50:15 +03:00
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_add_to_hash (mc_skin_t * mc_skin, const gchar * group, const gchar * key,
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t * mc_skin_color)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2010-02-02 13:48:08 +03:00
|
|
|
gchar *kname;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2010-02-02 13:48:08 +03:00
|
|
|
kname = g_strdup_printf ("%s.%s", group, key);
|
2010-04-23 11:54:25 +04:00
|
|
|
if (kname != NULL)
|
|
|
|
{
|
2010-02-02 13:48:08 +03:00
|
|
|
if (g_hash_table_lookup (mc_skin->colors, (gpointer) kname) != NULL)
|
|
|
|
g_hash_table_remove (mc_skin->colors, (gpointer) kname);
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2010-02-02 13:48:08 +03:00
|
|
|
g_hash_table_insert (mc_skin->colors, (gpointer) kname, (gpointer) mc_skin_color);
|
|
|
|
}
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2023-09-10 12:57:40 +03:00
|
|
|
static tty_color_pair_t *
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_get_with_defaults (const gchar * group, const gchar * name)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, name);
|
2009-09-04 18:22:49 +04:00
|
|
|
if (mc_skin_color != NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
return mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color = mc_skin_color_get_from_hash (NULL, group, "_default_");
|
2009-09-04 18:22:49 +04:00
|
|
|
if (mc_skin_color != NULL)
|
2009-09-10 16:14:18 +04:00
|
|
|
return mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color = mc_skin_color_get_from_hash (NULL, "core", "_default_");
|
2009-09-04 18:22:49 +04:00
|
|
|
return mc_skin_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2016-11-14 13:51:19 +03:00
|
|
|
/* If an alias is found, alloc a new string for the resolved value and free the input parameter.
|
|
|
|
Otherwise it's a no-op returning the original string. */
|
|
|
|
static gchar *
|
|
|
|
mc_skin_color_look_up_alias (mc_skin_t * mc_skin, gchar * str)
|
|
|
|
{
|
|
|
|
gchar *orig, *str2;
|
|
|
|
int hop = 0;
|
|
|
|
|
|
|
|
orig = g_strdup (str);
|
|
|
|
str2 = g_strdup (str);
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
gchar **values;
|
|
|
|
gsize items_count;
|
|
|
|
|
|
|
|
values = mc_config_get_string_list (mc_skin->config, "aliases", str, &items_count);
|
|
|
|
if (items_count != 1)
|
|
|
|
{
|
|
|
|
/* No such alias declaration found, that is, we've got the resolved value. */
|
|
|
|
g_strfreev (values);
|
|
|
|
g_free (str2);
|
|
|
|
g_free (orig);
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
str = g_strdup (values[0]);
|
|
|
|
g_strfreev (values);
|
|
|
|
|
|
|
|
/* str2 resolves at half speed than str. This is used for loop detection. */
|
|
|
|
if (hop++ % 2 != 0)
|
|
|
|
{
|
|
|
|
values = mc_config_get_string_list (mc_skin->config, "aliases", str2, &items_count);
|
|
|
|
g_assert (items_count == 1);
|
|
|
|
g_free (str2);
|
|
|
|
str2 = g_strdup (values[0]);
|
|
|
|
g_strfreev (values);
|
|
|
|
|
|
|
|
if (strcmp (str, str2) == 0)
|
|
|
|
{
|
|
|
|
/* Loop detected. */
|
|
|
|
fprintf (stderr,
|
|
|
|
"Loop detected while trying to resolve alias \"%s\" in skin \"%s\"\n",
|
|
|
|
orig, mc_skin->name);
|
|
|
|
g_free (str);
|
|
|
|
g_free (str2);
|
|
|
|
return orig;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
2023-09-10 12:57:40 +03:00
|
|
|
static tty_color_pair_t *
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_get_from_ini_file (mc_skin_t * mc_skin, const gchar * group, const gchar * key)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
|
|
|
gsize items_count;
|
|
|
|
gchar **values;
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color, *tmp;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
values = mc_config_get_string_list (mc_skin->config, group, key, &items_count);
|
2011-01-26 13:40:20 +03:00
|
|
|
if (values == NULL || values[0] == NULL)
|
2010-04-23 11:54:25 +04:00
|
|
|
{
|
2010-09-12 18:40:04 +04:00
|
|
|
g_strfreev (values);
|
2009-09-10 16:14:18 +04:00
|
|
|
return NULL;
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
2010-09-12 18:40:04 +04:00
|
|
|
|
2023-09-10 12:57:40 +03:00
|
|
|
mc_skin_color = g_try_new0 (tty_color_pair_t, 1);
|
2010-04-23 11:54:25 +04:00
|
|
|
if (mc_skin_color == NULL)
|
|
|
|
{
|
2009-09-10 16:14:18 +04:00
|
|
|
g_strfreev (values);
|
|
|
|
return NULL;
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
2010-12-29 12:58:10 +03:00
|
|
|
tmp = mc_skin_color_get_with_defaults (group, "_default_");
|
2023-09-10 12:57:40 +03:00
|
|
|
mc_skin_color->fg = (items_count > 0 && values[0][0]) ?
|
2016-11-14 13:51:19 +03:00
|
|
|
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[0]))) :
|
2023-09-10 12:57:40 +03:00
|
|
|
(tmp != NULL) ? g_strdup (tmp->fg) : NULL;
|
|
|
|
mc_skin_color->bg = (items_count > 1 && values[1][0]) ?
|
2016-11-14 13:51:19 +03:00
|
|
|
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[1]))) :
|
2023-09-10 12:57:40 +03:00
|
|
|
(tmp != NULL) ? g_strdup (tmp->bg) : NULL;
|
2016-11-14 13:51:19 +03:00
|
|
|
mc_skin_color->attrs = (items_count > 2 && values[2][0]) ?
|
|
|
|
mc_skin_color_look_up_alias (mc_skin, g_strstrip (g_strdup (values[2]))) :
|
2010-12-29 12:58:10 +03:00
|
|
|
(tmp != NULL) ? g_strdup (tmp->attrs) : NULL;
|
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
g_strfreev (values);
|
|
|
|
|
2023-06-12 11:26:53 +03:00
|
|
|
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color, FALSE);
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
return mc_skin_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_set_default_for_terminal (mc_skin_t * mc_skin)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color;
|
2023-06-12 11:26:53 +03:00
|
|
|
|
2023-09-10 12:57:40 +03:00
|
|
|
mc_skin_color = g_try_new0 (tty_color_pair_t, 1);
|
2010-04-23 11:54:25 +04:00
|
|
|
if (mc_skin_color != NULL)
|
|
|
|
{
|
2023-09-10 12:57:40 +03:00
|
|
|
mc_skin_color->fg = g_strdup ("default");
|
|
|
|
mc_skin_color->bg = g_strdup ("default");
|
2010-12-29 12:58:10 +03:00
|
|
|
mc_skin_color->attrs = NULL;
|
2023-06-12 11:26:53 +03:00
|
|
|
mc_skin_color->pair_index = tty_try_alloc_color_pair (mc_skin_color, FALSE);
|
2010-04-23 11:54:25 +04:00
|
|
|
mc_skin_color_add_to_hash (mc_skin, "skin", "terminal_default_color", mc_skin_color);
|
2009-12-12 13:54:22 +03:00
|
|
|
}
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
2014-02-08 19:37:11 +04:00
|
|
|
|
2009-09-04 18:22:49 +04:00
|
|
|
static void
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_cache_init (void)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2009-09-10 16:14:18 +04:00
|
|
|
DEFAULT_COLOR = mc_skin_color_get ("skin", "terminal_default_color");
|
|
|
|
NORMAL_COLOR = mc_skin_color_get ("core", "_default_");
|
|
|
|
MARKED_COLOR = mc_skin_color_get ("core", "marked");
|
|
|
|
SELECTED_COLOR = mc_skin_color_get ("core", "selected");
|
|
|
|
MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
|
2010-11-08 13:21:45 +03:00
|
|
|
DISABLED_COLOR = mc_skin_color_get ("core", "disabled");
|
2009-09-19 18:31:22 +04:00
|
|
|
REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
|
2010-10-12 13:33:09 +04:00
|
|
|
HEADER_COLOR = mc_skin_color_get ("core", "header");
|
2010-04-29 23:30:06 +04:00
|
|
|
COMMAND_MARK_COLOR = mc_skin_color_get ("core", "commandlinemark");
|
2020-07-19 19:47:15 +03:00
|
|
|
SHADOW_COLOR = mc_skin_color_get ("core", "shadow");
|
2009-09-10 16:14:18 +04:00
|
|
|
|
|
|
|
COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_");
|
|
|
|
COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus");
|
|
|
|
COLOR_HOT_NORMAL = mc_skin_color_get ("dialog", "dhotnormal");
|
|
|
|
COLOR_HOT_FOCUS = mc_skin_color_get ("dialog", "dhotfocus");
|
2010-10-12 13:33:09 +04:00
|
|
|
COLOR_TITLE = mc_skin_color_get ("dialog", "dtitle");
|
2009-09-10 16:14:18 +04:00
|
|
|
|
2009-09-19 18:31:22 +04:00
|
|
|
ERROR_COLOR = mc_skin_color_get ("error", "_default_");
|
2010-10-12 13:33:09 +04:00
|
|
|
ERROR_FOCUS = mc_skin_color_get ("error", "errdfocus");
|
2009-09-19 18:31:22 +04:00
|
|
|
ERROR_HOT_NORMAL = mc_skin_color_get ("error", "errdhotnormal");
|
|
|
|
ERROR_HOT_FOCUS = mc_skin_color_get ("error", "errdhotfocus");
|
2010-10-12 13:33:09 +04:00
|
|
|
ERROR_TITLE = mc_skin_color_get ("error", "errdtitle");
|
2009-09-19 18:31:22 +04:00
|
|
|
|
|
|
|
MENU_ENTRY_COLOR = mc_skin_color_get ("menu", "_default_");
|
2009-09-10 16:14:18 +04:00
|
|
|
MENU_SELECTED_COLOR = mc_skin_color_get ("menu", "menusel");
|
|
|
|
MENU_HOT_COLOR = mc_skin_color_get ("menu", "menuhot");
|
|
|
|
MENU_HOTSEL_COLOR = mc_skin_color_get ("menu", "menuhotsel");
|
2010-02-23 14:13:23 +03:00
|
|
|
MENU_INACTIVE_COLOR = mc_skin_color_get ("menu", "menuinactive");
|
2009-09-10 16:14:18 +04:00
|
|
|
|
2010-11-29 21:46:11 +03:00
|
|
|
PMENU_ENTRY_COLOR = mc_skin_color_get ("popupmenu", "_default_");
|
|
|
|
PMENU_SELECTED_COLOR = mc_skin_color_get ("popupmenu", "menusel");
|
|
|
|
PMENU_TITLE_COLOR = mc_skin_color_get ("popupmenu", "menutitle");
|
|
|
|
|
2010-11-11 14:05:34 +03:00
|
|
|
BUTTONBAR_HOTKEY_COLOR = mc_skin_color_get ("buttonbar", "hotkey");
|
|
|
|
BUTTONBAR_BUTTON_COLOR = mc_skin_color_get ("buttonbar", "button");
|
|
|
|
|
|
|
|
STATUSBAR_COLOR = mc_skin_color_get ("statusbar", "_default_");
|
|
|
|
|
2009-09-19 18:31:22 +04:00
|
|
|
GAUGE_COLOR = mc_skin_color_get ("core", "gauge");
|
|
|
|
INPUT_COLOR = mc_skin_color_get ("core", "input");
|
2010-10-12 13:33:09 +04:00
|
|
|
INPUT_HISTORY_COLOR = mc_skin_color_get ("core", "inputhistory");
|
|
|
|
COMMAND_HISTORY_COLOR = mc_skin_color_get ("core", "commandhistory");
|
2010-04-29 23:30:06 +04:00
|
|
|
INPUT_MARK_COLOR = mc_skin_color_get ("core", "inputmark");
|
2010-05-03 02:33:08 +04:00
|
|
|
INPUT_UNCHANGED_COLOR = mc_skin_color_get ("core", "inputunchanged");
|
2009-09-19 18:31:22 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
HELP_NORMAL_COLOR = mc_skin_color_get ("help", "_default_");
|
|
|
|
HELP_ITALIC_COLOR = mc_skin_color_get ("help", "helpitalic");
|
|
|
|
HELP_BOLD_COLOR = mc_skin_color_get ("help", "helpbold");
|
|
|
|
HELP_LINK_COLOR = mc_skin_color_get ("help", "helplink");
|
|
|
|
HELP_SLINK_COLOR = mc_skin_color_get ("help", "helpslink");
|
2010-10-12 13:33:09 +04:00
|
|
|
HELP_TITLE_COLOR = mc_skin_color_get ("help", "helptitle");
|
2009-09-10 16:14:18 +04:00
|
|
|
|
2014-05-02 10:22:34 +04:00
|
|
|
VIEW_NORMAL_COLOR = mc_skin_color_get ("viewer", "_default_");
|
2010-10-12 13:33:09 +04:00
|
|
|
VIEW_BOLD_COLOR = mc_skin_color_get ("viewer", "viewbold");
|
2009-09-19 18:31:22 +04:00
|
|
|
VIEW_UNDERLINED_COLOR = mc_skin_color_get ("viewer", "viewunderline");
|
2010-10-12 13:33:09 +04:00
|
|
|
VIEW_SELECTED_COLOR = mc_skin_color_get ("viewer", "viewselected");
|
2009-09-10 16:14:18 +04:00
|
|
|
|
|
|
|
EDITOR_NORMAL_COLOR = mc_skin_color_get ("editor", "_default_");
|
|
|
|
EDITOR_BOLD_COLOR = mc_skin_color_get ("editor", "editbold");
|
|
|
|
EDITOR_MARKED_COLOR = mc_skin_color_get ("editor", "editmarked");
|
|
|
|
EDITOR_WHITESPACE_COLOR = mc_skin_color_get ("editor", "editwhitespace");
|
2023-12-03 19:28:56 +03:00
|
|
|
EDITOR_NONPRINTABLE_COLOR = mc_skin_color_get ("editor", "editnonprintable");
|
2009-11-19 15:35:00 +03:00
|
|
|
EDITOR_RIGHT_MARGIN_COLOR = mc_skin_color_get ("editor", "editrightmargin");
|
2010-04-22 16:09:52 +04:00
|
|
|
LINE_STATE_COLOR = mc_skin_color_get ("editor", "editlinestate");
|
2011-10-28 13:57:00 +04:00
|
|
|
EDITOR_BACKGROUND = mc_skin_color_get ("editor", "editbg");
|
|
|
|
EDITOR_FRAME = mc_skin_color_get ("editor", "editframe");
|
|
|
|
EDITOR_FRAME_ACTIVE = mc_skin_color_get ("editor", "editframeactive");
|
|
|
|
EDITOR_FRAME_DRAG = mc_skin_color_get ("editor", "editframedrag");
|
2009-11-19 15:35:00 +03:00
|
|
|
|
2009-10-22 13:29:24 +04:00
|
|
|
BOOK_MARK_COLOR = mc_skin_color_get ("editor", "bookmark");
|
|
|
|
BOOK_MARK_FOUND_COLOR = mc_skin_color_get ("editor", "bookmarkfound");
|
2010-03-03 16:09:15 +03:00
|
|
|
|
|
|
|
DFF_ADD_COLOR = mc_skin_color_get ("diffviewer", "added");
|
|
|
|
DFF_CHG_COLOR = mc_skin_color_get ("diffviewer", "changedline");
|
|
|
|
DFF_CHH_COLOR = mc_skin_color_get ("diffviewer", "changednew");
|
|
|
|
DFF_CHD_COLOR = mc_skin_color_get ("diffviewer", "changed");
|
|
|
|
DFF_DEL_COLOR = mc_skin_color_get ("diffviewer", "removed");
|
|
|
|
DFF_ERROR_COLOR = mc_skin_color_get ("diffviewer", "error");
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
2009-09-10 16:14:18 +04:00
|
|
|
|
2009-09-10 15:14:32 +04:00
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static gboolean
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_check_inisection (const gchar * group)
|
2009-09-10 15:14:32 +04:00
|
|
|
{
|
2016-11-14 13:51:19 +03:00
|
|
|
return !((strcasecmp ("skin", group) == 0) || (strcasecmp ("aliases", group) == 0)
|
2010-04-23 11:54:25 +04:00
|
|
|
|| (strcasecmp ("lines", group) == 0) || (strncasecmp ("widget-", group, 7) == 0));
|
2009-09-10 15:14:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_check_bw_mode (mc_skin_t * mc_skin)
|
2009-09-10 15:14:32 +04:00
|
|
|
{
|
|
|
|
gchar **groups, **orig_groups;
|
|
|
|
|
2011-09-07 13:06:03 +04:00
|
|
|
if (tty_use_colors () && !mc_global.tty.disable_colors)
|
2009-09-10 16:14:18 +04:00
|
|
|
return;
|
2009-09-10 15:14:32 +04:00
|
|
|
|
2014-05-04 12:05:30 +04:00
|
|
|
orig_groups = mc_config_get_groups (mc_skin->config, NULL);
|
2009-09-10 15:14:32 +04:00
|
|
|
|
2014-05-04 12:05:30 +04:00
|
|
|
for (groups = orig_groups; *groups != NULL; groups++)
|
2009-09-14 17:43:03 +04:00
|
|
|
if (mc_skin_color_check_inisection (*groups))
|
|
|
|
mc_config_del_group (mc_skin->config, *groups);
|
2014-05-04 12:05:30 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
g_strfreev (orig_groups);
|
2014-05-04 12:05:30 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_hardcoded_blackwhite_colors (mc_skin);
|
2009-09-10 15:14:32 +04:00
|
|
|
}
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
/*** public functions ****************************************************************************/
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
gboolean
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_parse_ini_file (mc_skin_t * mc_skin)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2021-05-28 09:52:22 +03:00
|
|
|
gboolean ret = FALSE;
|
2009-09-04 18:22:49 +04:00
|
|
|
gsize items_count;
|
|
|
|
gchar **groups, **orig_groups;
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_check_bw_mode (mc_skin);
|
2009-09-10 15:14:32 +04:00
|
|
|
|
2014-05-04 12:05:30 +04:00
|
|
|
orig_groups = mc_config_get_groups (mc_skin->config, &items_count);
|
|
|
|
if (*orig_groups == NULL)
|
2021-05-28 09:52:22 +03:00
|
|
|
goto ret;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
|
|
|
/* as first, need to set up default colors */
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_set_default_for_terminal (mc_skin);
|
|
|
|
mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, "core", "_default_");
|
2009-09-04 18:22:49 +04:00
|
|
|
if (mc_skin_color == NULL)
|
2021-05-28 09:52:22 +03:00
|
|
|
goto ret;
|
2009-09-10 16:14:18 +04:00
|
|
|
|
2023-06-12 11:26:53 +03:00
|
|
|
tty_color_set_defaults (mc_skin_color);
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_add_to_hash (mc_skin, "core", "_default_", mc_skin_color);
|
|
|
|
|
2014-07-15 16:53:06 +04:00
|
|
|
for (groups = orig_groups; *groups != NULL; groups++)
|
2010-04-23 11:54:25 +04:00
|
|
|
{
|
2014-05-04 11:38:25 +04:00
|
|
|
gchar **keys, **orig_keys;
|
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
if (!mc_skin_color_check_inisection (*groups))
|
|
|
|
continue;
|
|
|
|
|
2014-05-04 11:38:25 +04:00
|
|
|
orig_keys = mc_config_get_keys (mc_skin->config, *groups, NULL);
|
2009-12-11 15:59:28 +03:00
|
|
|
|
2014-05-04 11:38:25 +04:00
|
|
|
for (keys = orig_keys; *keys != NULL; keys++)
|
2010-04-23 11:54:25 +04:00
|
|
|
{
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color = mc_skin_color_get_from_ini_file (mc_skin, *groups, *keys);
|
2009-09-14 17:43:03 +04:00
|
|
|
if (mc_skin_color != NULL)
|
|
|
|
mc_skin_color_add_to_hash (mc_skin, *groups, *keys, mc_skin_color);
|
2009-09-10 16:14:18 +04:00
|
|
|
}
|
|
|
|
g_strfreev (orig_keys);
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_cache_init ();
|
2021-05-28 09:52:22 +03:00
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
ret:
|
|
|
|
g_strfreev (orig_groups);
|
|
|
|
return ret;
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
int
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color_get (const gchar * group, const gchar * name)
|
2009-09-04 18:22:49 +04:00
|
|
|
{
|
2023-09-10 12:57:40 +03:00
|
|
|
tty_color_pair_t *mc_skin_color;
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-10 16:14:18 +04:00
|
|
|
mc_skin_color = mc_skin_color_get_with_defaults (group, name);
|
2009-09-04 18:22:49 +04:00
|
|
|
|
2009-09-14 17:43:03 +04:00
|
|
|
return (mc_skin_color != NULL) ? mc_skin_color->pair_index : 0;
|
2009-09-04 18:22:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------- */
|