Initial commit
This commit is contained in:
commit
1ce8c47bcc
7
C/scripts/build.sh
Executable file
7
C/scripts/build.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#Compiles the entire program then runs it, producing an executable.
|
||||||
|
#C
|
||||||
|
printf "Running program...\n\n\n"
|
||||||
|
if gcc $(find . -type f -name "*.c") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then
|
||||||
|
./${PROJECT_NAME} "$@"
|
||||||
|
fi
|
||||||
|
printf "\n\n"
|
20
C/scripts/commit.sh
Executable file
20
C/scripts/commit.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#Adds a commit message and pushes project to github repository.
|
||||||
|
#C
|
||||||
|
COMMIT_MESSAGE="$*"
|
||||||
|
FIRST_LINE=true
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
if [ "$FIRST_LINE" = true ]; then
|
||||||
|
COMMIT_MESSAGE+="
|
||||||
|
|
||||||
|
Co-authored-by: $line"
|
||||||
|
FIRST_LINE=false
|
||||||
|
else
|
||||||
|
COMMIT_MESSAGE+="
|
||||||
|
Co-authored-by: $line"
|
||||||
|
fi
|
||||||
|
done < utils/.coauthors
|
||||||
|
git add -u
|
||||||
|
git add *
|
||||||
|
git commit -m "$COMMIT_MESSAGE"
|
||||||
|
git push
|
2
C/scripts/filelist
Normal file
2
C/scripts/filelist
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build.sh
|
||||||
|
commit.sh
|
2
C/scripts/md5
Normal file
2
C/scripts/md5
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
build.sh:fcbd8c14fe2a608d11166cf5aa7dba02 -
|
||||||
|
commit.sh:89783d2e6a165aa9612c79cfbd804a35 -
|
BIN
CProjectTemplate
Executable file
BIN
CProjectTemplate
Executable file
Binary file not shown.
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
This repository provides a template for starting a new C project using Sig's build system! Updates are automatically propogated. Run `./sig` for a list of commands and then use follow the instructions given to invoke them. Adjust variables as necessary in the `sig` command file.
|
||||||
|
|
||||||
|
```
|
||||||
|
@sigonasr2 ➜ /workspaces/CProjectTemplate (main) $ ./sig
|
||||||
|
Dev build, no checks required.
|
||||||
|
|
||||||
|
Usage: ./sig <command> {args}
|
||||||
|
|
||||||
|
==== Current Configuration =====================
|
||||||
|
PROJECT_NAME CProjectTemplate
|
||||||
|
BUILD_OPTIONS -lncurses
|
||||||
|
LANGUAGE C
|
||||||
|
=====================================================
|
||||||
|
|
||||||
|
Command List:
|
||||||
|
|
||||||
|
build Compiles the entire program then runs it, producing an executable.
|
||||||
|
commit Adds a commit message and pushes project to github repository.
|
||||||
|
'``
|
15
install
Executable file
15
install
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
echo "Initializing..."
|
||||||
|
FILES=$(ls -dA */)
|
||||||
|
LANGUAGES=()
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
if [ "$f" != "scripts/" ] && [ "$f" != "utils/" ];
|
||||||
|
then
|
||||||
|
LANGUAGES+=(""${f::-1}"")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Languages Detected:"
|
||||||
|
for f in "${LANGUAGES[@]}"
|
||||||
|
do
|
||||||
|
printf "\t%-15s\n" $f
|
||||||
|
done
|
173
main.c
Normal file
173
main.c
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
#include <curses.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ncurses.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include "project/utils/utils.h"
|
||||||
|
|
||||||
|
void drawBorder(WINDOW*box) {
|
||||||
|
int rows=getmaxy(box)+1;
|
||||||
|
int cols=getmaxx(box)+2;
|
||||||
|
int x=getbegx(box);
|
||||||
|
int y=getbegy(box);
|
||||||
|
//mvwprintw(box,3,1,"%d %d %d %d",x,y,rows,cols);
|
||||||
|
move(y-1,x-1);
|
||||||
|
for (int yy=0;yy<rows+1;yy++) {
|
||||||
|
for (int xx=0;xx<cols;xx++) {
|
||||||
|
if (xx==0||xx==cols-1) {
|
||||||
|
if (yy==0&&xx==0) {
|
||||||
|
addch(ACS_ULCORNER);
|
||||||
|
} else
|
||||||
|
if (yy==0&&xx==cols-1) {
|
||||||
|
addch(ACS_URCORNER);
|
||||||
|
} else
|
||||||
|
if (yy==rows&&xx==0) {
|
||||||
|
addch(ACS_LLCORNER);
|
||||||
|
} else
|
||||||
|
if (yy==rows&&xx==cols-1) {
|
||||||
|
addch(ACS_LRCORNER);
|
||||||
|
} else {
|
||||||
|
addch(ACS_VLINE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (yy==0||yy==rows) {
|
||||||
|
addch(ACS_HLINE);
|
||||||
|
} else {
|
||||||
|
move(getcury(stdscr),getcurx(stdscr)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Returns true if the window was toggled on, or false if it got hidden.
|
||||||
|
boolean ToggleWindow(WINDOW**win,int w,int h,int x,int y) {
|
||||||
|
if (*win!=NULL) {
|
||||||
|
*win=NULL;
|
||||||
|
delwin(*win);
|
||||||
|
clear();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
*win=newwin(h,w,y,x);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void changeColor(int*oldcol,int newcol) {
|
||||||
|
attroff(COLOR_PAIR(*oldcol));
|
||||||
|
attron(COLOR_PAIR(newcol));
|
||||||
|
*oldcol=newcol;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Provide the width and height that the background needs to cover as well as an offset x and y value.
|
||||||
|
void drawBackground(int*currentcol,int background_id,int x,int y,int w,int h) {
|
||||||
|
int oldcol=*currentcol;
|
||||||
|
switch(background_id) {
|
||||||
|
case 0:{
|
||||||
|
move(y,x);
|
||||||
|
for (int yy=0;yy<h;yy++) {
|
||||||
|
for (int xx=0;xx<w;xx++) {
|
||||||
|
if (xx%2==0) {
|
||||||
|
changeColor(currentcol,9);
|
||||||
|
} else {
|
||||||
|
changeColor(currentcol,10);
|
||||||
|
}
|
||||||
|
addch(ACS_DIAMOND);
|
||||||
|
}
|
||||||
|
move(getcury(stdscr)+1,x);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
changeColor(currentcol,oldcol);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc,char**argv) {
|
||||||
|
int*keyLog=calloc(25,sizeof(int));
|
||||||
|
unsigned short currentLogCounter=0;
|
||||||
|
unsigned int frameCount = 0;
|
||||||
|
int rows,cols;
|
||||||
|
clock_t lastTime = clock();
|
||||||
|
int FRAMETIME = CLOCKS_PER_SEC/60;
|
||||||
|
int currentcol=1;
|
||||||
|
|
||||||
|
initscr();
|
||||||
|
|
||||||
|
start_color();
|
||||||
|
getmaxyx(stdscr,rows,cols);
|
||||||
|
cbreak();
|
||||||
|
keypad(stdscr,TRUE);
|
||||||
|
nodelay(stdscr,TRUE);
|
||||||
|
noecho();
|
||||||
|
|
||||||
|
init_pair(1,COLOR_BLACK,COLOR_BLACK);
|
||||||
|
init_pair(2,COLOR_RED,COLOR_BLACK);
|
||||||
|
init_pair(3,COLOR_GREEN,COLOR_BLACK);
|
||||||
|
init_pair(4,COLOR_YELLOW,COLOR_BLACK);
|
||||||
|
init_pair(5,COLOR_BLUE,COLOR_BLACK);
|
||||||
|
init_pair(6,COLOR_MAGENTA,COLOR_BLACK);
|
||||||
|
init_pair(7,COLOR_CYAN,COLOR_BLACK);
|
||||||
|
init_pair(8,COLOR_WHITE,COLOR_BLACK);
|
||||||
|
init_pair(9,COLOR_GREEN,COLOR_WHITE);
|
||||||
|
init_pair(10,COLOR_BLACK,COLOR_GREEN);
|
||||||
|
changeColor(¤tcol,6);
|
||||||
|
|
||||||
|
WINDOW*messageBox=newwin(4,cols-2,rows-5,1);
|
||||||
|
drawBorder(messageBox);
|
||||||
|
//box(messageBox,0,0);
|
||||||
|
|
||||||
|
boolean resizeOccured=false;
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
getmaxyx(stdscr,rows,cols);
|
||||||
|
int ch=ERR;
|
||||||
|
while (true) {
|
||||||
|
if ((ch=getch())!=ERR) {
|
||||||
|
keyLog[currentLogCounter]=ch;
|
||||||
|
currentLogCounter=(currentLogCounter+1)%25;
|
||||||
|
switch (ch) {
|
||||||
|
case 'A':
|
||||||
|
case 'a':{
|
||||||
|
ToggleWindow(&messageBox,cols-2,4,1,rows-5);
|
||||||
|
}break;
|
||||||
|
case KEY_RESIZE:{
|
||||||
|
resizeOccured=true;
|
||||||
|
getmaxyx(stdscr,rows,cols);
|
||||||
|
}break;
|
||||||
|
case KEY_RIGHT:{
|
||||||
|
changeColor(¤tcol,(currentcol+1)%8);
|
||||||
|
}break;
|
||||||
|
case KEY_LEFT:{
|
||||||
|
changeColor(¤tcol,(currentcol-1>=0)?currentcol-1:7);
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (clock()-lastTime>FRAMETIME) {
|
||||||
|
if (resizeOccured) {
|
||||||
|
resizeOccured=false;
|
||||||
|
clear();
|
||||||
|
delwin(messageBox);
|
||||||
|
messageBox=newwin(4,cols-2,rows-5,1);
|
||||||
|
}
|
||||||
|
//mvprintw(5,7,"There are %dx%d squares. (%d)",cols,rows,frameCount++);
|
||||||
|
drawBackground(¤tcol,0,0,0,cols-1,rows);
|
||||||
|
if (messageBox!=NULL) {
|
||||||
|
drawBorder(messageBox);
|
||||||
|
mvwprintw(messageBox,0,0,"There are %dx%d squares. (%d) It is good!",cols,rows,frameCount);
|
||||||
|
}
|
||||||
|
for (int i=0;i<25;i++) {
|
||||||
|
if (keyLog[i]>0) {
|
||||||
|
mvprintw(6+i,2,"Key %d was pressed.",keyLog[i]);
|
||||||
|
short r,g,b;
|
||||||
|
color_content(currentcol,&r,&g,&b);
|
||||||
|
mvprintw(6+i,30,"%d %d %d",r,g,b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
wrefresh(messageBox);
|
||||||
|
lastTime=clock();
|
||||||
|
frameCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(keyLog);
|
||||||
|
endwin();
|
||||||
|
return 0;
|
||||||
|
}
|
6
project/extras.c
Normal file
6
project/extras.c
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <ncurses.h>
|
||||||
|
#include "extras.h"
|
||||||
|
|
||||||
|
void writeExtras(){
|
||||||
|
addch(ACS_PI);
|
||||||
|
}
|
1
project/extras.h
Normal file
1
project/extras.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
void writeExtras();
|
4
project/utils/utils.h
Normal file
4
project/utils/utils.h
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
#define boolean char
|
||||||
|
#define byte char
|
9
sig
Executable file
9
sig
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
export AUTO_UPDATE=true
|
||||||
|
|
||||||
|
source utils/define.sh
|
||||||
|
|
||||||
|
define PROJECT_NAME "main"
|
||||||
|
define CUSTOM_PARAMS "-lncurses"
|
||||||
|
define LANGUAGE "C"
|
||||||
|
|
||||||
|
source utils/main.sh
|
1
utils/.coauthors
Normal file
1
utils/.coauthors
Normal file
@ -0,0 +1 @@
|
|||||||
|
sigonasr2 <sigonasr2@gmail.com>
|
4
utils/.updateDirectories
Normal file
4
utils/.updateDirectories
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
Java/
|
||||||
|
C/
|
||||||
|
scripts/
|
||||||
|
utils/
|
26
utils/define.sh
Executable file
26
utils/define.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
export VARS=("")
|
||||||
|
|
||||||
|
export LANGUAGE=""
|
||||||
|
|
||||||
|
function define() {
|
||||||
|
VARS+=("$1")
|
||||||
|
value="${*:2}"
|
||||||
|
eval export "$1"='$value'
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then
|
||||||
|
source utils/search.sh
|
||||||
|
|
||||||
|
find . -type f -name md5 -delete
|
||||||
|
find . -type f -name filelist -delete
|
||||||
|
|
||||||
|
#Check for hashes
|
||||||
|
FILES=$(cat utils/.updateDirectories)
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
search $f
|
||||||
|
check $f
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Dev build, no checks required."
|
||||||
|
fi
|
5
utils/filelist
Normal file
5
utils/filelist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.coauthors
|
||||||
|
define.sh
|
||||||
|
main.sh
|
||||||
|
search.sh
|
||||||
|
.updateDirectories
|
28
utils/main.sh
Normal file
28
utils/main.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo " Usage: ./sig <command> {args}"
|
||||||
|
echo ""
|
||||||
|
printf "====\tCurrent Configuration"
|
||||||
|
printf "\t====================="
|
||||||
|
for t in ${VARS[@]}
|
||||||
|
do
|
||||||
|
printf "\n\t%-15s%20s" $t ${!t}
|
||||||
|
done
|
||||||
|
printf "\n====================================================="
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo " Command List:"
|
||||||
|
FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /')
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then
|
||||||
|
DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)"
|
||||||
|
printf "\n\t%-15s%-65s" $f "${DESC:1}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
./$LANGUAGE/scripts/$1.sh "${@:2}"
|
4
utils/md5
Normal file
4
utils/md5
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 -
|
||||||
|
main.sh:4e6e9f0650ec790ce2c4364db94f0caa -
|
||||||
|
search.sh:81d08f5ff48e8a44b5f68387d426da05 -
|
||||||
|
.updateDirectories:fa5e95db12be22ae8aed7ecbc560e38c -
|
103
utils/search.sh
Normal file
103
utils/search.sh
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
function search() {
|
||||||
|
FILES2=$(ls -A $1 2>/dev/null)
|
||||||
|
for g in $FILES2
|
||||||
|
do
|
||||||
|
if [ -d $1$g ];
|
||||||
|
then
|
||||||
|
echo "$1$g is a directory"
|
||||||
|
search $1$g/
|
||||||
|
else
|
||||||
|
echo "$1$g is a file"
|
||||||
|
if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then
|
||||||
|
if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then
|
||||||
|
SUM=$(md5sum < $1$g)
|
||||||
|
echo "$g:$SUM" >> $1md5
|
||||||
|
fi
|
||||||
|
echo "$g" >> $1filelist
|
||||||
|
else
|
||||||
|
echo " ignoring $g..."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
echo "Check $1"
|
||||||
|
FILES2=$(ls -A $1 2>/dev/null)
|
||||||
|
if [ -f "$1/md5" ];
|
||||||
|
then
|
||||||
|
echo " md5: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" --output /tmp/out
|
||||||
|
cmp -s $1/md5 /tmp/out
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo " Differences detected!"
|
||||||
|
cat /tmp/out
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
IFS=':' read -ra split <<< $line
|
||||||
|
g="${split[0]}"
|
||||||
|
echo "LINE -- $g"
|
||||||
|
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then
|
||||||
|
if [ -f $1$g ];
|
||||||
|
then
|
||||||
|
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then
|
||||||
|
echo "++Redownload $1$g..."
|
||||||
|
if [ -f "$1$g" ]; then
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g
|
||||||
|
else
|
||||||
|
echo "===Could not find directory, assuming regular scripts directory exists."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < /tmp/out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f "$1/filelist" ];
|
||||||
|
then
|
||||||
|
echo " filelist: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" --output /tmp/out
|
||||||
|
cmp -s $1/filelist /tmp/out
|
||||||
|
if [ "$?" -ne 0 ]
|
||||||
|
then
|
||||||
|
echo " Differences detected!"
|
||||||
|
cat /tmp/out
|
||||||
|
while IFS= read -r line
|
||||||
|
do
|
||||||
|
IFS=':' read -ra split <<< $line
|
||||||
|
g="${split[0]}"
|
||||||
|
echo "LINE -- $g"
|
||||||
|
if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then
|
||||||
|
if [ -f $1$g ];
|
||||||
|
then
|
||||||
|
if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then
|
||||||
|
echo "++Redownload $1$g..."
|
||||||
|
if [ -f "$1$g" ]; then
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g
|
||||||
|
else
|
||||||
|
echo "===Could not find directory, assuming regular scripts directory exists."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < /tmp/out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
for g in $FILES2
|
||||||
|
do
|
||||||
|
if [ -d $1$g ];
|
||||||
|
then
|
||||||
|
echo "$1$g is a directory"
|
||||||
|
check $1$g/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user