Skip to content
Permalink
Browse files

curl: Add Terminal-Colors

This commit adds a colorful output to the stdout
  • Loading branch information
emilengler committed Nov 30, 2019
1 parent 0044443 commit 0e822332fafe8af02256a9e58aab42d9a8221072
Showing with 29 additions and 1 deletion.
  1. +18 −0 configure.ac
  2. +11 −1 src/tool_msgs.c
@@ -4486,6 +4486,24 @@ AC_HELP_STRING([--disable-progress-meter],[Disable progress-meter]),
AC_MSG_RESULT(yes)
)

dnl ************************************************************
dnl disable terminal colors
dnl
AC_MSG_CHECKING([whether to support terminal-colors])
AC_ARG_ENABLE(terminal-colors,
AC_HELP_STRING([--enable-terminal-colors],[Enable terminal-colors])
AC_HELP_STRING([--disable-terminal-colors],[Disable terminal-colors]),
[ case "$enableval" in
no)
AC_MSG_RESULT(no)
AC_DEFINE(CURL_DISABLE_TERMINAL_COLORS, 1, [disable terminal-colors])
;;
*) AC_MSG_RESULT(yes)
;;
esac ],
AC_MSG_RESULT(yes)
)

dnl ************************************************************
dnl disable shuffle DNS support
dnl
@@ -30,15 +30,25 @@

#include "memdebug.h" /* keep this as LAST include */

#ifndef CURL_DISABLE_TERMINAL_COLORS
#define WARN_PREFIX "\033[33mWarning: \033[0m"
#define NOTE_PREFIX "\033[36mNote: \033[0m"
#else
#define WARN_PREFIX "Warning: "
#define NOTE_PREFIX "Note: "
#endif

static void voutf(struct GlobalConfig *config,
const char *prefix,
const char *fmt,
va_list ap)
{
size_t width = (79 - strlen(prefix));
unsigned short maxlength = 79;
#ifndef CURL_DISABLE_TERMINAL_COLORS
/* Terminal color sequences are 16 characters long (starter and escaper) */
maxlength += 16;
#endif
size_t width = (maxlength - strlen(prefix));
if(!config->mute) {
size_t len;
char *ptr;

0 comments on commit 0e82233

Please sign in to comment.
You can’t perform that action at this time.