Skip to content

Commit

Permalink
Add feature detection for A_ITALIC
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin authored and flyingmutant committed Jul 16, 2023
1 parent 7b7cc1d commit afa2bdb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Doc/cmus.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 16 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,17 @@ check_rtsched()
return 0
}

ncurses_code="
ncurses_include="
#if defined(__sun__) || defined(__CYGWIN__)
#include <termios.h>
#include <ncurses.h>
#else
#include <curses.h>
#endif
"

ncurses_code="
$ncurses_include
int main(void)
{
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#include "debug.h"
#include "discid.h"
#include "mpris.h"
#ifdef HAVE_CONFIG
#include "config/curses.h"
#endif

#include <stdio.h>
#include <errno.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit afa2bdb

Please sign in to comment.