Force 256color escapes.

This commit is contained in:
Matt 2014-08-10 10:59:08 -04:00
commit 690bcb6b32
2 changed files with 49 additions and 2 deletions

View file

@ -175,6 +175,15 @@ AC_ARG_ENABLE(true-color,
fi, fi,
want_truecolor=no) want_truecolor=no)
AC_ARG_ENABLE(force-256color,
[ --enable-force-256color Force using 256-color escapes],
if text x$enableval = xno ; then
want_force256color=no
else
want_force256color=yes
fi,
want_force256color=no)
dnl ** dnl **
dnl ** SSL Library checks (OpenSSL) dnl ** SSL Library checks (OpenSSL)
dnl ** dnl **
@ -669,6 +678,12 @@ else
want_truecolor=no want_truecolor=no
fi fi
if test "x$want_force256color" = "xyes" ; then
AC_DEFINE([HACK_FORCE_256COLOR], [], [force 256color escapes in terminal])
else
want_force256color=no
fi
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile
src/Makefile src/Makefile
@ -802,6 +817,7 @@ echo "Building with 64bit DCC support .. : $offt_64bit"
echo "Building with garbage collector .. : $have_gc" echo "Building with garbage collector .. : $have_gc"
echo "Building with DANE support ....... : $have_dane" echo "Building with DANE support ....... : $have_dane"
echo "Building with true color support.. : $want_truecolor" echo "Building with true color support.. : $want_truecolor"
echo "Building with force 256color hack. : $want_force256color"
echo echo
echo "If there are any problems, read the INSTALL file." echo "If there are any problems, read the INSTALL file."

View file

@ -451,7 +451,11 @@ void terminfo_setup_colors(TERM_REC *term, int force)
terminfo_colors_deinit(term); terminfo_colors_deinit(term);
if (force && term->TI_setf == NULL && term->TI_setaf == NULL) if (force && term->TI_setf == NULL && term->TI_setaf == NULL)
#ifdef HACK_FORCE_256COLOR
term->TI_colors = 256;
#else
term->TI_colors = 8; term->TI_colors = 8;
#endif
if ((term->TI_setf || term->TI_setaf || force) && if ((term->TI_setf || term->TI_setaf || force) &&
term->TI_colors > 0) { term->TI_colors > 0) {
@ -464,8 +468,19 @@ void terminfo_setup_colors(TERM_REC *term, int force)
term->TI_colors = 0; term->TI_colors = 0;
term->set_fg = term->set_bg = _ignore_parm; term->set_fg = term->set_bg = _ignore_parm;
} }
#ifdef HACK_FORCE_256COLOR
/* force 256-color escapes for base colors also, lets you have bold
* font in konsole without bright
*/
if (force) {
for (i = 0; i < term->TI_colors; i++) {
color = i < 16 ? ansitab[i] : i;
term->TI_fg[i] = g_strdup_printf("\033[38;5;%dm", color);
}
} else if (term->TI_setaf) {
#else
if (term->TI_setaf) { if (term->TI_setaf) {
#endif
for (i = 0; i < term->TI_colors; i++) { for (i = 0; i < term->TI_colors; i++) {
color = i < 16 ? ansitab[i] : i; color = i < 16 ? ansitab[i] : i;
term->TI_fg[i] = g_strdup(tparm(term->TI_setaf, color, 0)); term->TI_fg[i] = g_strdup(tparm(term->TI_setaf, color, 0));
@ -473,12 +488,24 @@ void terminfo_setup_colors(TERM_REC *term, int force)
} else if (term->TI_setf) { } else if (term->TI_setf) {
for (i = 0; i < term->TI_colors; i++) for (i = 0; i < term->TI_colors; i++)
term->TI_fg[i] = g_strdup(tparm(term->TI_setf, i, 0)); term->TI_fg[i] = g_strdup(tparm(term->TI_setf, i, 0));
#ifdef HACK_FORCE_256COLOR
}
#else
} else if (force) { } else if (force) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
term->TI_fg[i] = g_strdup_printf("\033[%dm", 30+ansitab[i]); term->TI_fg[i] = g_strdup_printf("\033[%dm", 30+ansitab[i]);
} }
#endif
#ifdef HACK_FORCE_256COLOR
if (force) {
for (i = 0; i < term->TI_colors; i++) {
color = i < 16 ? ansitab[i] : i;
term->TI_bg[i] = g_strdup_printf("\033[48;5;%dm", color);
}
} else if (term->TI_setab) {
#else
if (term->TI_setab) { if (term->TI_setab) {
#endif
for (i = 0; i < term->TI_colors; i++) { for (i = 0; i < term->TI_colors; i++) {
color = i < 16 ? ansitab[i] : i; color = i < 16 ? ansitab[i] : i;
term->TI_bg[i] = g_strdup(tparm(term->TI_setab, color, 0)); term->TI_bg[i] = g_strdup(tparm(term->TI_setab, color, 0));
@ -486,10 +513,14 @@ void terminfo_setup_colors(TERM_REC *term, int force)
} else if (term->TI_setb) { } else if (term->TI_setb) {
for (i = 0; i < term->TI_colors; i++) for (i = 0; i < term->TI_colors; i++)
term->TI_bg[i] = g_strdup(tparm(term->TI_setb, i, 0)); term->TI_bg[i] = g_strdup(tparm(term->TI_setb, i, 0));
#ifdef HACK_FORCE_256COLOR
}
#else
} else if (force) { } else if (force) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
term->TI_bg[i] = g_strdup_printf("\033[%dm", 40+ansitab[i]); term->TI_bg[i] = g_strdup_printf("\033[%dm", 40+ansitab[i]);
} }
#endif /* HACK_FORCE_256COLOR */
} }
static void terminfo_input_init(TERM_REC *term) static void terminfo_input_init(TERM_REC *term)