-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4ea57e
commit 878f883
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include "colors.h" | ||
|
||
void redColor(char* word, char color) | ||
{ | ||
char selectedColor[COLOR_LENGTH] = {'\0'}; | ||
|
||
switch (color) | ||
{ | ||
case BLA: | ||
strcat(selectedColor, BLACK); | ||
break; | ||
|
||
case R: | ||
strcat(selectedColor, RED); | ||
break; | ||
|
||
case GR: | ||
strcat(selectedColor, GREEN); | ||
break; | ||
|
||
case YEL: | ||
strcat(selectedColor, YELLOW); | ||
break; | ||
|
||
case BLU: | ||
strcat(selectedColor, BLUE); | ||
break; | ||
|
||
case MAG: | ||
strcat(selectedColor, MAGENTA); | ||
break; | ||
|
||
case CY: | ||
strcat(selectedColor, CYAN); | ||
break; | ||
|
||
default: | ||
if (color == WHI) | ||
{ | ||
strcat(selectedColor, WHITE); | ||
} | ||
else | ||
{ | ||
strcat(selectedColor, RESET); | ||
} | ||
} | ||
printf("%s", selectedColor); | ||
|
||
while(*word != '\0') | ||
{ | ||
printf("%c", *word++); | ||
} | ||
printf("%s", RESET); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef _COLORS_H_ | ||
#define _COLORS_H_ | ||
|
||
#define BLA 'B' | ||
#define R 'r' | ||
#define GR 'g' | ||
#define YEL 'y' | ||
#define BLU 'b' | ||
#define MAG 'm' | ||
#define CY 'c' | ||
#define WHI 'w' | ||
|
||
#define COLOR_LENGTH 7 | ||
#define BLACK "\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 WHITE "\x1b[37m" | ||
#define RESET "\x1b[0m" | ||
|
||
extern void redColor(char* word, char color); | ||
|
||
#endif |