[patch] Detection of color terminal
- From: "Martin Bialasinski" <martin internet-treff uni-koeln de>
- To: mc-devel list <mc-devel gnome org>
- Subject: [patch] Detection of color terminal
- Date: 04 Dec 2001 22:43:55 +0100
Hi,
Oskar Liljeblad <oskar osk mine nu>, the author of the current zip
extfs, has sent me the following patch to do better check for color
support than currently done.
Currently, mc checks $TERM for xterm* or for teh existance of
$COLORTERM.
Oskar says:
----------
The patch below fixes the problem. The behaviour was
copied from ncurses has_color: Require that max_colors (Co)
terminfo attribute is set. Require that max_pairs (pa)
is set. Require one of:
1. set_foreground (Sf) set, set_background (Sb) set.
2. set_a_foreground (AF) set, set_a_background (AB) set.
3. set_color_pair (sp) set.
Note that these checks are only made if the traditional
color checking fails.
diff -ru mc-4.5.55/src/slint.c mc-4.5.55-oskar/src/slint.c
--- mc-4.5.55/src/slint.c Sat Nov 24 12:46:42 2001
+++ mc-4.5.55-oskar/src/slint.c Sat Nov 24 12:54:25 2001
@@ -466,6 +466,13 @@
for (i = 0; color_terminals [i]; i++)
if (strcmp (color_terminals [i], terminal) == 0)
SLtt_Use_Ansi_Colors = 1;
+ if (!SLtt_Use_Ansi_Colors
+ && SLtt_tgetnum("Co") >= 0
+ && SLtt_tgetnum("pa") >= 0
+ && (((SLtt_tgetstr("Sf") != NULL && SLtt_tgetstr("Sb") != NULL))
+ || ((SLtt_tgetstr("AF") != NULL && SLtt_tgetstr("AB") != NULL))
+ || (SLtt_tgetstr("sp") != NULL)))
+ SLtt_Use_Ansi_Colors = 1;
}
else
/* check color_terminal_string */
----------
Ciao,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]