-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor.h
115 lines (96 loc) · 3.11 KB
/
color.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// ! OSONIC DESDROID.INC
//* COLOR MODULE FOR C/C++
#include <stdio.h>
#ifndef COLOR_H_
#define COLOR_H_
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
//FONTS AVALIABLE
#define BOLD "\x1b[1m"
#define COURIER "\x1b[2m"
#define ITALIC "\x1b[3m"
#define UNDERLINE "\x1b[4m"
#define INVISIBLE "\x1b[8m"
#define DELETE "\x1b[9m"
// HIGHLIGHT_COLOR
#define HIGHLIGHT_RED "\x1b[41m"
#define HIGHLIGHT_GREEN "\x1b[42m"
#define HIGHLIGHT_YELLOW "\x1b[43m"
#define HIGHLIGHT_BLUE "\x1b[44m"
#define HIGHLIGHT_MAGENTA "\x1b[45m"
#define HIGHLIGHT_CYAN "\x1b[46m"
#define HIGHLIGHT_WHITE "\x1b[47m"
//DARK_COLOR
#define DARK_GREY "\x1b[90m"
#define DARK_RED "\x1b[91m"
#define DARK_GREEN "\x1b[92m"
#define DARK_YELLOW "\x1b[93m"
#define DARK_BLUE "\x1b[94m"
#define DARK_MAGENTA "\x1b[95m"
#define DARK_CYAN "\x1b[96m"
// use this :
#define GREY "\x1b[30m"
#define RED "\x1b[31m"
#define GREEN "\x1b[32m"
#define YELLOW "\x1b[33m"
#define BLUE "\x1b[34m"
#define MAGENTA "\x1b[35m"
#define CYAN "\x1b[36m"
#define RESET "\x1b[0m"
//PRINTING
void p(const char *text){
printf("%s",text);}
//PRETTY PRINT
void pprint(const char *format
,const char *MODE){
printf("%s%s%s",MODE,format,RESET);
}
// FUSING FONT AND COLOR
void cprint(const char *format,
const char*color,
const char *font)
{
p(color);
printf("%s%s%s",font,format,RESET);
}
// EXAMPLE
void Example(){
pprint("\n\tCOLORED TEXT \n\n",RESET);
pprint("\tRED \n" ,RED);
pprint("\tGREEN \n" ,GREEN);
pprint("\tYELLOW \n" ,YELLOW);
pprint("\tMAGENTA \n",MAGENTA);
pprint("\tCYAN \n\n" ,CYAN);
pprint("\tHIGHLIGHTED TEXT \n\n",RESET);
pprint("\tHIGHLIGHT RED \n",HIGHLIGHT_RED);
pprint("\tHIGHLIGHT GREEN \n",HIGHLIGHT_GREEN);
pprint("\tHIGHLIGHT YELLOW \n",HIGHLIGHT_YELLOW);
pprint("\tHIGHLIGHT MAGENTA \n",HIGHLIGHT_MAGENTA);
pprint("\tHIGHLIGHT CYAN \n\n",HIGHLIGHT_CYAN);
pprint("\tDARK COLORED TEXT \n\n",RESET);
pprint("\tDARK RED \n",DARK_RED);
pprint("\tDARK GREEN \n",DARK_GREEN);
pprint("\tDARK YELLOW \n",DARK_YELLOW);
pprint("\tDARK MAGENTA \n",DARK_MAGENTA);
pprint("\tDARK CYAN \n\n",DARK_CYAN);
pprint("\tFONTS \n\n",RESET);
pprint("\tBOLD \n",BOLD);
pprint("\tCOURIER \n",COURIER);
pprint("\tUNDERLINED \n",UNDERLINE);
pprint("\tINVISIBLE <-INVISBLE\n",INVISIBLE);
pprint("\tDELETED \n",DELETE);
}
// HOW I FOUND IT
void HOW_I_FOUND_IT(){
for (int i=0;i<100;i++){
char a[50];
sprintf(a,"%d",i);
printf("\x1b[%sm colored text\n",a); // <- MAIN WAY
}}
#endif
//! NOTE: ONLY WORKS ON EDITORS