Switch from compile time to runtime setting.

This commit is contained in:
Matt 2014-08-10 17:10:29 -04:00
commit 9001a97469
3 changed files with 17 additions and 44 deletions

View file

@ -175,15 +175,6 @@ 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 **
@ -678,12 +669,6 @@ 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
@ -817,7 +802,6 @@ 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

@ -130,6 +130,7 @@ static void read_settings(void)
int old_colors = term_use_colors; int old_colors = term_use_colors;
int old_colors24 = term_use_colors24; int old_colors24 = term_use_colors24;
int old_type = term_type; int old_type = term_type;
int old_forced = force_colors;
/* set terminal type */ /* set terminal type */
str = settings_get_str("term_charset"); str = settings_get_str("term_charset");
@ -144,8 +145,14 @@ static void read_settings(void)
term_set_input_type(term_type); term_set_input_type(term_type);
/* change color stuff */ /* change color stuff */
if (force_colors != settings_get_bool("term_force_colors")) { if (settings_get_bool("term_force_256colors")) {
force_colors = 256;
}
else if (force_colors != settings_get_bool("term_force_colors")) {
force_colors = settings_get_bool("term_force_colors"); force_colors = settings_get_bool("term_force_colors");
}
if (old_forced != force_colors) {
term_force_colors(force_colors); term_force_colors(force_colors);
} }
@ -172,6 +179,7 @@ void term_common_init(void)
settings_add_bool("lookandfeel", "colors", TRUE); settings_add_bool("lookandfeel", "colors", TRUE);
settings_add_bool("lookandfeel", "term_force_colors", FALSE); settings_add_bool("lookandfeel", "term_force_colors", FALSE);
settings_add_bool("lookandfeel", "mirc_blink_fix", FALSE); settings_add_bool("lookandfeel", "mirc_blink_fix", FALSE);
settings_add_bool("lookandfeel", "term_force_256colors", FALSE);
force_colors = FALSE; force_colors = FALSE;
term_use_colors = term_has_colors() && settings_get_bool("colors"); term_use_colors = term_has_colors() && settings_get_bool("colors");

View file

@ -449,13 +449,10 @@ void terminfo_setup_colors(TERM_REC *term, int force)
unsigned int i, color; unsigned int i, color;
terminfo_colors_deinit(term); terminfo_colors_deinit(term);
if (force == 256)
if (force && term->TI_setf == NULL && term->TI_setaf == NULL)
#ifdef HACK_FORCE_256COLOR
term->TI_colors = 256; term->TI_colors = 256;
#else else if (force && term->TI_setf == NULL && term->TI_setaf == NULL)
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) {
@ -468,19 +465,15 @@ 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 if (force == 256) {
/* force 256-color escapes for base colors also, lets you have bold /* force 256-color escapes for base colors as well, lets you
* font in konsole without bright * have bold font in konsole without bright.
*/ */
if (force) {
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_printf("\033[38;5;%dm", color); term->TI_fg[i] = g_strdup_printf("\033[38;5;%dm", color);
} }
} else if (term->TI_setaf) { } else if (term->TI_setaf) {
#else
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));
@ -488,24 +481,16 @@ 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 if (force == 256) {
#ifdef HACK_FORCE_256COLOR
if (force) {
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_printf("\033[48;5;%dm", color); term->TI_bg[i] = g_strdup_printf("\033[48;5;%dm", color);
} }
} else if (term->TI_setab) { } else if (term->TI_setab) {
#else
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));
@ -513,14 +498,10 @@ 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)