diff --git a/lib/tty/color-ncurses.c b/lib/tty/color-ncurses.c index ec3d27105..4618e1034 100644 --- a/lib/tty/color-ncurses.c +++ b/lib/tty/color-ncurses.c @@ -174,11 +174,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 +209,7 @@ tty_setcolor (int color) void tty_lowlevel_setcolor (int color) { - attrset (COLOR_PAIR (color) | color_get_attr (color)); + tty_setcolor (color); } /* --------------------------------------------------------------------------------------------- */ @@ -211,3 +221,11 @@ tty_set_normal_attrs (void) } /* --------------------------------------------------------------------------------------------- */ + +gboolean +tty_use_256colors (void) +{ + return (COLORS == 256); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/tty/color-slang.c b/lib/tty/color-slang.c index ec94adcb2..b2f9d1731 100644 --- a/lib/tty/color-slang.c +++ b/lib/tty/color-slang.c @@ -204,3 +204,11 @@ tty_set_normal_attrs (void) } /* --------------------------------------------------------------------------------------------- */ + +gboolean +tty_use_256colors(void) +{ + return (SLtt_Use_Ansi_Colors && SLtt_tgetnum ((char *) "Co") == 256); +} + +/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/tty/color.h b/lib/tty/color.h index c19db5285..b7f9b7ddb 100644 --- a/lib/tty/color.h +++ b/lib/tty/color.h @@ -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 */ diff --git a/lib/tty/tty-slang.c b/lib/tty/tty-slang.c index d63a879b0..5dd48e9fe 100644 --- a/lib/tty/tty-slang.c +++ b/lib/tty/tty-slang.c @@ -292,7 +292,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 (); diff --git a/lib/tty/tty.h b/lib/tty/tty.h index 521aad64e..76090d306 100644 --- a/lib/tty/tty.h +++ b/lib/tty/tty.h @@ -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);