started colors, i have a things noted on the side that's not in the repo but i have most of the functions planned
This commit is contained in:
1 parent
0b9d62202a
commit
d77d131661
4 files changed
+91
-3
No files matched your search
+3
-2
@@ -6,11 +6,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "helper.h"
|
||||
|
||||
//COLORS.C
|
||||
void Void(void); //function that does FUCKING NOTHING BECAUSE MY STUPID LSP THINK I'M NOT USING THIS FUCKING FILE AND GIVES ME A WARNINGGENROENIGGHUIOAGHUIHUIAUHIDFG
|
||||
|
||||
//COLORS.C
|
||||
#include "colors.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,50 @@
|
||||
#ifndef COLORS_H
|
||||
#define COLORS_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum color_mode {
|
||||
MODE_NONE,
|
||||
MODE_ANSI16,
|
||||
MODE_ANSI256,
|
||||
MODE_TRUECOLOR
|
||||
}color_mode;
|
||||
|
||||
typedef enum NamedColor {
|
||||
Black,
|
||||
Red,
|
||||
Green,
|
||||
Yellow,
|
||||
Blue,
|
||||
Magenta,
|
||||
Cyan,
|
||||
White,
|
||||
BrightBlack,
|
||||
BrightRed,
|
||||
BrightGreen,
|
||||
BrightYellow,
|
||||
BrightBlue,
|
||||
BrightMagenta,
|
||||
BrightCyan,
|
||||
BrightWhite,
|
||||
}NamedColor;
|
||||
|
||||
typedef struct{
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
}rgbcolor;
|
||||
|
||||
typedef struct colorconfig {
|
||||
enum color_mode mode;
|
||||
bool has_solid_color;
|
||||
rgbcolor solid_color;
|
||||
bool rainbow_enabled; //flag
|
||||
int saturation; //default 100
|
||||
int brightness; //default 50
|
||||
char **rainbow_cache; //array of rgb_color malloced
|
||||
size_t rainbow_count;
|
||||
}colorconfig;
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,41 @@
|
||||
#include "../defs/all.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
void colorconfig_init(colorconfig config){
|
||||
config.saturation = 100;
|
||||
config.brightness = 50;
|
||||
}
|
||||
|
||||
enum color_mode detect_color_mode(void){
|
||||
const char *colorterm, *term;
|
||||
|
||||
if(getenv("NO_COLOR"))
|
||||
return MODE_NONE;
|
||||
|
||||
colorterm = getenv("COLORTERM");
|
||||
if(colorterm && (strstr(colorterm, "truecolor") || strstr(colorterm, "24bit")))
|
||||
return MODE_TRUECOLOR;
|
||||
|
||||
term = getenv("TERM");
|
||||
if(term && strstr(term, "256color"))
|
||||
return MODE_ANSI256;
|
||||
|
||||
return MODE_ANSI16;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
//i'll do this later
|
||||
#endif
|
||||
|
||||
char parse_namedcolors(rgbcolor name, char *outrgb){
|
||||
/*
|
||||
table = array of { name_string, rgb } for the 16 colors
|
||||
normalized = lowercase copy of name, with "_" removed // so that it handles bright_red and brightred
|
||||
for each entry in the table:
|
||||
if normalized equals entry.name -> out_rgb = entry.rgb, return success
|
||||
return fail
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -279,7 +279,6 @@ void draw_miku_says(char *text, int style){
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
Void(); //look at all.h
|
||||
srand(time(NULL));
|
||||
getterminalsize();
|
||||
|
||||
|
||||
Reference in new issue
Block a user