rvis | Minimal terminal colorizer. |
| download: https://git.y1.nz/archives/rvis.tar.gz | |
| README | Files | Log | Refs |
config.h
1 #define COLOR_RESET 0
2 #define COLOR_WHITE 1
3 #define COLOR_RED 2
4 #define COLOR_GREEN 3
5 #define COLOR_BROWN 4
6 #define COLOR_BLUE 5
7 #define COLOR_MAGENTA 6
8 #define COLOR_CYAN 7
9 #define COLOR_BLACK 8
10 #define COLOR_BOLD_WHITE 9
11 #define COLOR_BOLD_RED 10
12 #define COLOR_BOLD_GREEN 11
13 #define COLOR_BOLD_BROWN 12
14 #define COLOR_BOLD_BLUE 13
15 #define COLOR_BOLD_MAGENTA 14
16 #define COLOR_BOLD_CYAN 15
17 #define COLOR_BOLD_BLACK 16
18 char *group_colors[] = {
19 "\033[0m", /* reset */
20
21 "\033[0;30m", /* white */
22 "\033[0;31m", /* red */
23 "\033[0;32m", /* green */
24 "\033[0;33m", /* brown */
25 "\033[0;34m", /* blue */
26 "\033[0;35m", /* magenta */
27 "\033[0;36m", /* cyan */
28 "\033[0;37m", /* black */
29
30 "\033[1;30m", /* white */
31 "\033[1;31m", /* red */
32 "\033[1;32m", /* green */
33 "\033[1;33m", /* brown */
34 "\033[1;34m", /* blue */
35 "\033[1;35m", /* magenta */
36 "\033[1;36m", /* cyan */
37 "\033[1;37m", /* black */
38 };
39
40 /* color by type */
41 int
42 get_char_group(char ch)
43 {
44 if ('a' <= ch && ch <= 'z') return COLOR_BOLD_MAGENTA;
45 if ('A' <= ch && ch <= 'Z') return COLOR_MAGENTA;
46 if ('0' <= ch && ch <= '9') return COLOR_BLUE;
47 return 0;
48 }
49
50 /* color in order */
51 int counter = 0;
52 int
53 get_char_group2(char ch)
54 {
55 counter = (counter+1) % 2;
56 if (counter == 0) return COLOR_BOLD_MAGENTA;
57 if (counter == 1) return COLOR_MAGENTA;
58 return COLOR_BLACK;
59 }
60
61 /* coloring my git diffs BY FORCE. (dumb lol) */
62 int is_add = 0, is_sub = 0;
63 char previous = (char) 0;
64 int
65 get_char_group3(char ch)
66 {
67 if (previous == '\n' && ch == '-') { is_add = 0; is_sub = 1; }
68 else if (previous == '\n' && ch == '+') { is_add = 1; is_sub = 0; }
69 else if (ch == '\n') { is_add = is_sub = 0; }
70
71 previous = ch;
72 if (is_add) return 3;
73 if (is_sub) return 4;
74 return 0;
75 }
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.