mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
fail back to standard skin if 256-colors skin used on non256 colors terminal
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
df0ae6ad0c
commit
5b167ccc9e
@ -115,6 +115,7 @@ typedef struct mc_skin_struct
|
||||
gchar *description;
|
||||
mc_config_t *config;
|
||||
GHashTable *colors;
|
||||
gboolean have_256_colors;
|
||||
} mc_skin_t;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include "lib/tty/color.h" /* tty_use_256colors(); */
|
||||
|
||||
#include "src/args.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
@ -115,11 +117,12 @@ mc_skin_init (GError ** error)
|
||||
{
|
||||
gboolean is_good_init = TRUE;
|
||||
|
||||
mc_skin__default.have_256_colors = FALSE;
|
||||
|
||||
mc_skin__default.name = mc_skin_get_default_name ();
|
||||
|
||||
mc_skin__default.colors = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, mc_skin_hash_destroy_value);
|
||||
|
||||
if (!mc_skin_ini_file_load (&mc_skin__default))
|
||||
{
|
||||
*error = g_error_new (MC_ERROR, 0,
|
||||
@ -143,6 +146,19 @@ mc_skin_init (GError ** error)
|
||||
(void) mc_skin_ini_file_parse (&mc_skin__default);
|
||||
is_good_init = FALSE;
|
||||
}
|
||||
if ( is_good_init && !tty_use_256colors () && mc_skin__default.have_256_colors )
|
||||
{
|
||||
if (*error == NULL)
|
||||
*error = g_error_new (MC_ERROR, 0,
|
||||
_
|
||||
("Unable to use '%s' skin with 256 colors support\non non-256 colors terminal.\nDefault skin has been loaded"),
|
||||
mc_skin__default.name);
|
||||
|
||||
mc_skin_try_to_load_default ();
|
||||
mc_skin_colors_old_configure (&mc_skin__default);
|
||||
(void) mc_skin_ini_file_parse (&mc_skin__default);
|
||||
is_good_init = FALSE;
|
||||
}
|
||||
mc_skin_is_init = TRUE;
|
||||
return is_good_init;
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ mc_skin_ini_file_parse (mc_skin_t * mc_skin)
|
||||
return FALSE;
|
||||
|
||||
mc_skin_lines_parse_ini_file (mc_skin);
|
||||
mc_skin->have_256_colors = mc_config_get_bool (mc_skin->config, "skin", "256colors", FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ void
|
||||
tty_color_set_defaults (const char *fgcolor, const char *bgcolor, const char *attrs)
|
||||
{
|
||||
g_free (tty_color_defaults__fg);
|
||||
g_free (tty_color_defaults__fg);
|
||||
g_free (tty_color_defaults__bg);
|
||||
g_free (tty_color_defaults__attrs);
|
||||
|
||||
tty_color_defaults__fg = (fgcolor != NULL) ? g_strdup (fgcolor) : NULL;
|
||||
|
@ -53,6 +53,7 @@
|
||||
|
||||
[skin]
|
||||
description=Sand skin using 256 colors
|
||||
256colors=true
|
||||
|
||||
[Lines]
|
||||
horiz=─
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
[skin]
|
||||
description=Xoria256
|
||||
256colors=true
|
||||
|
||||
# [Lines]
|
||||
# horiz=─
|
||||
|
Loading…
Reference in New Issue
Block a user