diff --git a/TODO.txt b/TODO.txt index 95a9afc4..661dece7 100644 --- a/TODO.txt +++ b/TODO.txt @@ -77,6 +77,7 @@ ; [X] make panel resizing not whacky with child panels ; [X] visual studio file saves aren't picked up by the file track system ; [X] findstr format not quite working +; [X] over left-shifting the view? ; ; [] indication on failure to save ; [] history is broken, revist the entire system @@ -86,7 +87,6 @@ ; [] view fails to follow cursor when the view is shrunk ; [] view fails to follow cursor after deleting long line ; -; [] over left-shifting the view? ; ; BEFORE I SHIP @@ -190,8 +190,8 @@ ; [X] get the navigation working correctly around multi-glyph characters ; [] provide full cursor positioning in buffers ; [] provide cursor positioning system that does columns correctly -; [] binary buffer mode ; [] unicode buffer mode +; [] binary buffer mode ; [] support full length unicode file names ; [] user file bar string @@ -224,20 +224,17 @@ ; meta programming system ; [X] condense system into single meta compiler +; [X] formalize the documentation writer so the TOC can be better and so it's easier to shoot off other docs ; [] formalize the rewriter for the 4coder_string.h so it can be used for other single header libs -; [] formalize the documentation writer so the TOC can be better and so it's easier to shoot off other docs ; [] profile and optimize the current metagen system ; [] expand the use of 4coder_types.h to also allow static variable and function declarations ; [] get more of the helper functions going through the documentation system -; [] method of pulling the documentation line from another item rather than copy-pasting the text. +; [] method of virtually pulling the documentation line from another item rather than copy-pasting the text. ; ; GUI related tech -; [X] consolidate all GUI code properly -; [X] rewrite GUI -; [X] arrow navigation of GUIs -; [] scroll bar position and size options -; [] GUI API +; [] scroll bar options +; [] buffer driven GUI experiment ; ; search related tech @@ -251,16 +248,11 @@ ; ; theme related business -; [] fix the versioning system for themes -; [] theme switch per panel? -; [] allow multiple font faces with effects -; ; control schemes ; [] emacs style sub-maps -; [] vim style modes +; [] vim keys ; [] sublime style editing -; [] "tap typing" ; [] command meta data ; [] macros ; @@ -281,7 +273,7 @@ ; [] fancy code presentation mode ; -; [] switch based word complete +; [] switch-case-enum based word complete ; [] keep copy of unedited orignal maybe? (compressed? restore by history?) ; ; [] diff @@ -291,7 +283,6 @@ ; [] polish for hot directories ; ; [] tutorials -; [] 4edT thing ; [] console emulator ; ; [] 10 GB text file @@ -303,6 +294,7 @@ ; [X] change job canceling to a polling based thing ; [] hashed string pool for clipboard/filenames/etc ; [] new profiling/debugging system +; [] new testing system ; ; EASY TODOS @@ -354,10 +346,10 @@ ; [] file drag and drop ; [] allow for multiple clipboards ; [] OS X port -; [] 4coder code compiling -; [] opengl window up -; [] basic versions of system functions -; [] get 4coder to render to window +; [X] 4coder code compiling +; [X] opengl window up +; [X] basic versions of system functions +; [X] get 4coder to render to window ; [] keyboard and mouse input ; [] file exchange ; [] clipboard diff --git a/build.cpp b/build.cpp index ff5fde4a..6ae7d8ae 100644 --- a/build.cpp +++ b/build.cpp @@ -115,11 +115,17 @@ typedef union _LARGE_INTEGER { # define WINAPI #endif -extern "C" DWORD WINAPI GetCurrentDirectoryA(_In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer); -extern "C" BOOL WINAPI QueryPerformanceCounter(_Out_ LARGE_INTEGER *lpPerformanceCount); -extern "C" BOOL WINAPI QueryPerformanceFrequency(_Out_ LARGE_INTEGER *lpFrequency); -extern "C" BOOL WINAPI CreateDirectoryA(_In_ LPCTSTR lpPathName, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes); -extern "C" BOOL WINAPI CopyFileA(_In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists); +extern "C"{ +DWORD WINAPI GetCurrentDirectoryA(_In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer); + + BOOL WINAPI QueryPerformanceCounter(_Out_ LARGE_INTEGER *lpPerformanceCount); + + BOOL WINAPI QueryPerformanceFrequency(_Out_ LARGE_INTEGER *lpFrequency); + + BOOL WINAPI CreateDirectoryA(_In_ LPCTSTR lpPathName, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes); + + BOOL WINAPI CopyFileA(_In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists); +} static uint64_t perf_frequency; @@ -157,12 +163,14 @@ get_current_directory(char *buffer, int32_t max){ static void execute(char *dir, char *str, char *args){ if (dir){ + Temp_Dir temp = pushdir(dir); if (args){ - systemf("pushd %s & call \"%s\" %s", dir, str, args); + systemf("call \"%s\" %s", str, args); } else{ - systemf("pushd %s & call \"%s\"", dir, str); + systemf("call \"%s\"", str); } + popdir(temp); } else{ if (args){ @@ -266,7 +274,10 @@ zip(char *parent, char *folder, char *dest){ slash_fix(parent); slash_fix(dest); - systemf("pushd %s & %s\\zip %s\\4tech_gobble.zip", parent, cdir, cdir); + Temp_Dir temp = pushdir(parent); + systemf("%s\\zip %s\\4tech_gobble.zip", cdir, cdir); + popdir(temp); + systemf("copy %s\\4tech_gobble.zip %s & del %s\\4tech_gobble.zip", cdir, dest, cdir); } @@ -281,7 +292,7 @@ pushdir(char *dir){ char *result = getcwd(temp.dir, sizeof(temp.dir)); int32_t chresult = chdir(dir); if (result == 0 || chresult != 0){ - printf("trying pushd %s\n", dir); + printf("trying pushdir %s\n", dir); assert(result != 0); assert(chresult == 0); } @@ -512,23 +523,21 @@ init_build_line(Build_Line *line){ "/wd4127 /wd4510 /wd4512 /wd4610 /wd4390 /WX " \ "/GR- /EHa- /nologo /FC" -#define CL_INCLUDES \ -"/I..\\foreign /I..\\foreign\\freetype2" +#define CL_INCLUDES "/I..\\foreign /I..\\foreign\\freetype2" -#define CL_SITE_INCLUDES \ -"/I..\\..\\code" +#define CL_SITE_INCLUDES "/I..\\..\\code" #define CL_LIBS \ "user32.lib winmm.lib gdi32.lib opengl32.lib " \ "..\\foreign\\freetype.lib" -#define CL_ICON \ -"..\\res\\icon.res" +#define CL_ICON "..\\res\\icon.res" static void build_cl(uint32_t flags, char *code_path, char *code_file, char *out_path, char *out_file, char *exports){ slash_fix(out_path); slash_fix(code_path); + slash_fix(code_file); Build_Line line; init_build_line(&line); @@ -588,7 +597,9 @@ build_cl(uint32_t flags, char *code_path, char *code_file, char *out_path, char snprintf(link_options, sizeof(link_options), "/NODEFAULTLIB:library"); } - systemf("pushd %s & cl %s %s\\%s /Fe%s /link /DEBUG /INCREMENTAL:NO %s", out_path, line.build_options, code_path, code_file, out_file, link_options); + Temp_Dir temp = pushdir(out_path); + systemf("cl %s %s\\%s /Fe%s /link /DEBUG /INCREMENTAL:NO %s", line.build_options, code_path, code_file, out_file, link_options); + popdir(temp); } @@ -596,11 +607,9 @@ build_cl(uint32_t flags, char *code_path, char *code_file, char *out_path, char "-Wno-write-strings -D_GNU_SOURCE -fPIC " \ "-fno-threadsafe-statics -pthread" -#define GCC_INCLUDES \ -"-I../foreign -I../code" +#define GCC_INCLUDES "-I../foreign -I../code" -#define GCC_SITE_INCLUDES \ -"-I../../code" +#define GCC_SITE_INCLUDES "-I../../code" #define GCC_LIBS \ "-L/usr/local/lib -lX11 -lpthread -lm -lrt " \ @@ -686,34 +695,32 @@ build(uint32_t flags, char *code_path, char *code_file, char *out_path, char *ou static void buildsuper(char *code_path, char *out_path, char *filename){ + Temp_Dir temp = pushdir(out_path); + #if defined(IS_CL) slash_fix(filename); slash_fix(out_path); slash_fix(code_path); - systemf("pushd %s & call \"%s\\buildsuper.bat\" %s", - out_path, code_path, filename); + systemf("call \"%s\\buildsuper.bat\" %s", code_path, filename); #elif defined(IS_GCC) - Temp_Dir temp = pushdir(out_path); - - systemf("\"%s/buildsuper.sh\" %s", - code_path, filename); - - popdir(temp); + systemf("\"%s/buildsuper.sh\" %s", code_path, filename); #else #error The build rule for this compiler is not ready #endif + + popdir(temp); } #define D_META_DIR "../meta" #define D_META_FSM_DIR "../meta/fsmgen" #define D_META_GEN_DIR "../meta/metagen" #define D_BUILD_DIR "../build" -#define D_BUILD_SITE_DIR "../../build/site" -#define D_SITE_GEN_DIR "../../build/site/sitegen" +#define D_BUILD_SITE_DIR "../build/site" +#define D_SITE_GEN_DIR "../build/site/sitegen" #define D_SITE_DIR "../site" #define D_PACK_DIR "../distributions" @@ -916,7 +923,7 @@ static void site_build(char *cdir, uint32_t flags){ { BEGIN_TIME_SECTION(); - build(OPTS | SITE_INCLUDES | flags, cdir, "sitegen.cpp", BUILD_SITE_DIR, "sitegen", 0); + build(OPTS | SITE_INCLUDES | flags, cdir, "site/sitegen.cpp", BUILD_SITE_DIR, "sitegen", 0); END_TIME_SECTION("build sitegen"); } @@ -924,9 +931,9 @@ site_build(char *cdir, uint32_t flags){ BEGIN_TIME_SECTION(); #if defined(IS_WINDOWS) - systemf("..\\..\\build\\site\\sitegen .. source_material ..\\..\\site"); + systemf("..\\build\\site\\sitegen . site\\source_material ..\\site"); #else - systemf("../../build/site/sitegen .. source_material ../../site"); + systemf("../build/site/sitegen . site/source_material ../site"); #endif END_TIME_SECTION("run sitegen"); diff --git a/site/abstract_document.cpp b/site/abstract_document.cpp index 064c029d..f6855f37 100644 --- a/site/abstract_document.cpp +++ b/site/abstract_document.cpp @@ -47,14 +47,14 @@ enum{ Doc_Table_Of_Contents }; -typedef struct Alternate_Name{ +struct Alternate_Name{ String macro; String public_name; -} Alternate_Name; +}; -typedef struct Alternate_Names_Array{ +struct Alternate_Names_Array{ Alternate_Name *names; -} Alternate_Names_Array; +}; enum{ AltName_Standard, @@ -99,6 +99,74 @@ struct Abstract_Document{ }; static Abstract_Document null_abstract_document = {0}; +struct Document_Node{ + Abstract_Document doc; + Document_Node *next; +}; + +struct Document_System{ + Document_Node *head; + Document_Node *tail; + + Partition *part; +}; + +static Document_System +create_document_system(Partition *part){ + Document_System system = {0}; + system.part = part; + return(system); +} + +static Abstract_Document* +create_document(Document_System *system, char *name){ + int32_t is_new_name = 1; + + for (Document_Node *node = system->head; + node != 0; + node = node->next){ + if (match_cc(node->doc.name, name)){ + is_new_name = 0; + } + } + + Abstract_Document *result = 0; + if (is_new_name){ + Document_Node *node = push_struct(system->part, Document_Node); + memset(node, 0, sizeof(*node)); + assert(node != 0); + + result = &node->doc; + node->next = 0; + if (system->head == 0){ + system->head = node; + system->tail = node; + } + else{ + system->tail->next = node; + system->tail = node; + } + } + + return(result); +} + +static Abstract_Document* +get_document_by_name(Document_System *system, String name){ + Abstract_Document *result = 0; + + for (Document_Node *node = system->head; + node != 0; + node = node->next){ + if (match_cs(node->doc.name, name)){ + result = &node->doc; + break; + } + } + + return(result); +} + static void set_section_name(Partition *part, Document_Item *item, char *name){ int32_t name_len = str_size(name); @@ -133,6 +201,16 @@ set_document_name(Abstract_Document *doc, char *name){ doc->name = name; } +static Abstract_Document* +begin_document_description(Document_System *system, char *title, char *name){ + Abstract_Document *doc = create_document(system, name); + if (doc){ + begin_document_description(doc, system->part, title); + } + set_document_name(doc, name); + return(doc); +} + static void end_document_description(Abstract_Document *doc){ Assert(doc->section_top == 0); @@ -257,7 +335,7 @@ add_enriched_text(Abstract_Document *doc, Enriched_Text *text){ append_child(parent, item); } -// Document Generation +// HTML Document Generation #define HTML_BACK_COLOR "#FAFAFA" #define HTML_TEXT_COLOR "#0D0D0D" @@ -301,6 +379,15 @@ struct Section_Counter{ int32_t nest_level; }; +static int32_t +doc_get_link_string(Abstract_Document *doc, char *space, int32_t capacity){ + String str = make_string_cap(space, 0, capacity); + append_sc(&str, doc->name); + append_sc(&str, ".html"); + int32_t result = terminate_with_null(&str); + return(result); +} + static void append_section_number_reduced(String *out, Section_Counter *section_counter, int32_t reduce){ int32_t level = section_counter->nest_level-reduce; @@ -398,11 +485,13 @@ html_render_section_header(String *out, String section_name, String section_id, } static void -write_enriched_text_html(String *out, Enriched_Text *text, Section_Counter *section_counter){ +write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){ String source = text->source; append_sc(out, "
"); + int32_t item_counter = 0; + for (String line = get_first_double_line(source); line.str; line = get_next_double_line(source, line)){ @@ -498,7 +587,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Section_Counter *sect case Cmd_BeginList: { - append_sc(out, "