diff --git a/.gitignore b/.gitignore index 69f56a1..f3bc4e8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ CMakeUserPresets.json .cache build +bin diff --git a/bin/TartLib.a b/bin/TartLib.a deleted file mode 100644 index 5070913..0000000 Binary files a/bin/TartLib.a and /dev/null differ diff --git a/buffer.buf b/buffer.buf deleted file mode 100644 index e69de29..0000000 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5dd2f4f..3a745d0 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -5,6 +5,8 @@ set(SOURCE_FILES commands.h editor.h editor.c + nomi.c + nomi.h ) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) diff --git a/source/editor.c b/source/editor.c index bec2a6c..6253f1d 100644 --- a/source/editor.c +++ b/source/editor.c @@ -2,6 +2,9 @@ #define EDITOR_H #include +#include "editor.h" + + struct tart_window window; @@ -15,6 +18,14 @@ struct commandMode { char* input; }; +struct bottomBar { + struct tart_cstring mode_cstr; + struct tart_cstring file_cstr; + struct tart_cstring branch_cstr; + struct tart_cell bottomBar_cell; +}; + + struct InsertMode { }; @@ -31,12 +42,12 @@ void InitNormalMode(); void InitNomiMode(); -void CommandMode(struct CommandMode cmdm) { +void CommandMode(struct commandMode cmdm) { tart_draw_cstring_position(tart_get_buffer(&window, 0), - commandInput_cstr, + cmdm.input_cstr, (struct tart_vec2){16,10}); tart_draw_cstring_position(tart_get_buffer(&window, 0), - commandPrompt_cstr, + cmdm.prompt_cstr, (struct tart_vec2){0,10}); } void InsertMode(); diff --git a/source/main.c b/source/main.c index 2920f7b..88503aa 100644 --- a/source/main.c +++ b/source/main.c @@ -21,6 +21,7 @@ #include #include "commands.h" +#include "nomi.h" #define KEY_BACKSPACE 127 #define COMMAND_MODE 0x01 @@ -127,7 +128,7 @@ int main (int argc, char *argv[]) { // Window Createion struct tart_window window = tart_create_window(); struct tart_buffer buf = tart_create_buffer(0, - (struct tart_vec2){40,20}, + term_current_size(), (struct tart_vec2){0,0}); tart_add_buffer(&window, buf); @@ -257,6 +258,10 @@ int main (int argc, char *argv[]) { keyPressed = 0; } drawTextBox(&window, &inputRtb, 0); + + + DrawBranch(NULL, &window, 0); + tart_draw_window(&window, 0); if(mode == COMMAND_MODE) { tart_draw_cstring_position(tart_get_buffer(&window, 0), diff --git a/source/nomi.c b/source/nomi.c index e69de29..3bea9eb 100644 --- a/source/nomi.c +++ b/source/nomi.c @@ -0,0 +1,165 @@ +#include +#include +#include "nomi.h" +#include + +#define SPIREL_MOD 0.618055f + +struct nomiSpirel { + struct tart_cell selected_cell; + struct tart_cell unselected_cell; + struct tart_vec2 startPos; + struct tart_vec2 size; + struct tart_vec2 endPos; + unsigned char oreantation; + int fibonacci[3]; +}; + +struct nomiMenu { + struct nomiSpirel branches[30]; + struct tart_vec2 startPos; + struct tart_vec2 size; + struct tart_vec2 origin; + unsigned char brachIds[30]; +}; + +/* + * This will Init Nomi + */ +void NomiInit(); +/* + * This will create the truk of the note. + * */ +trunk* CreateTrunk(); + +/* + * This is a test + * */ +void CreaetBranch(trunk* trunk); + +/* + * Locate Branch + * */ +branch* LocateBranch(); + +/* + * Draw Branch + */ +void DrawBranch(branch* branch, struct tart_window* w, tart_byte b) { + struct tart_cell cell = NULL_CELL; + cell.display = '*'; + struct nomiSpirel spirel; + int SizeOfFile = 210; + char cellChart[] = {'%','*','\\','/','l','&','b','+','=','^',':'}; + int iderations = 0; + int fib = 0; + int fib1 = 1; + int fib2 = 0; + struct tart_vec2 pos = {40,10}; + struct tart_vec2 nextPos; + unsigned int count = 0; + + while(SizeOfFile/10 > fib) { + + // This is the direction that the spirel is oreanted + // 0 = up + // 1 = left + // 2 = down + // 3 = right + + if(iderations < 3){ + iderations++; + } else { + iderations = 0; + } + + fib = fib1 + fib2; + fib2 = fib1; + fib1 = fib; + + + cell.display = cellChart[rand_r(&count)%11]; + + switch(iderations) { + case 0: // up + pos.x += fib/2; + pos.y += fib/2; + for(int i = 0; i < fib/2; i ++){ + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x-(i-2), pos.y-i}); + count++; + cell.display = cellChart[rand_r(&count)%11]; + + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x-(i-2) + 1, pos.y-i}); + } + break; + case 1: // right + pos.x += fib/2; + pos.y -= fib/2; + for(int i = 0; i < fib/2; i ++){ + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x - i, pos.y+i}); + count++; + cell.display = cellChart[rand_r(&count)%11]; + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x-i + 1, pos.y+i}); + } + break; + case 2: // down + pos.x -= fib/2; + pos.y -= fib/2; + for(int i = 0; i < fib/2; i ++){ + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x+(i+2), pos.y+i}); + count++; + cell.display = cellChart[rand_r(&count)%11]; + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x+(i+2) + 1, pos.y+i}); + } + break; + case 3: // left + pos.x -= fib/2; + pos.y += fib/2; + for(int i = 0; i < fib/2; i ++){ + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x+i, pos.y-i}); + count++; + cell.display = cellChart[rand_r(&count)%11]; + tart_draw_cell_position(tart_get_buffer(w, b), + cell, + (struct tart_vec2){pos.x+ i + 1, pos.y-i}); + } + break; + } + + count++; + } + + //for(int i = 0; i < rint((SizeOfFile/10.0f)*SPIREL_MOD); i++) { + // + //} + + +} + +/* + * Create Nomi File + * + * name: the name of the file that will be created. + */ +FILE CreateNomiFile(const char* name); + +/* + * Save Nomi File + * + * file: the pointer to the nomi file. + */ +void SaveNomiFile(FILE* file); diff --git a/source/nomi.h b/source/nomi.h index 153b83d..418d7ef 100644 --- a/source/nomi.h +++ b/source/nomi.h @@ -14,6 +14,7 @@ #ifndef NOMI_H #define NOMI_H +#include "tart.h" #define BRNACH 0x01 #define TRUNK 0x00 #define MAX_CHILDREN 5 @@ -61,7 +62,7 @@ branch* LocateBranch(); /* * Draw Branch */ -void DrawBranch(branch* branch); +void DrawBranch(branch* branch, struct tart_window* w, tart_byte b); /* * Create Nomi File