Compare commits

..

8 commits

9 changed files with 97 additions and 225 deletions

61
basic.c
View file

@ -1,11 +1,9 @@
#include "basic.h"
#include <stdio.h>
#include "draw.h"
void rainbow_8() {
color colors [] = {
const color colors [] = {
RED,
L_RED,
L_YELLOW,
@ -16,19 +14,8 @@ void rainbow_8() {
draw(6, colors);
}
void aromantic_8() {
color colors [] = {
GREEN,
L_GREEN,
WHITE,
GRAY,
BLACK
};
draw(5, colors);
}
void aroace_8() {
color colors [] = {
const color colors [] = {
YELLOW,
L_YELLOW,
WHITE,
@ -38,29 +25,8 @@ void aroace_8() {
draw(5, colors);
}
void asexual_8() {
color colors [] = {
BLACK,
GRAY,
WHITE,
MAGENTA
};
draw(4, colors);
}
void bigender_8() {
color colors [] = {
L_RED,
L_YELLOW,
WHITE,
MAGENTA,
L_BLUE
};
draw(5, colors);
}
void bisexual_8() {
color colors [] = {
const color colors [] = {
RED,
RED,
MAGENTA,
@ -71,7 +37,7 @@ void bisexual_8() {
}
void gay_8() {
color colors [] = {
const color colors [] = {
CYAN,
L_CYAN,
WHITE,
@ -81,19 +47,8 @@ void gay_8() {
draw(5, colors);
}
void genderfluid_8() {
color colors [] = {
L_RED,
WHITE,
MAGENTA,
BLACK,
BLUE
};
draw(5, colors);
}
void lesbian_8() {
color colors [] = {
const color colors [] = {
RED,
L_RED,
WHITE,
@ -104,7 +59,7 @@ void lesbian_8() {
}
void nonbinary_8() {
color colors [] = {
const color colors [] = {
L_YELLOW,
WHITE,
MAGENTA,
@ -114,7 +69,7 @@ void nonbinary_8() {
}
void pansexual_8() {
color colors [] = {
const color colors [] = {
MAGENTA,
MAGENTA,
L_YELLOW,
@ -126,7 +81,7 @@ void pansexual_8() {
}
void transgender_8() {
color colors [] = {
const color colors [] = {
L_CYAN,
L_MAGENTA,
WHITE,

View file

@ -18,13 +18,9 @@
#define WHITE 15
void rainbow_8();
void aromantic_8();
void aroace_8();
void asexual_8();
void bigender_8();
void bisexual_8();
void gay_8();
void genderfluid_8();
void lesbian_8();
void nonbinary_8();
void pansexual_8();

2
draw.c
View file

@ -2,7 +2,7 @@
#include <stdio.h>
void draw(unsigned short int len, color colors []) {
void draw(const unsigned short int len, const color colors []) {
for(int i = 0; i < len; i++) {
printf(ANSI "%dm" STRIPE, colors[i]);
}

2
draw.h
View file

@ -6,5 +6,5 @@
typedef unsigned short int color;
void draw(unsigned short int len, color colors[]);
void draw(const unsigned short int len, const color colors[]);

63
full.c
View file

@ -1,11 +1,9 @@
#include "full.h"
#include <stdio.h>
#include "draw.h"
void rainbow_256() {
color colors [] = {
const color colors [] = {
196, // red
208, // orange
220, // yellow
@ -16,19 +14,8 @@ void rainbow_256() {
draw(6, colors);
}
void aromantic_256() {
color colors [] = {
40, // green
83, // light green
255, // white
249, // gray
16 // black
};
draw(5, colors);
}
void aroace_256() {
color colors [] = {
const color colors [] = {
172, // orange
184, // yellow
255, // white
@ -38,29 +25,8 @@ void aroace_256() {
draw(5, colors);
}
void asexual_256() {
color colors [] = {
16, // black
249, // gray
255, // white
90 // purple
};
draw(4, colors);
}
void bigender_256() {
color colors [] = {
204, // pink
227, // yellow
255, // white
134, // purple
69 // blue
};
draw(5, colors);
}
void bisexual_256() {
color colors [] = {
const color colors [] = {
161, // magenta
161,
91, // purple
@ -71,7 +37,7 @@ void bisexual_256() {
}
void gay_256() {
color colors [] = {
const color colors [] = {
29,
49, // greens
123,
@ -83,30 +49,19 @@ void gay_256() {
draw(7, colors);
}
void genderfluid_256() {
color colors[] = {
204, // pink
255, // white
164, // purple
16, // black
63, // blue
};
draw(5, colors);
}
void lesbian_256() {
color colors [] = {
const color colors [] = {
202, // orange
209, // tangerine
255, // white
134, // pink
205, // pink
161 // magenta
};
draw(5, colors);
}
void nonbinary_256() {
color colors [] = {
const color colors [] = {
226, // yellow
255, // white
134, // purple
@ -116,7 +71,7 @@ void nonbinary_256() {
}
void pansexual_256() {
color colors [] = {
const color colors [] = {
161, 161, // magenta
220, 220, // yellow
45, 45 // cyan
@ -125,7 +80,7 @@ void pansexual_256() {
}
void transgender_256() {
color colors [] = {
const color colors [] = {
45, // blue
213, // pink
255, // white

4
full.h
View file

@ -3,13 +3,9 @@
#include "draw.h"
void rainbow_256();
void aromantic_256();
void aroace_256();
void asexual_256();
void bigender_256();
void bisexual_256();
void gay_256();
void genderfluid_256();
void lesbian_256();
void nonbinary_256();
void pansexual_256();

99
main.c
View file

@ -2,12 +2,10 @@
#include <stdlib.h>
#include <string.h>
#include "draw.h"
#include "basic.h"
#include "full.h"
#include "name.h"
#define VERSION "0.0.1"
#define VERSION "0.0.4"
#define RESET "\x1b[0m"
@ -24,13 +22,9 @@ void help() {
"usage: pride [name]\n\n"
"flag names:\n"
" aromantic\n"
" aroace\n"
" asexual\n"
" bigender\n"
" bisexual\n"
" gay\n"
" genderfluid\n"
" lesbian\n"
" nonbinary\n"
" pansexual\n"
@ -39,11 +33,11 @@ void help() {
);
}
unsigned long djb_hash(unsigned char *string) {
unsigned long djb_hash(char *string) {
unsigned long output = 5381;
int c;
while(c = *string++)
while((c = *string++))
output = ((output << 5) + output) + c;
return output;
@ -55,111 +49,82 @@ int main(int argc, char **argv) {
if(argc > 1) { flag = argv[1]; }
else { flag = ""; }
// handle flags
if(strcmp(flag, "--version") == 0) {
version();
return 0;
} else if(strcmp(flag, "--help") == 0) {
help();
return 0;
}
int color_mode = 0;
char * term = getenv("TERM");
if(strcmp(term, "linux"))
char * colorterm = getenv("COLORTERM");
if(colorterm != NULL && strcmp(colorterm, ""))
color_mode = 1;
unsigned long flag_hash = djb_hash(flag);
#ifdef DEBUG_HASH
printf("[ %lu ]\n\n", flag_hash);
return 0;
#endif
char *output;
switch(flag_hash) {
// - RAINBOW -
case RAINBOW:
case EMPTY:
case 229480993726103lu: // 'rainbow'
case 5381lu: // (empty)
if(color_mode) rainbow_256();
else rainbow_8();
break;
// - AROMANTIC -
case AROMANTIC:
case ARO:
if(color_mode) aromantic_256();
else aromantic_8();
break;
// - ARO/ACE -
case AROACE:
case ARO_ACE:
case 6953324567312lu: // 'aroace'
case 22945708850429lu: // 'aro-ace'
if(color_mode) aroace_256();
else aroace_8();
break;
// - ASEXUAL -
case ASEXUAL:
case ACE:
if(color_mode) asexual_256();
else asexual_8();
break;
// - BIGENDER -
case BIGENDER:
if(color_mode) bigender_256();
else bigender_8();
break;
// - BISEXUAL -
case BISEXUAL:
case BI: // 'bi'
case 7572201611094690lu: // 'bisexual'
case 5863248lu: // 'bi'
if(color_mode) bisexual_256();
else bisexual_8();
break;
// - GAY -
case GAY:
case MLM:
case 193492486lu: // 'gay'
case 193499371lu: // 'mlm'
if(color_mode) gay_256();
else gay_8();
break;
// - GENDERFLUID -
case GENDERFLUID:
if(color_mode) genderfluid_256();
else genderfluid_8();
break;
// - LESBIAN -
case LESBIAN:
case WLW:
case 229473412894979lu: // 'lesbian'
case 193510271lu: // 'wlw'
if(color_mode) lesbian_256();
else lesbian_8();
break;
// - NONBINARY -
case NONBINARY:
case NB:
case 249899779187415445lu: // 'nonbinary'
case 5863637lu: // 'nb'
if(color_mode) nonbinary_256();
else nonbinary_8();
break;
// - PANSEXUAL -
case PANSEXUAL:
case PAN:
case 249901996007388822lu: // 'pansexual'
case 193502276lu: // 'pan'
if(color_mode) pansexual_256();
else pansexual_8();
break;
// - TRANSGENDER -
case TRANSGENDER:
case TRANS:
case 13895753452281080578lu: // 'transgender'
case 210729322765lu: // 'trans'
if(color_mode) transgender_256();
else transgender_8();
break;
// handle flags, but in the command-line sense
case 6951207451432lu: // --help
case 5861498lu: // -h
help();
break;
case 249805560270004805lu: // --version
case 5861512lu: // -v
version();
break;
default:
printf("pride-c: no flag '%s' found.", flag);
return 1;

46
man/pride-c.6 Normal file
View file

@ -0,0 +1,46 @@
.Dd $Mdocdate$
.Dt PRIDE-C 6
.Os
.Sh NAME
.Nm pride-c
.Nd shows pride flags in the terminal using ANSI color sequences.
.Sh SYNOPSIS
.Nm
.Op Ar flag
.Nm
.Op Fl -help | Fl -version
.Sh DESCRIPTION
.Nm
displays pride flags for reduced color terminals. Outputs 8- or 256-color flags depending on if
.Ev COLORTERM
is set. If no
.Ar flag
is provided,
.Nm
defaults to 'rainbow'. The following flags are implemented:
.Pp
.Bl -tag -compact
.It aroace, aro-ace
.It bisexual, bi
.It gay, mlm
.It lesbian, wlw
.It nonbinary, nb
.It pansexual, pan
.It transgender, trans
.El
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It COLORTERM
Should be set by your terminal if it supports colors. If set,
.Nm
will use 256-color mode.
.Sh SEE ALSO
.Xr pride 6
.Sh HISTORY
.Nm
is a C port of
.Xr pride 6
made for reduced color terminals and embedded systems.
.Sh AUTHORS
.An -nosplit
.An Valerie Wolfe Aq Mt sleeplessval@gmail.com

41
name.h
View file

@ -1,41 +0,0 @@
#define RAINBOW 229480993726103lu
#define EMPTY 5381lu
#define AROMANTIC 249881625443197539lu
#define ARO 193486503lu
#define AROACE 6953324567312lu
#define ARO_ACE 229459708850429lu
#define ASEXUAL 229459738843608lu
#define ACE 193485998lu
#define BIGENDER 7572201141092229lu
#define BISEXUAL 7572201611094690lu
#define BI 5863248lu
#define GAY 193492486lu
#define MLM 193499371lu
#define GENDERFLUID 13875257415654095150lu
#define LESBIAN 229473412894979lu
#define WLW 193510271lu
#define NONBINARY 249899779187415445lu
#define NB 5863637lu
#define PANSEXUAL 249901996007388822lu
#define PAN 193502276lu
#define TRANSGENDER 13895753452281080578lu
#define TRANS 210729322765lu