Compare commits

...

8 commits

7 changed files with 82 additions and 39 deletions

18
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,
@ -17,7 +15,7 @@ void rainbow_8() {
}
void aroace_8() {
color colors [] = {
const color colors [] = {
YELLOW,
L_YELLOW,
WHITE,
@ -28,7 +26,7 @@ void aroace_8() {
}
void bisexual_8() {
color colors [] = {
const color colors [] = {
RED,
RED,
MAGENTA,
@ -39,7 +37,7 @@ void bisexual_8() {
}
void gay_8() {
color colors [] = {
const color colors [] = {
CYAN,
L_CYAN,
WHITE,
@ -50,7 +48,7 @@ void gay_8() {
}
void lesbian_8() {
color colors [] = {
const color colors [] = {
RED,
L_RED,
WHITE,
@ -61,7 +59,7 @@ void lesbian_8() {
}
void nonbinary_8() {
color colors [] = {
const color colors [] = {
L_YELLOW,
WHITE,
MAGENTA,
@ -71,7 +69,7 @@ void nonbinary_8() {
}
void pansexual_8() {
color colors [] = {
const color colors [] = {
MAGENTA,
MAGENTA,
L_YELLOW,
@ -83,7 +81,7 @@ void pansexual_8() {
}
void transgender_8() {
color colors [] = {
const color colors [] = {
L_CYAN,
L_MAGENTA,
WHITE,

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[]);

20
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
@ -17,7 +15,7 @@ void rainbow_256() {
}
void aroace_256() {
color colors [] = {
const color colors [] = {
172, // orange
184, // yellow
255, // white
@ -28,7 +26,7 @@ void aroace_256() {
}
void bisexual_256() {
color colors [] = {
const color colors [] = {
161, // magenta
161,
91, // purple
@ -39,7 +37,7 @@ void bisexual_256() {
}
void gay_256() {
color colors [] = {
const color colors [] = {
29,
49, // greens
123,
@ -52,18 +50,18 @@ void gay_256() {
}
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
@ -73,7 +71,7 @@ void nonbinary_256() {
}
void pansexual_256() {
color colors [] = {
const color colors [] = {
161, 161, // magenta
220, 220, // yellow
45, 45 // cyan
@ -82,7 +80,7 @@ void pansexual_256() {
}
void transgender_256() {
color colors [] = {
const color colors [] = {
45, // blue
213, // pink
255, // white

View file

@ -1,4 +1,4 @@
build:
gcc main.c draw.c basic.c full.c -o pride-c
gcc -s main.c draw.c basic.c full.c -o pride-c

31
main.c
View file

@ -2,11 +2,10 @@
#include <stdlib.h>
#include <string.h>
#include "draw.h"
#include "basic.h"
#include "full.h"
#define VERSION "0.0.1"
#define VERSION "0.0.4"
#define RESET "\x1b[0m"
@ -34,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;
@ -51,19 +50,10 @@ int main(int argc, char **argv) {
else { flag = ""; }
int color_mode = 0;
char * term = getenv("TERM");
if(strcmp(term, "linux"))
char * colorterm = getenv("COLORTERM");
if(colorterm != NULL && strcmp(colorterm, ""))
color_mode = 1;
// handle flags
if(strcmp(flag, "--version") == 0) {
version();
return 0;
} else if(strcmp(flag, "--help") == 0) {
help();
return 0;
}
unsigned long flag_hash = djb_hash(flag);
char *output;
@ -124,6 +114,17 @@ int main(int argc, char **argv) {
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