]> git.ipfire.org Git - people/ms/network.git/blob - src/networkctl/terminal.h
Makefile: Fix typo in localstatedir
[people/ms/network.git] / src / networkctl / terminal.h
1 /*#############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2023 IPFire Network Development Team #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 #############################################################################*/
20
21 #ifndef NETWORKCTL_TERMINAL_H
22 #define NETWORKCTL_TERMINAL_H
23
24 typedef enum color_mode {
25 COLORS_UNKNOWN = 0,
26 COLORS_OFF,
27 COLORS_ON,
28 } color_mode_t;
29
30 // Reset
31 #define COLOR_RESET "\x1B[0m"
32
33 // Highlight
34 #define COLOR_HIGHLIGHT "\x1B[0;1;39m"
35
36 // Regular Colors
37 #define COLOR_BLACK "\x1B[0;30m"
38 #define COLOR_RED "\x1B[0;31m"
39 #define COLOR_GREEN "\x1B[0;32m"
40 #define COLOR_YELLOW "\x1B[0;33m"
41 #define COLOR_BLUE "\x1B[0;34m"
42 #define COLOR_MAGENTA "\x1B[0;35m"
43 #define COLOR_CYAN "\x1B[0;36m"
44 #define COLOR_WHITE "\x1B[0;37m"
45
46 #define COLOR_BRIGHT_BLACK "\x1B[0;90m"
47 #define COLOR_BRIGHT_RED "\x1B[0;91m"
48 #define COLOR_BRIGHT_GREEN "\x1B[0;92m"
49 #define COLOR_BRIGHT_YELLOW "\x1B[0;93m"
50 #define COLOR_BRIGHT_BLUE "\x1B[0;94m"
51 #define COLOR_BRIGHT_MAGENTA "\x1B[0;95m"
52 #define COLOR_BRIGHT_CYAN "\x1B[0;96m"
53 #define COLOR_BRIGHT_WHITE "\x1B[0;97m"
54
55 #define COLOR_HIGHLIGHT_BLACK "\x1B[0;1;30m"
56 #define COLOR_HIGHLIGHT_RED "\x1B[0;1;31m"
57 #define COLOR_HIGHLIGHT_GREEN "\x1B[0;1;32m"
58 #define COLOR_HIGHLIGHT_YELLOW "\x1B[0;1;33m"
59 #define COLOR_HIGHLIGHT_BLUE "\x1B[0;1;34m"
60 #define COLOR_HIGHLIGHT_MAGENTA "\x1B[0;1;35m"
61 #define COLOR_HIGHLIGHT_CYAN "\x1B[0;1;36m"
62 #define COLOR_HIGHLIGHT_WHITE "\x1B[0;1;37m"
63
64 // Returns the color mode
65 color_mode_t color_mode(void);
66
67 #define COLOR_FUNC(name, color) \
68 static inline const char* color_##name(void) { \
69 return (color_mode() == COLORS_ON) ? COLOR_ ## color : ""; \
70 }
71
72 COLOR_FUNC(reset, RESET)
73 COLOR_FUNC(highlight, HIGHLIGHT)
74 COLOR_FUNC(black, BLACK)
75 COLOR_FUNC(red, RED)
76 COLOR_FUNC(green, GREEN)
77 COLOR_FUNC(yellow, YELLOW)
78 COLOR_FUNC(blue, BLUE)
79 COLOR_FUNC(magenta, MAGENTA)
80 COLOR_FUNC(cyan, CYAN)
81 COLOR_FUNC(white, WHITE)
82
83 #endif /* NETWORKCTL_TERMINAL_H */