From afa2bdbcca4c00faa3efdd0e80a8809bb643e74f Mon Sep 17 00:00:00 2001 From: Patrick Gaskin Date: Sat, 15 Jul 2023 09:01:40 -0400 Subject: [PATCH] Add feature detection for A_ITALIC --- Doc/cmus.txt | 2 +- configure | 18 ++++++++++++++++-- options.c | 7 +++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Doc/cmus.txt b/Doc/cmus.txt index 2f461944d..1bd5bc3be 100644 --- a/Doc/cmus.txt +++ b/Doc/cmus.txt @@ -1293,7 +1293,7 @@ the other attributes will be used. `underline` underlines the text. -`italic` makes the text italic. +`italic` makes the text italic (not supported on all ncurses versions). `blink` makes the text blink. diff --git a/configure b/configure index f04f66a1c..b64a1a677 100755 --- a/configure +++ b/configure @@ -156,13 +156,17 @@ check_rtsched() return 0 } -ncurses_code=" +ncurses_include=" #if defined(__sun__) || defined(__CYGWIN__) #include #include #else #include #endif +" + +ncurses_code=" +$ncurses_include int main(void) { @@ -209,6 +213,16 @@ check_ncurses() check_function "use_default_colors" $NCURSES_CFLAGS $NCURSES_LIBS HAVE_USE_DEFAULT_COLORS=`test $? -ne 0 ; echo $?` + msg_checking "for A_ITALIC" + if try_compile_link "$ncurses_include int main(int argc, char *argv[]) { unsigned long x = A_ITALIC; return !!x; }" $NCURSES_CFLAGS $NCURSES_LIBS + then + msg_result yes + HAVE_ITALIC="1" + else + msg_result no + HAVE_ITALIC="0" + fi + return 0 } @@ -656,7 +670,7 @@ config_header config/tremor.h CONFIG_TREMOR config_header config/modplug.h MODPLUG_API_8 config_header config/mpc.h MPC_SV8 config_header config/mp4.h USE_MPEG4IP -config_header config/curses.h HAVE_RESIZETERM HAVE_USE_DEFAULT_COLORS +config_header config/curses.h HAVE_RESIZETERM HAVE_USE_DEFAULT_COLORS HAVE_ITALIC config_header config/ffmpeg.h HAVE_FFMPEG_AVCODEC_H USE_FALLBACK_IP config_header config/utils.h HAVE_BYTESWAP_H config_header config/iconv.h HAVE_ICONV diff --git a/options.c b/options.c index 0f4af8106..703729a7e 100644 --- a/options.c +++ b/options.c @@ -41,6 +41,9 @@ #include "debug.h" #include "discid.h" #include "mpris.h" +#ifdef HAVE_CONFIG +#include "config/curses.h" +#endif #include #include @@ -1388,8 +1391,10 @@ static void get_attr(void *data, char *buf, size_t size) blink = "blink|"; if (attr & A_BOLD) bold = "bold|"; + #if HAVE_ITALIC if (attr & A_ITALIC) italic = "italic|"; + #endif size_t len = snprintf(buf, size, "%s%s%s%s%s%s", standout, underline, reverse, blink, bold, italic); @@ -1422,8 +1427,10 @@ static void set_attr(void *data, const char *buf) attr |= A_BLINK; else if (strcmp(current, "bold") == 0) attr |= A_BOLD; + #if HAVE_ITALIC else if (strcmp(current, "italic") == 0) attr |= A_ITALIC; + #endif free(current);