diff --git a/configure.ac b/configure.ac index 2a7bee0d..fc715efd 100644 --- a/configure.ac +++ b/configure.ac @@ -175,6 +175,15 @@ AC_ARG_ENABLE(true-color, fi, 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 ** SSL Library checks (OpenSSL) dnl ** @@ -669,6 +678,12 @@ else want_truecolor=no 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([ 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 DANE support ....... : $have_dane" echo "Building with true color support.. : $want_truecolor" +echo "Building with force 256color hack. : $want_force256color" echo echo "If there are any problems, read the INSTALL file." diff --git a/src/fe-text/terminfo-core.c b/src/fe-text/terminfo-core.c index d16987fe..8c97d0a5 100644 --- a/src/fe-text/terminfo-core.c +++ b/src/fe-text/terminfo-core.c @@ -451,7 +451,11 @@ void terminfo_setup_colors(TERM_REC *term, int force) terminfo_colors_deinit(term); if (force && term->TI_setf == NULL && term->TI_setaf == NULL) +#ifdef HACK_FORCE_256COLOR + term->TI_colors = 256; +#else term->TI_colors = 8; +#endif if ((term->TI_setf || term->TI_setaf || force) && term->TI_colors > 0) { @@ -464,8 +468,19 @@ void terminfo_setup_colors(TERM_REC *term, int force) term->TI_colors = 0; 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) { +#endif for (i = 0; i < term->TI_colors; i++) { color = i < 16 ? ansitab[i] : i; 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) { for (i = 0; i < term->TI_colors; i++) term->TI_fg[i] = g_strdup(tparm(term->TI_setf, i, 0)); +#ifdef HACK_FORCE_256COLOR + } +#else } else if (force) { for (i = 0; i < 8; 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) { +#endif for (i = 0; i < term->TI_colors; i++) { color = i < 16 ? ansitab[i] : i; 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) { for (i = 0; i < term->TI_colors; i++) term->TI_bg[i] = g_strdup(tparm(term->TI_setb, i, 0)); +#ifdef HACK_FORCE_256COLOR + } +#else } else if (force) { for (i = 0; i < 8; 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)