diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml
new file mode 100644
index 0000000..aec2309
--- /dev/null
+++ b/.gitea/workflows/build.yaml
@@ -0,0 +1,13 @@
+name: Build
+on: [push]
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install dependencies
+ run: sudo apt-get update && sudo apt-get install -y cmake build-essential
+ - name: Configure CMake
+ run: cmake -B build
+ - name: Build
+ run: cmake --build build
diff --git a/.gitignore b/.gitignore
index a7f389f..00b817c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,24 @@
-.vscode
-cmake-build-debug
-build
\ No newline at end of file
+# CMake
+CMakeCache.txt
+CMakeFiles/
+CMakeLists.txt.user
+cmake_install.cmake
+install_manifest.txt
+Makefile
+cmake-build-debug/
+cmake-build-release/
+build/
+bin/
+
+# Executables
+ScreamIntoTheVoid
+
+# IDEs
+.idea/
+.vscode/
+*.swp
+*.swo
+
+# OS
+.DS_Store
+Thumbs.db
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 30cf57e..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
-# Editor-based HTTP Client requests
-/httpRequests/
-# Ignored default folder with query files
-/queries/
-# Datasource local storage ignored files
-/dataSources/
-/dataSources.local.xml
diff --git a/.idea/ScreamIntoTheVoid.iml b/.idea/ScreamIntoTheVoid.iml
deleted file mode 100644
index 4c94235..0000000
--- a/.idea/ScreamIntoTheVoid.iml
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
deleted file mode 100644
index 1798069..0000000
--- a/.idea/editor.xml
+++ /dev/null
@@ -1,346 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 0b76fe5..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 677dbcf..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
deleted file mode 100644
index c2098a2..0000000
--- a/.vscode/c_cpp_properties.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "configurations": [
- {
- "name": "linux-gcc-x64",
- "includePath": [
- "${workspaceFolder}/**"
- ],
- "compilerPath": "/usr/bin/gcc",
- "cStandard": "${default}",
- "cppStandard": "${default}",
- "intelliSenseMode": "linux-gcc-x64",
- "compilerArgs": [
- ""
- ]
- }
- ],
- "version": 4
-}
\ No newline at end of file
diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index 3c920e3..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- "name": "C/C++ Runner: Debug Session",
- "type": "cppdbg",
- "request": "launch",
- "args": [],
- "stopAtEntry": false,
- "externalConsole": false,
- "cwd": "/home/jannis/dev/ScreamIntoTheVoid",
- "program": "/home/jannis/dev/ScreamIntoTheVoid/build/Debug/outDebug",
- "MIMode": "gdb",
- "miDebuggerPath": "gdb",
- "setupCommands": [
- {
- "description": "Enable pretty-printing for gdb",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
deleted file mode 100644
index a2e7291..0000000
--- a/.vscode/settings.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "C_Cpp_Runner.cCompilerPath": "gcc",
- "C_Cpp_Runner.cppCompilerPath": "g++",
- "C_Cpp_Runner.debuggerPath": "gdb",
- "C_Cpp_Runner.cStandard": "",
- "C_Cpp_Runner.cppStandard": "",
- "C_Cpp_Runner.msvcBatchPath": "",
- "C_Cpp_Runner.useMsvc": false,
- "C_Cpp_Runner.warnings": [
- "-Wall",
- "-Wextra",
- "-Wpedantic",
- "-Wshadow",
- "-Wformat=2",
- "-Wcast-align",
- "-Wconversion",
- "-Wsign-conversion",
- "-Wnull-dereference"
- ],
- "C_Cpp_Runner.msvcWarnings": [
- "/W4",
- "/permissive-",
- "/w14242",
- "/w14287",
- "/w14296",
- "/w14311",
- "/w14826",
- "/w44062",
- "/w44242",
- "/w14905",
- "/w14906",
- "/w14263",
- "/w44265",
- "/w14928"
- ],
- "C_Cpp_Runner.enableWarnings": true,
- "C_Cpp_Runner.warningsAsError": false,
- "C_Cpp_Runner.compilerArgs": [],
- "C_Cpp_Runner.linkerArgs": [],
- "C_Cpp_Runner.includePaths": [],
- "C_Cpp_Runner.includeSearch": [
- "*",
- "**/*"
- ],
- "C_Cpp_Runner.excludeSearch": [
- "**/build",
- "**/build/**",
- "**/.*",
- "**/.*/**",
- "**/.vscode",
- "**/.vscode/**"
- ],
- "C_Cpp_Runner.useAddressSanitizer": false,
- "C_Cpp_Runner.useUndefinedSanitizer": false,
- "C_Cpp_Runner.useLeakSanitizer": false,
- "C_Cpp_Runner.showCompilationTime": false,
- "C_Cpp_Runner.useLinkTimeOptimization": false,
- "C_Cpp_Runner.msvcSecureNoWarnings": false,
- "rpc.enabled": true
-}
\ No newline at end of file
diff --git a/README.md b/README.md
index a29177f..0f6bb3c 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@ Did you ever wanted to just scream your feelings and make sure your secrets are
## Todo
-- [ ] pass files via args
-- [ ] give user a choice on how to delete the string
-- [ ] in the main menu, show the string, or the filename with filesize
-- [ ] actually implement destroying the data
-- [ ] write descriptions so the user knows whats happening
\ No newline at end of file
+- [x] pass files via args
+- [x] give user a choice on how to delete the string
+- [x] in the main menu, show the string, or the filename with filesize
+- [x] actually implement destroying the data
+- [x] write descriptions so the user knows whats happening
\ No newline at end of file
diff --git a/draw.c b/draw.c
index 5e6b4c5..1293195 100644
--- a/draw.c
+++ b/draw.c
@@ -3,7 +3,9 @@
#include
#include
#include
+#include
#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;
-}
\ No newline at end of file
+}
+
+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);
+}
diff --git a/draw.h b/draw.h
index f79fe67..6fdea24 100644
--- a/draw.h
+++ b/draw.h
@@ -51,4 +51,19 @@ void getUserInput(char* output, char* displayText);
char** splitByNewLine(char *str, int *lineCount);
+/**
+ * @brief Animates the text disappearing into the void.
+ */
+void screamIntoVoid(char* text);
+
+/**
+ * @brief Animates the text burning away.
+ */
+void burnText(char* text);
+
+/**
+ * @brief Animates the text dissolving.
+ */
+void dissolveText(char* text);
+
#endif
\ No newline at end of file
diff --git a/main.c b/main.c
index aa4696c..e60e6c1 100644
--- a/main.c
+++ b/main.c
@@ -1,31 +1,111 @@
#include
#include
+#include
#include "draw.h"
#include "main.h"
-#ifdef _WIN32
- #include
- #define sleep_ms(ms) Sleep(ms)
-#else
- #include
- #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);
-}
diff --git a/main.h b/main.h
index 32216dc..f562fa4 100644
--- a/main.h
+++ b/main.h
@@ -3,6 +3,12 @@
#define TITLE "Scream your thoughts into the void!"
-void getInitialWorries(char* output);
+#ifdef _WIN32
+ #include
+ #define sleep_ms(ms) Sleep(ms)
+#else
+ #include
+ #define sleep_ms(ms) usleep((ms) * 1000)
+#endif
#endif
\ No newline at end of file