Add more ANSI colors to libzfs
Reviewed-by: WHR <msl0000023508@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ethan Coe-Renner <coerenner1@llnl.gov> Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de> Closes #14621
This commit is contained in:
parent
59f1875639
commit
374f86b5c9
|
@ -150,10 +150,16 @@ int zfs_ioctl_fd(int fd, unsigned long request, struct zfs_cmd *zc);
|
||||||
/*
|
/*
|
||||||
* List of colors to use
|
* List of colors to use
|
||||||
*/
|
*/
|
||||||
|
#define ANSI_BLACK "\033[0;30m"
|
||||||
#define ANSI_RED "\033[0;31m"
|
#define ANSI_RED "\033[0;31m"
|
||||||
#define ANSI_GREEN "\033[0;32m"
|
#define ANSI_GREEN "\033[0;32m"
|
||||||
#define ANSI_YELLOW "\033[0;33m"
|
#define ANSI_YELLOW "\033[0;33m"
|
||||||
#define ANSI_BLUE "\033[0;34m"
|
#define ANSI_BLUE "\033[0;34m"
|
||||||
|
#define ANSI_BOLD_BLUE "\033[1;34m" /* light blue */
|
||||||
|
#define ANSI_MAGENTA "\033[0;35m"
|
||||||
|
#define ANSI_CYAN "\033[0;36m"
|
||||||
|
#define ANSI_GRAY "\033[0;37m"
|
||||||
|
|
||||||
#define ANSI_RESET "\033[0m"
|
#define ANSI_RESET "\033[0m"
|
||||||
#define ANSI_BOLD "\033[1m"
|
#define ANSI_BOLD "\033[1m"
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
#define ZDIFF_ADDED_COLOR ANSI_GREEN
|
#define ZDIFF_ADDED_COLOR ANSI_GREEN
|
||||||
#define ZDIFF_MODIFIED_COLOR ANSI_YELLOW
|
#define ZDIFF_MODIFIED_COLOR ANSI_YELLOW
|
||||||
#define ZDIFF_REMOVED_COLOR ANSI_RED
|
#define ZDIFF_REMOVED_COLOR ANSI_RED
|
||||||
#define ZDIFF_RENAMED_COLOR ANSI_BLUE
|
#define ZDIFF_RENAMED_COLOR ANSI_BOLD_BLUE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Given a {dsname, object id}, get the object path
|
* Given a {dsname, object id}, get the object path
|
||||||
|
|
|
@ -2073,10 +2073,11 @@ use_color(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* color_start() and color_end() are used for when you want to colorize a block
|
* The functions color_start() and color_end() are used for when you want
|
||||||
* of text. For example:
|
* to colorize a block of text.
|
||||||
*
|
*
|
||||||
* color_start(ANSI_RED_FG)
|
* For example:
|
||||||
|
* color_start(ANSI_RED)
|
||||||
* printf("hello");
|
* printf("hello");
|
||||||
* printf("world");
|
* printf("world");
|
||||||
* color_end();
|
* color_end();
|
||||||
|
@ -2084,7 +2085,7 @@ use_color(void)
|
||||||
void
|
void
|
||||||
color_start(const char *color)
|
color_start(const char *color)
|
||||||
{
|
{
|
||||||
if (use_color()) {
|
if (color && use_color()) {
|
||||||
fputs(color, stdout);
|
fputs(color, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -2099,7 +2100,9 @@ color_end(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* printf() with a color. If color is NULL, then do a normal printf. */
|
/*
|
||||||
|
* printf() with a color. If color is NULL, then do a normal printf.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
printf_color(const char *color, char *format, ...)
|
printf_color(const char *color, char *format, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue