chore: cleanup repository and add Gitea Actions build workflow
Some checks failed
Build / build (push) Failing after 5s
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:
120
main.c
120
main.c
@@ -1,31 +1,111 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "draw.h"
|
||||
#include "main.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#define sleep_ms(ms) Sleep(ms)
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define sleep_ms(ms) usleep((ms) * 1000)
|
||||
#endif
|
||||
int main(int argc, char *argv[]) {
|
||||
char input[4096];
|
||||
char* data = NULL;
|
||||
size_t data_len = 0;
|
||||
|
||||
int main() {
|
||||
char output[1024];
|
||||
if (argc > 1) {
|
||||
// Read from file
|
||||
FILE *f = fopen(argv[1], "rb");
|
||||
if (f == NULL) {
|
||||
perror("Error opening file");
|
||||
return 1;
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
data_len = ftell(f);
|
||||
fseek(f, 0, SEEK_SET);
|
||||
|
||||
getInitialWorries(output);
|
||||
data = malloc(data_len + 1);
|
||||
if (data == NULL) {
|
||||
fprintf(stderr, "Memory allocation failed\n");
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
fread(data, 1, data_len, f);
|
||||
data[data_len] = '\0';
|
||||
fclose(f);
|
||||
} else {
|
||||
// Get input from user
|
||||
drawEdges();
|
||||
drawEmptyLines(1);
|
||||
drawTitle(TITLE);
|
||||
drawEmptyLines(1);
|
||||
drawEdges();
|
||||
|
||||
getUserInput(input, "What's weighing on your soul?");
|
||||
data = strdup(input);
|
||||
data_len = strlen(data);
|
||||
}
|
||||
|
||||
drawEdges();
|
||||
drawEmptyLines(1);
|
||||
drawTitle(TITLE);
|
||||
drawEmptyLines(1);
|
||||
drawEdges();
|
||||
printf("%s", output);
|
||||
if (data == NULL || strlen(data) == 0) {
|
||||
printf("The void remains silent. (No input provided)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Main interaction loop
|
||||
int choice = -1;
|
||||
while (choice != 0) {
|
||||
printf("\033[H\033[J"); // Clear screen
|
||||
drawEdges();
|
||||
drawEmptyLines(1);
|
||||
drawTitle("THE VOID AWAITS");
|
||||
drawEmptyLines(1);
|
||||
|
||||
if (argc > 1) {
|
||||
char file_info[256];
|
||||
snprintf(file_info, sizeof(file_info), "File: %s (%zu bytes)", argv[1], data_len);
|
||||
drawTitle(file_info);
|
||||
} else {
|
||||
// Show a preview of the string
|
||||
char preview[100];
|
||||
strncpy(preview, data, 96);
|
||||
if (strlen(data) > 96) strcat(preview, "...");
|
||||
drawTitle(preview);
|
||||
}
|
||||
|
||||
drawEmptyLines(1);
|
||||
drawEdges();
|
||||
drawEmptyLines(1);
|
||||
drawTitle("1. Scream it into the void (Standard)");
|
||||
drawTitle("2. Let it burn (Fire)");
|
||||
drawTitle("3. Let it dissolve (Acid)");
|
||||
drawTitle("0. Keep it to yourself (Exit)");
|
||||
drawEmptyLines(1);
|
||||
drawEdges();
|
||||
|
||||
printf("Choose your release: ");
|
||||
if (scanf("%d", &choice) != 1) {
|
||||
while (getchar() != '\n'); // clear buffer
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (choice) {
|
||||
case 1:
|
||||
screamIntoVoid(data);
|
||||
choice = 0; // Exit after screaming
|
||||
break;
|
||||
case 2:
|
||||
burnText(data);
|
||||
choice = 0;
|
||||
break;
|
||||
case 3:
|
||||
dissolveText(data);
|
||||
choice = 0;
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
printf("Invalid choice.\n");
|
||||
sleep_ms(1000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void getInitialWorries(char* output) {
|
||||
scanf("What's on your mind? %s\n", output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user