chore: cleanup repository and add Gitea Actions build workflow
Some checks failed
Build / build (push) Failing after 5s

- Update .gitignore to exclude build artifacts and IDE files
- Remove tracked .idea and .vscode directories from index
- Add .gitea/workflows/build.yaml for CI
- Commit existing source changes and README updates
This commit is contained in:
2026-06-07 17:40:03 +02:00
parent 8121288e57
commit 873ae5ae9d
16 changed files with 336 additions and 532 deletions

194
draw.c
View File

@@ -3,7 +3,9 @@
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <time.h>
#include "draw.h"
#include "main.h"
void drawEdges() {
for (int i = 0; i < WIDTH; i++) {
@@ -17,17 +19,25 @@ void drawTitle(char* title) {
printf("%c", SEPERATION_CHAR);
// calculate amount of spaces before and after the word
int spacing = (WIDTH - 2 - strlen(title)) / 2;
int title_len = strlen(title);
int spacing = (WIDTH - 2 - title_len) / 2;
if (spacing < 0) spacing = 0;
for (int i = 0; i < spacing; i++) {
printf(" ");
}
printf("%s", title);
// Print title, but truncate if it's too long
if (title_len > WIDTH - 2) {
for(int i = 0; i < WIDTH - 5; i++) printf("%c", title[i]);
printf("...");
} else {
printf("%s", title);
}
// we check if either the length of the title or the width is odd.
if ((strlen(title) + WIDTH) % 2 == 1) {
spacing += 1;
}
for (int i = 0; i < spacing; i++) {
int remaining = WIDTH - 2 - spacing - (title_len > WIDTH - 2 ? WIDTH - 2 : title_len);
for (int i = 0; i < remaining; i++) {
printf(" ");
}
printf("%c\n", SEPERATION_CHAR);
@@ -87,51 +97,191 @@ void getUserInput(char* output, char* displayText) {
col--;
printf("\b \b");
}
// Note: Backspacing across lines is omitted for simplicity
// but could be added with more complex cursor management.
}
} else {
// Check if we have space in output (assume output is large enough or handle gracefully)
output[i++] = ch;
printf("%c", ch);
col++;
// If we reach the end of the text area (WIDTH - 1 is the space before #)
if (col == WIDTH - 1) {
// Move to next line and draw new borders
printf("\n%c ", SEPERATION_CHAR);
for (int j = 0; j < WIDTH - 4; j++) printf(" ");
printf(" %c", SEPERATION_CHAR);
printf("\033[%dG", 3); // Move to column 3
printf("\033[%dG", 3);
col = 3;
}
}
fflush(stdout);
}
// 4. Restore terminal settings
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
}
char** splitByNewLine(char *str, int *lineCount) {
int maxLines = 100;
int maxLines = 1000;
char **lines = malloc(maxLines * sizeof(char*));
int count = 0;
char *token = strtok(str, "\n");
while (token != NULL) {
lines[count] = token; // Store the pointer to this line
lines[count] = token;
count++;
if (count >= maxLines) {
break; // Safety check so we don't overflow our array
}
if (count >= maxLines) break;
token = strtok(NULL, "\n");
}
*lineCount = count; // Pass the total count back to the caller
*lineCount = count;
return lines;
}
}
void screamIntoVoid(char* text) {
srand(time(NULL));
char* copy = strdup(text);
int len = strlen(copy);
for (int step = 0; step <= 20; step++) {
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(2);
for (int i = 0; i < len; i++) {
if (copy[i] != ' ' && copy[i] != '\n' && copy[i] != '.' && (rand() % 100) < (step * 7)) {
copy[i] = (rand() % 2 == 0) ? '.' : ' ';
}
}
char* temp_copy = strdup(copy);
int lineCount;
char** lines = splitByNewLine(temp_copy, &lineCount);
if (lineCount == 0) {
drawTitle(" ");
} else {
for(int i = 0; i < lineCount; i++) {
drawTitle(lines[i]);
}
}
free(lines);
free(temp_copy);
drawEmptyLines(2);
drawEdges();
fflush(stdout);
sleep_ms(150);
}
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(5);
drawTitle("...");
drawTitle("It's gone.");
drawTitle("The void has consumed your worries.");
drawEmptyLines(5);
drawEdges();
fflush(stdout);
sleep_ms(3000);
free(copy);
}
void burnText(char* text) {
srand(time(NULL));
char* copy = strdup(text);
int len = strlen(copy);
char* fire_chars = "@#%*+=-:. ";
int fire_len = strlen(fire_chars);
for (int step = 0; step <= 25; step++) {
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(2);
for (int i = 0; i < len; i++) {
if (copy[i] != ' ' && copy[i] != '\n') {
int r = rand() % 100;
if (r < (step * 10)) {
int char_idx = (step / 3) + (rand() % 3);
if (char_idx >= fire_len) copy[i] = ' ';
else copy[i] = fire_chars[char_idx];
}
}
}
char* temp_copy = strdup(copy);
int lineCount;
char** lines = splitByNewLine(temp_copy, &lineCount);
if (lineCount == 0) {
drawTitle(" ");
} else {
for(int i = 0; i < lineCount; i++) {
drawTitle(lines[i]);
}
}
free(lines);
free(temp_copy);
drawEmptyLines(2);
drawEdges();
fflush(stdout);
sleep_ms(100);
}
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(5);
drawTitle("Ashes to ashes.");
drawTitle("Dust to dust.");
drawEmptyLines(5);
drawEdges();
fflush(stdout);
sleep_ms(3000);
free(copy);
}
void dissolveText(char* text) {
srand(time(NULL));
char* copy = strdup(text);
int len = strlen(copy);
for (int step = 0; step <= 30; step++) {
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(2);
for (int i = 0; i < len; i++) {
if (copy[i] != ' ' && copy[i] != '\n') {
if ((rand() % 100) < (step * 5)) {
copy[i] = (rand() % 5 == 0) ? '~' : (rand() % 2 == 0 ? ',' : ' ');
}
}
}
char* temp_copy = strdup(copy);
int lineCount;
char** lines = splitByNewLine(temp_copy, &lineCount);
if (lineCount == 0) {
drawTitle(" ");
} else {
for(int i = 0; i < lineCount; i++) {
drawTitle(lines[i]);
}
}
free(lines);
free(temp_copy);
drawEmptyLines(2);
drawEdges();
fflush(stdout);
sleep_ms(100);
}
printf("\033[H\033[J");
drawEdges();
drawEmptyLines(5);
drawTitle("Dissolved into nothingness.");
drawEmptyLines(5);
drawEdges();
fflush(stdout);
sleep_ms(3000);
free(copy);
}