xref: /freebsd/contrib/wireguard-tools/terminal.h (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 /*
3  * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
4  */
5 
6 #ifndef TERMINAL_H
7 #define TERMINAL_H
8 
9 #define TERMINAL_FG_BLACK	"\x1b[30m"
10 #define TERMINAL_FG_RED		"\x1b[31m"
11 #define TERMINAL_FG_GREEN	"\x1b[32m"
12 #define TERMINAL_FG_YELLOW	"\x1b[33m"
13 #define TERMINAL_FG_BLUE	"\x1b[34m"
14 #define TERMINAL_FG_MAGENTA	"\x1b[35m"
15 #define TERMINAL_FG_CYAN	"\x1b[36m"
16 #define TERMINAL_FG_WHITE	"\x1b[37m"
17 #define TERMINAL_FG_DEFAULT	"\x1b[39m"
18 
19 #define TERMINAL_BG_BLACK	"\x1b[40m"
20 #define TERMINAL_BG_RED		"\x1b[41m"
21 #define TERMINAL_BG_GREEN	"\x1b[42m"
22 #define TERMINAL_BG_YELLOW	"\x1b[43m"
23 #define TERMINAL_BG_BLUE	"\x1b[44m"
24 #define TERMINAL_BG_MAGENTA	"\x1b[45m"
25 #define TERMINAL_BG_CYAN	"\x1b[46m"
26 #define TERMINAL_BG_WHITE	"\x1b[47m"
27 #define TERMINAL_BG_DEFAULT	"\x1b[49m"
28 
29 #define TERMINAL_BOLD		"\x1b[1m"
30 #define TERMINAL_NO_BOLD	"\x1b[22m"
31 #define TERMINAL_UNDERLINE	"\x1b[4m"
32 #define TERMINAL_NO_UNDERLINE	"\x1b[24m"
33 
34 #define TERMINAL_RESET		"\x1b[0m"
35 
36 #define TERMINAL_SAVE_CURSOR	"\x1b[s"
37 #define TERMINAL_RESTORE_CURSOR	"\x1b[u"
38 #define TERMINAL_UP_CURSOR(l)	"\x1b[" #l "A"
39 #define TERMINAL_DOWN_CURSOR(l)	"\x1b[" #l "B"
40 #define TERMINAL_RIGHT_CURSOR(c) "\x1b[" #c "C"
41 #define TERMINAL_LEFT_CURSOR(c)	"\x1b[" #c "D"
42 #define TERMINAL_CLEAR_DOWN	"\x1b[0J"
43 #define TERMINAL_CLEAR_UP	"\x1b[1J"
44 #define TERMINAL_CLEAR_RIGHT	"\x1b[0K"
45 #define TERMINAL_CLEAR_LEFT	"\x1b[1K"
46 #define TERMINAL_CLEAR_LINE	"\x1b[2K"
47 #define TERMINAL_CLEAR_ALL	"\x1b[2J"
48 
49 void terminal_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
50 
51 #endif
52