diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c795b05..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# 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 new file mode 100644 index 0000000..4c94235 --- /dev/null +++ b/.idea/ScreamIntoTheVoid.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..1798069 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,346 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..677dbcf --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c2098a2 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "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 new file mode 100644 index 0000000..3c920e3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "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 new file mode 100644 index 0000000..a2e7291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,60 @@ +{ + "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/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5ce2473 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.10.0) +project(ScreamIntoTheVoid VERSION 0.1.0 LANGUAGES C) + +add_executable(ScreamIntoTheVoid draw.c main.c + main.h) + diff --git a/draw.c b/draw.c new file mode 100644 index 0000000..35a9fbf --- /dev/null +++ b/draw.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include "draw.h" + +void drawEdges() { + for (int i = 0; i < WIDTH; i++) { + printf("%c", SEPERATION_CHAR); + } + printf("\n"); +} + +void drawTitle(char* title) { + // put seperation_char at start and end + printf("%c", SEPERATION_CHAR); + + // calculate amount of spaces before and after the word + int spacing = (WIDTH - 2 - strlen(title)) / 2; + for (int i = 0; i < spacing; i++) { + printf(" "); + } + printf("%s", title); + if (strlen(title) % 2 != WIDTH % 2) { + spacing += 1; + } + for (int i = 0; i < spacing; i++) { + printf(" "); + } + printf("%c\n", SEPERATION_CHAR); +} + +void drawEmptyLines(const int amount) { + for (int i = 0; i < amount; i++) { + printf("%c", SEPERATION_CHAR); + for (int j = 0; j < WIDTH - 2; j++) { + printf(" "); + } + printf("%c\n", SEPERATION_CHAR); + } + +} + +char** splitByNewline(char *str, int *lineCount) { + int maxLines = 100; + 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 + count++; + + if (count >= maxLines) { + break; // Safety check so we don't overflow our array + } + + token = strtok(NULL, "\n"); + } + + *lineCount = count; // Pass the total count back to the caller + return lines; +} \ No newline at end of file diff --git a/draw.h b/draw.h new file mode 100644 index 0000000..591ebe4 --- /dev/null +++ b/draw.h @@ -0,0 +1,46 @@ +#ifndef DRAW_H_ +#define DRAW_H_ + + +/** + * @brief The width at which everything gets rendered. + */ +#define WIDTH 140 + +/** + * @brief The character used for the edges and layout in general + */ +#define SEPERATION_CHAR '#' + +/** + * @brief Draws the Upper and Lower bar using the SEPERATION_CHAR + * + * This function prints out the SEPERATION_CHAR out by WIDTH amount of times. + * It simply runs a for-loop + * + * @see WIDTH, SEPERATION_CHAR + */ +void drawEdges(); + +/** + * @brief prints the title in the standard formatting centered. + * + * prints out the title centered and calculates the spacing based on the WIDTH and the length of the title. + * Puts an SEPERATION_CHAR at the start and end of the line. + * + * @param title the title that should be printed out. Type is char* + * + * @see SEPERATION_CHAR, WIDTH + */ +void drawTitle(char* title); + +/** + * @brief Draws the amount of empty lines, passed as amount + * + * @param amount + */ +void drawEmptyLines(int amount); + +char** splitByNewLine(char *str, int *lineCount); + +#endif \ No newline at end of file diff --git a/main.c b/main.c index a864fed..c2c83ee 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ -#include -#include +#include "draw.h" +#include "main.h" #ifdef _WIN32 #include @@ -10,17 +10,24 @@ #endif int main() { - char *buffer = NULL; - size_t buffsize = 0; - ssize_t characters; + // char *buffer = NULL; + // size_t buffsize = 0; + // ssize_t characters; - printf("What do you worry about? \n"); - characters = getline(&buffer, &buffsize, stdin); + // printf("Python alter leck meine eier? \n"); + // characters = getline(&buffer, &buffsize, stdin); - if (characters != -1) { - printf("you typed %s\n", buffer); - } + // if (characters != -1) { + // printf("you typed %s\n", buffer); + // } sleep_ms(500); + + drawEdges(); + drawEmptyLines(1); + drawTitle(TITLE); + drawEmptyLines(1); + drawEdges(); + return 0; -} \ No newline at end of file +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..ad24457 --- /dev/null +++ b/main.h @@ -0,0 +1,6 @@ +#ifndef MAIN_H_ +#define MAIN_H_ + +#define TITLE "Scream your thoughts into the void!" + +#endif \ No newline at end of file