Merge branch '2169_fix_colors'
* 2169_fix_colors: Fixed parser of old colors string. Added description of 256colors parameter fail back to standard skin if 256-colors skin used on non256 colors terminal Fixed strange incomplete code while replace colour attribute in hash Use constant for describe color intensity Ticket #2169: Colors fixups for backward compability
Этот коммит содержится в:
Коммит
6ab2753063
@ -3517,6 +3517,10 @@ with the assignment of colors, as described in Section
|
||||
.\"LINK2"
|
||||
Colors\&.
|
||||
.\"Colors"
|
||||
.PP
|
||||
If your skin contains any of 256\-color definitions, you should define the
|
||||
'256colors' key set to TRUE value in [skin] section.
|
||||
|
||||
.PP
|
||||
A skin\-file is searched on the following algorithm (to the first one found):
|
||||
.IP
|
||||
|
@ -3797,6 +3797,10 @@ menuhotsel=yellow;black;bold+underline
|
||||
.\"Colors"
|
||||
.PP
|
||||
|
||||
Если скин содержит описание любого из 256\-ти цветов, то необходимо установить
|
||||
опцию '256colors' со значением TRUE в секции [skin].
|
||||
.PP
|
||||
|
||||
Поиск скин\-файла производится по следующему алгоритму (до
|
||||
первого нахождения файла):
|
||||
.IP
|
||||
|
@ -47,8 +47,8 @@
|
||||
/* Popup menu colors */
|
||||
#define PMENU_ENTRY_COLOR mc_skin_color__cache[24]
|
||||
#define PMENU_SELECTED_COLOR mc_skin_color__cache[25]
|
||||
#define PMENU_HOT_COLOR mc_skin_color__cache[26] /* unused: not implemented yet */
|
||||
#define PMENU_HOTSEL_COLOR mc_skin_color__cache[27] /* unused: not implemented yet */
|
||||
#define PMENU_HOT_COLOR mc_skin_color__cache[26] /* unused: not implemented yet */
|
||||
#define PMENU_HOTSEL_COLOR mc_skin_color__cache[27] /* unused: not implemented yet */
|
||||
#define PMENU_TITLE_COLOR mc_skin_color__cache[28]
|
||||
|
||||
#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[29]
|
||||
@ -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 *********************************************************/
|
||||
|
@ -140,9 +140,6 @@ static void
|
||||
mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_string)
|
||||
{
|
||||
gchar **colors, **orig_colors;
|
||||
gchar **key_val;
|
||||
const gchar *skin_group, *skin_key;
|
||||
gchar *skin_val;
|
||||
|
||||
if (the_color_string == NULL)
|
||||
return;
|
||||
@ -151,30 +148,32 @@ mc_skin_colors_old_configure_one (mc_skin_t * mc_skin, const char *the_color_str
|
||||
if (colors == NULL)
|
||||
return;
|
||||
|
||||
for (; *colors; colors++)
|
||||
for (; *colors != NULL; colors++)
|
||||
{
|
||||
gchar **key_val;
|
||||
const gchar *skin_group, *skin_key;
|
||||
|
||||
key_val = g_strsplit_set (*colors, "=,", 4);
|
||||
|
||||
if (!key_val)
|
||||
if (key_val == NULL)
|
||||
continue;
|
||||
|
||||
if (key_val[1] == NULL
|
||||
|| !mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key))
|
||||
if (key_val[1] != NULL
|
||||
&& mc_skin_colors_old_transform (key_val[0], &skin_group, &skin_key))
|
||||
{
|
||||
g_strfreev (key_val);
|
||||
continue;
|
||||
gchar *skin_val;
|
||||
|
||||
if (key_val[2] == NULL)
|
||||
skin_val = g_strdup_printf ("%s;", key_val[1]);
|
||||
else if (key_val[3] == NULL)
|
||||
skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]);
|
||||
else
|
||||
skin_val = g_strdup_printf ("%s;%s;%s", key_val[1], key_val[2], key_val[3]);
|
||||
|
||||
mc_config_set_string (mc_skin->config, skin_group, skin_key, skin_val);
|
||||
g_free (skin_val);
|
||||
}
|
||||
|
||||
if (key_val[3] != NULL)
|
||||
skin_val = g_strdup_printf ("%s;%s;%s", key_val[1], key_val[2], key_val[3]);
|
||||
else if (key_val[2] != NULL)
|
||||
skin_val = g_strdup_printf ("%s;%s", key_val[1], key_val[2]);
|
||||
else
|
||||
skin_val = g_strdup_printf ("%s;", key_val[1]);
|
||||
mc_config_set_string (mc_skin->config, skin_group, skin_key, skin_val);
|
||||
|
||||
g_free (skin_val);
|
||||
|
||||
g_strfreev (key_val);
|
||||
}
|
||||
g_strfreev (orig_colors);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ gboolean mc_tty_color_disable;
|
||||
|
||||
/*** file scope macro definitions ****************************************************************/
|
||||
|
||||
#define COLOR_INTENSITY 8
|
||||
|
||||
/*** file scope type declarations ****************************************************************/
|
||||
|
||||
typedef struct mc_tty_color_table_struct
|
||||
@ -50,21 +52,21 @@ typedef struct mc_tty_color_table_struct
|
||||
|
||||
mc_tty_color_table_t const color_table[] = {
|
||||
{"black", COLOR_BLACK},
|
||||
{"gray", COLOR_BLACK + 8},
|
||||
{"gray", COLOR_BLACK + COLOR_INTENSITY},
|
||||
{"red", COLOR_RED},
|
||||
{"brightred", COLOR_RED + 8},
|
||||
{"brightred", COLOR_RED + COLOR_INTENSITY},
|
||||
{"green", COLOR_GREEN},
|
||||
{"brightgreen", COLOR_GREEN + 8},
|
||||
{"brightgreen", COLOR_GREEN + COLOR_INTENSITY},
|
||||
{"brown", COLOR_YELLOW},
|
||||
{"yellow", COLOR_YELLOW + 8},
|
||||
{"yellow", COLOR_YELLOW + COLOR_INTENSITY},
|
||||
{"blue", COLOR_BLUE},
|
||||
{"brightblue", COLOR_BLUE + 8},
|
||||
{"brightblue", COLOR_BLUE + COLOR_INTENSITY},
|
||||
{"magenta", COLOR_MAGENTA},
|
||||
{"brightmagenta", COLOR_MAGENTA + 8},
|
||||
{"brightmagenta", COLOR_MAGENTA + COLOR_INTENSITY},
|
||||
{"cyan", COLOR_CYAN},
|
||||
{"brightcyan", COLOR_CYAN + 8},
|
||||
{"brightcyan", COLOR_CYAN + COLOR_INTENSITY},
|
||||
{"lightgray", COLOR_WHITE},
|
||||
{"white", COLOR_WHITE + 8},
|
||||
{"white", COLOR_WHITE + COLOR_INTENSITY},
|
||||
{"default", -1}, /* default color of the terminal */
|
||||
/* special colors */
|
||||
{"A_REVERSE", SPEC_A_REVERSE},
|
||||
|
@ -75,6 +75,7 @@ mc_tty_color_save_attr (int color_pair, int color_attr)
|
||||
return;
|
||||
}
|
||||
|
||||
*key = color_pair;
|
||||
*attr = color_attr;
|
||||
|
||||
g_hash_table_replace (mc_tty_color_color_pair_attrs, (gpointer) key, (gpointer) attr);
|
||||
@ -174,11 +175,21 @@ tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
|
||||
ibg = mc_color_pair->ibg;
|
||||
attr = mc_color_pair->attr;
|
||||
|
||||
/* In 8 color mode, change bright colors into bold */
|
||||
if (COLORS == 8 && ifg >= 8 && ifg < 16)
|
||||
|
||||
/* In non-256 color mode, change bright colors into bold */
|
||||
if (!tty_use_256colors ())
|
||||
{
|
||||
ifg &= 0x07;
|
||||
attr |= A_BOLD;
|
||||
if (ifg >= 8 && ifg < 16)
|
||||
{
|
||||
ifg &= 0x07;
|
||||
attr |= A_BOLD;
|
||||
}
|
||||
|
||||
if (ibg >= 8 && ibg < 16)
|
||||
{
|
||||
ibg &= 0x07;
|
||||
/* attr | = A_BOLD | A_REVERSE ; */
|
||||
}
|
||||
}
|
||||
|
||||
init_pair (mc_color_pair->pair_index, ifg, ibg);
|
||||
@ -199,7 +210,7 @@ tty_setcolor (int color)
|
||||
void
|
||||
tty_lowlevel_setcolor (int color)
|
||||
{
|
||||
attrset (COLOR_PAIR (color) | color_get_attr (color));
|
||||
tty_setcolor (color);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -211,3 +222,11 @@ tty_set_normal_attrs (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
tty_use_256colors (void)
|
||||
{
|
||||
return (COLORS == 256);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -169,8 +169,8 @@ tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
|
||||
}
|
||||
else
|
||||
{
|
||||
fg = tty_color_get_name_by_index(mc_color_pair->ifg);
|
||||
bg = tty_color_get_name_by_index(mc_color_pair->ibg);
|
||||
fg = tty_color_get_name_by_index (mc_color_pair->ifg);
|
||||
bg = tty_color_get_name_by_index (mc_color_pair->ibg);
|
||||
SLtt_set_color (mc_color_pair->pair_index, (char *) "", (char *) fg, (char *) bg);
|
||||
SLtt_add_color_attribute (mc_color_pair->pair_index, mc_color_pair->attr);
|
||||
}
|
||||
@ -204,3 +204,11 @@ tty_set_normal_attrs (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
gboolean
|
||||
tty_use_256colors (void)
|
||||
{
|
||||
return (SLtt_Use_Ansi_Colors && SLtt_tgetnum ((char *) "Co") == 256);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -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;
|
||||
|
@ -50,5 +50,7 @@ void tty_set_normal_attrs (void);
|
||||
|
||||
void tty_color_set_defaults (const char *, const char *, const char *);
|
||||
|
||||
extern gboolean tty_use_256colors(void);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
#endif /* MC_COLOR_H */
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "tty-internal.h" /* slow_tty */
|
||||
#include "tty.h"
|
||||
#include "color.h"
|
||||
#include "color-slang.h"
|
||||
#include "color-internal.h"
|
||||
#include "mouse.h" /* Gpm_Event is required in key.h */
|
||||
@ -292,7 +293,8 @@ tty_init (gboolean slow, gboolean ugly_lines)
|
||||
|
||||
tty_reset_prog_mode ();
|
||||
load_terminfo_keys ();
|
||||
SLtt_Blink_Mode = 1;
|
||||
|
||||
SLtt_Blink_Mode = tty_use_256colors ()? 1 : 0;
|
||||
|
||||
tty_start_interrupt_key ();
|
||||
|
||||
|
@ -65,15 +65,16 @@ extern int mc_tty_frm[];
|
||||
|
||||
extern char *tty_tgetstr (const char *name);
|
||||
|
||||
extern void tty_beep (void);
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
|
||||
/* {{{ Input }}} */
|
||||
|
||||
extern int reset_hp_softkeys;
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
extern void tty_beep (void);
|
||||
|
||||
/* {{{ Input }}} */
|
||||
|
||||
extern void tty_init (gboolean slow, gboolean ugly_lines);
|
||||
extern void tty_shutdown (void);
|
||||
|
||||
|
@ -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=─
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user