summaryrefslogtreecommitdiff
path: root/color.h
blob: f2b92333cf1695d6c6f99b9e90424bf52d2df6fb (plain)
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
void change_color(int); //function to change color of text

/*
 * 0  -> regular color (reset)
 * 1  -> red
 * 2  -> bold red
 * 3  -> green
 * 4  -> bold green
 * 5  -> yellow
 * 6  -> bold yellow
 * 7  -> blue
 * 8  -> bold blue
 * 9  -> magenta
 * 10 -> bold magenta
 * 11 -> cyan
 * 12 -> bold cyan
 * 13 -> bg black (reset)
 * 14 -> bg red
 * 15 -> bg green
 * 16 -> bg yellow
 * 17 -> bg blue
 * 18 -> bg magenta
 * 19 -> bg cyan
 * 20 -> bg light gray
*/

void change_color(int option){
	if(option == 0) printf("\033[0m");
	else if(option < 13) printf("\033[%d;3%dm", (option % 2 == 0 ? 1 : 0), (option+1)/2);
	else printf("\033[4%dm", option-13);

	return;
}