-
Notifications
You must be signed in to change notification settings - Fork 291
/
terminal.h
56 lines (47 loc) · 1.64 KB
/
terminal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef TERMINAL_H
#define TERMINAL_H
#include "util.h"
#define TERMINAL_FG_BLACK "\x1b[30m"
#define TERMINAL_FG_RED "\x1b[31m"
#define TERMINAL_FG_GREEN "\x1b[32m"
#define TERMINAL_FG_YELLOW "\x1b[33m"
#define TERMINAL_FG_BLUE "\x1b[34m"
#define TERMINAL_FG_MAGENTA "\x1b[35m"
#define TERMINAL_FG_CYAN "\x1b[36m"
#define TERMINAL_FG_WHITE "\x1b[37m"
#define TERMINAL_FG_DEFAULT "\x1b[39m"
#define TERMINAL_BG_BLACK "\x1b[40m"
#define TERMINAL_BG_RED "\x1b[41m"
#define TERMINAL_BG_GREEN "\x1b[42m"
#define TERMINAL_BG_YELLOW "\x1b[43m"
#define TERMINAL_BG_BLUE "\x1b[44m"
#define TERMINAL_BG_MAGENTA "\x1b[45m"
#define TERMINAL_BG_CYAN "\x1b[46m"
#define TERMINAL_BG_WHITE "\x1b[47m"
#define TERMINAL_BG_DEFAULT "\x1b[49m"
#define TERMINAL_BOLD "\x1b[1m"
#define TERMINAL_NO_BOLD "\x1b[22m"
#define TERMINAL_UNDERLINE "\x1b[4m"
#define TERMINAL_NO_UNDERLINE "\x1b[24m"
#define TERMINAL_RESET "\x1b[0m"
#define TERMINAL_SAVE_CURSOR "\x1b[s"
#define TERMINAL_RESTORE_CURSOR "\x1b[u"
#define TERMINAL_UP_CURSOR(l) "\x1b[" #l "A"
#define TERMINAL_DOWN_CURSOR(l) "\x1b[" #l "B"
#define TERMINAL_RIGHT_CURSOR(c) "\x1b[" #c "C"
#define TERMINAL_LEFT_CURSOR(c) "\x1b[" #c "D"
#define TERMINAL_CLEAR_DOWN "\x1b[0J"
#define TERMINAL_CLEAR_UP "\x1b[1J"
#define TERMINAL_CLEAR_RIGHT "\x1b[0K"
#define TERMINAL_CLEAR_LEFT "\x1b[1K"
#define TERMINAL_CLEAR_LINE "\x1b[2K"
#define TERMINAL_CLEAR_ALL "\x1b[2J"
enum color_mode {
COLOR_MODE_AUTO,
COLOR_MODE_NEVER,
COLOR_MODE_ALWAYS
};
void terminal_set_color_mode(enum color_mode color_mode);
void terminal_printf(const char *fmt, ...) _printf_(1, 2);
void terminal_fprintf(FILE *file, const char *fmt, ...) _printf_(2, 3);
#endif