dpkg (1.18.25) stretch; urgency=medium
[dpkg] / lib / dpkg / color.h
CommitLineData
1479465f
GJ
1/*
2 * libdpkg - Debian packaging suite library routines
3 * color.h - color support
4 *
5 * Copyright © 2015-2016 Guillem Jover <guillem@debian.org>
6 *
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef LIBDPKG_COLOR_H
22#define LIBDPKG_COLOR_H
23
24#include <stdbool.h>
25
26#include <dpkg/macros.h>
27
28DPKG_BEGIN_DECLS
29
30/**
31 * @defgroup color Color support
32 * @ingroup dpkg-internal
33 * @{
34 */
35
36/* Standard ANSI colors and attributes. */
37#define COLOR_NORMAL ""
38#define COLOR_RESET "\e[0m"
39#define COLOR_BOLD "\e[1m"
40#define COLOR_BLACK "\e[30m"
41#define COLOR_RED "\e[31m"
42#define COLOR_GREEN "\e[32m"
43#define COLOR_YELLOW "\e[33m"
44#define COLOR_BLUE "\e[34m"
45#define COLOR_MAGENTA "\e[35m"
46#define COLOR_CYAN "\e[36m"
47#define COLOR_WHITE "\e[37m"
48#define COLOR_BOLD_BLACK "\e[1;30m"
49#define COLOR_BOLD_RED "\e[1;31m"
50#define COLOR_BOLD_GREEN "\e[1;32m"
51#define COLOR_BOLD_YELLOW "\e[1;33m"
52#define COLOR_BOLD_BLUE "\e[1;34m"
53#define COLOR_BOLD_MAGENTA "\e[1;35m"
54#define COLOR_BOLD_CYAN "\e[1;36m"
55#define COLOR_BOLD_WHITE "\e[1;37m"
56
57/* Current defaults. These might become configurable in the future. */
58#define COLOR_PROG COLOR_BOLD
59#define COLOR_INFO COLOR_GREEN
60#define COLOR_NOTICE COLOR_YELLOW
61#define COLOR_WARN COLOR_BOLD_YELLOW
62#define COLOR_ERROR COLOR_BOLD_RED
63
64enum color_mode {
65 COLOR_MODE_UNKNOWN = -1,
66 COLOR_MODE_NEVER,
67 COLOR_MODE_ALWAYS,
68 COLOR_MODE_AUTO,
69};
70
71bool
72color_set_mode(const char *mode);
73
74const char *
75color_get(const char *color);
76
77static inline const char *
78color_reset(void)
79{
80 return color_get(COLOR_RESET);
81}
82
83/** @} */
84
85DPKG_END_DECLS
86
87#endif /* LIBDPKG_COLOR_H */