Skip to content

Commit

Permalink
add hor ver dia val coloring patterns / add pattern setting
Browse files Browse the repository at this point in the history
  • Loading branch information
niki committed Mar 14, 2023
1 parent d3b815b commit d664c5c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
3 changes: 3 additions & 0 deletions cfg/binfetch.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
Size
Arches
Binary count

[pattern]
value
36 changes: 33 additions & 3 deletions src/binfetch.c.ib
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,41 @@ extern void mach_universal_parser(FILE * fp)

extern void drunken_bishop(FILE * fp)

typedef enum coloring
hor
ver
dia
val
clr
extern clr cclr

void print_label(const char * label)
const char set[] = " .o+=*B0X@%&#/^SE"
if (ascii_art[current_line][0] != '\0')
set_color(ascii_cols[(int)floor((float) current_line / (float) (max_height) * (float) flag_max_colors)])
printf("%s ", ascii_art[current_line])
set_blank()
int x = 0
while (ascii_art[current_line][x] != '\0')
switch (cclr)
case hor:
set_color(ascii_cols[(int)floor((float) current_line / (float) (max_height) * (float) flag_max_colors)])
break
case ver:
set_color(ascii_cols[(int)floor((float) x / (float) (max_width) * (float) flag_max_colors)])
break
case dia:
set_color(ascii_cols[(int)floor((float) (current_line + x) / (float) (max_width + max_height) * (float) flag_max_colors)])
break
case val:
int ckdi = 0
while (ckdi < 14)
if (ascii_art[current_line][x] == set[ckdi])
break
++ckdi
set_color(ascii_cols[(int)floor((float) ckdi / (float) 14 * (float) flag_max_colors)])
break
printf("%c", ascii_art[current_line][x])
set_blank()
x++
printf(" ")
else if (current_line != 0)
printf("%*s ", max_width, " ")
set_color(main_cols[(int)floor((float) current_line / (float) (label_count) * (float) main_max_colors)])
Expand Down
32 changes: 29 additions & 3 deletions src/config.c.ib
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ extern int label_order_count
extern int flag_max_colors
extern int main_max_colors

typedef enum coloring
hor
ver
dia
val
clr

clr cclr = hor

void parse_cfg(const char * path)
FILE * fp
if (path == NULL)
Expand All @@ -36,23 +45,40 @@ void parse_cfg(const char * path)

char tok[128]
while (fgets(tok, 128, fp))
if (!strncmp("[art_colors]", tok, 6))
if (!strncmp("[art_colors]", tok, 12))
while (fgets(tok, 128, fp))
if (tok[0] != '\t')
break
sscanf(tok + 1, "#%2x%2x%2x", (unsigned int *) &ascii_cols[flag_max_colors].r, (unsigned int *) &ascii_cols[flag_max_colors].g, (unsigned int *) &ascii_cols[flag_max_colors].b)
++flag_max_colors
if (!strncmp("[label_colors]", tok, 6))
if (!strncmp("[label_colors]", tok, 14))
while (fgets(tok, 128, fp))
if (tok[0] != '\t')
break
sscanf(tok + 1, "#%2x%2x%2x", (unsigned int *) &main_cols[main_max_colors].r, (unsigned int *) &main_cols[main_max_colors].g, (unsigned int *) &main_cols[main_max_colors].b)
++main_max_colors
if (!strncmp("[order]", tok, 6))
if (!strncmp("[order]", tok, 7))
while (fgets(tok, 128, fp))
if (tok[0] != '\t')
break
tok[strlen(tok) - 1] = '\0'
strcpy(label_order[label_order_count++], tok + 1)

if (!strncmp("[pattern]", tok, 9))
while (fgets(tok, 128, fp))
if (tok[0] != '\t')
break
if (!strncmp("horizontal", tok + 1, 10))
cclr = hor
break
if (!strncmp("vertical", tok + 1, 8))
cclr = ver
break
if (!strncmp("diagonal", tok + 1, 8))
cclr = dia
break
if (!strncmp("value", tok + 1, 5))
cclr = val
break

fclose(fp)

0 comments on commit d664c5c

Please sign in to comment.