mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Clarify check of 256 colors support.
(tty_use_truecolors): don't check 256 colors here. (tty_use_256colors): generate error message if 256 colors aren't supported. (tty_init): sync with modified tty_use_256colors(). (tty_color_try_alloc_pair_lib): likewise. (mc_skin_init): likewise. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
f29533f00f
commit
4cbc61a775
@ -159,7 +159,7 @@ mc_skin_init (const gchar * skin_override, GError ** mcerror)
|
|||||||
(void) mc_skin_ini_file_parse (&mc_skin__default);
|
(void) mc_skin_ini_file_parse (&mc_skin__default);
|
||||||
is_good_init = FALSE;
|
is_good_init = FALSE;
|
||||||
}
|
}
|
||||||
if (is_good_init && mc_skin__default.have_256_colors && !tty_use_256colors ())
|
if (is_good_init && mc_skin__default.have_256_colors && !tty_use_256colors (&error))
|
||||||
{
|
{
|
||||||
mc_propagate_error (mcerror, 0,
|
mc_propagate_error (mcerror, 0,
|
||||||
_
|
_
|
||||||
|
@ -181,7 +181,7 @@ tty_color_try_alloc_pair_lib (tty_color_pair_t * mc_color_pair)
|
|||||||
attr = mc_color_pair->attr;
|
attr = mc_color_pair->attr;
|
||||||
|
|
||||||
/* In legacy color mode, change bright colors into bold */
|
/* In legacy color mode, change bright colors into bold */
|
||||||
if (!tty_use_256colors () && !tty_use_truecolors (NULL))
|
if (!tty_use_256colors (NULL) && !tty_use_truecolors (NULL))
|
||||||
{
|
{
|
||||||
if (ifg >= 8 && ifg < 16)
|
if (ifg >= 8 && ifg < 16)
|
||||||
{
|
{
|
||||||
@ -228,8 +228,10 @@ tty_set_normal_attrs (void)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
tty_use_256colors (void)
|
tty_use_256colors (GError ** error)
|
||||||
{
|
{
|
||||||
|
(void) error;
|
||||||
|
|
||||||
return (COLORS == 256);
|
return (COLORS == 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,9 +210,17 @@ tty_set_normal_attrs (void)
|
|||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
tty_use_256colors (void)
|
tty_use_256colors (GError ** error)
|
||||||
{
|
{
|
||||||
return (SLtt_Use_Ansi_Colors && SLtt_tgetnum ((char *) "Co") == 256);
|
gboolean ret;
|
||||||
|
|
||||||
|
ret = (SLtt_Use_Ansi_Colors && SLtt_tgetnum ((char *) "Co") == 256);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
g_set_error (error, MC_ERROR, -1,
|
||||||
|
_("Your terminal doesn't even seem to support 256 colors."));
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
@ -232,14 +240,6 @@ tty_use_truecolors (GError ** error)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity check that at least 256 colors are supported. */
|
|
||||||
if (!tty_use_256colors ())
|
|
||||||
{
|
|
||||||
g_set_error (error, MC_ERROR, -1,
|
|
||||||
_("Your terminal doesn't even seem to support 256 colors."));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Duplicate slang's check so that we can pop up an error message
|
/* Duplicate slang's check so that we can pop up an error message
|
||||||
rather than silently use wrong colors. */
|
rather than silently use wrong colors. */
|
||||||
colorterm = getenv ("COLORTERM");
|
colorterm = getenv ("COLORTERM");
|
||||||
|
@ -47,7 +47,7 @@ void tty_set_normal_attrs (void);
|
|||||||
|
|
||||||
void tty_color_set_defaults (const char *, const char *, const char *);
|
void tty_color_set_defaults (const char *, const char *, const char *);
|
||||||
|
|
||||||
extern gboolean tty_use_256colors (void);
|
extern gboolean tty_use_256colors (GError **);
|
||||||
extern gboolean tty_use_truecolors (GError **);
|
extern gboolean tty_use_truecolors (GError **);
|
||||||
|
|
||||||
/*** inline functions ****************************************************************************/
|
/*** inline functions ****************************************************************************/
|
||||||
|
@ -310,7 +310,7 @@ tty_init (gboolean mouse_enable, gboolean is_xterm)
|
|||||||
tty_reset_prog_mode ();
|
tty_reset_prog_mode ();
|
||||||
load_terminfo_keys ();
|
load_terminfo_keys ();
|
||||||
|
|
||||||
SLtt_Blink_Mode = (tty_use_256colors () || tty_use_truecolors (NULL)) ? 1 : 0;
|
SLtt_Blink_Mode = (tty_use_256colors (NULL) || tty_use_truecolors (NULL)) ? 1 : 0;
|
||||||
|
|
||||||
tty_start_interrupt_key ();
|
tty_start_interrupt_key ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user