From 987eeb06ec4c338d2a37c1609296d61b9a70596d Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 8 Dec 2016 12:16:50 -0500 Subject: [PATCH] progress on the site baking system; stream lined build.bat --- 4coder_default_include.cpp | 206 +++++++++++++------------- 4coder_mem.h | 37 ++++- TODO.txt | 17 +-- build.cpp | 27 +++- buildsuper.bat | 4 +- power/4coder_experiments.cpp | 2 +- site/4ed_site.ctm | Bin 5316 -> 6996 bytes site/abstract_document.cpp | 171 ++++++++++++++++----- site/out_context.cpp | 15 +- site/sitegen.cpp | 111 ++++++++++++-- site/source_material/feature_list.txt | 5 +- site/source_material/home.txt | 14 +- site/source_material/roadmap.txt | 26 +++- site/source_material/tutorials.txt | 12 ++ 14 files changed, 453 insertions(+), 194 deletions(-) create mode 100644 site/source_material/tutorials.txt diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 6f7376c7..54632ec4 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -404,7 +404,7 @@ buffer_seek_delimiter_forward(Application_Links *app, Buffer_Summary *buffer, static void buffer_seek_delimiter_backward(Application_Links *app, Buffer_Summary *buffer, - int32_t pos, char delim, int32_t *result){ + int32_t pos, char delim, int32_t *result){ if (buffer->exists){ char chunk[1024]; int32_t size = sizeof(chunk); @@ -1404,7 +1404,7 @@ buffer_seek_whitespace_up(Application_Links *app, Buffer_Summary *buffer, int32_ ++pos; } } - + return(pos); } @@ -1479,8 +1479,8 @@ CUSTOM_COMMAND_SIG(seek_whitespace_up){ int32_t new_pos = buffer_seek_whitespace_up(app, &buffer, view.cursor.pos); view_set_cursor(app, &view, - seek_pos(new_pos), - true); + seek_pos(new_pos), + true); } CUSTOM_COMMAND_SIG(seek_whitespace_down){ @@ -1490,8 +1490,8 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down){ int32_t new_pos = buffer_seek_whitespace_down(app, &buffer, view.cursor.pos); view_set_cursor(app, &view, - seek_pos(new_pos), - true); + seek_pos(new_pos), + true); } CUSTOM_COMMAND_SIG(seek_end_of_textual_line){ @@ -2053,18 +2053,18 @@ CUSTOM_COMMAND_SIG(if0_off){ edits[1].end = range.max; buffer_batch_edit(app,&buffer, - base, global_part.pos, - edits, ArrayCount(edits), BatchEdit_Normal); + base, global_part.pos, + edits, ArrayCount(edits), BatchEdit_Normal); view = get_view(app, view.view_id, AccessAll); if (view.cursor.pos > view.mark.pos){ view_set_cursor(app, &view, - seek_line_char(view.cursor.line+1, view.cursor.character), - true); + seek_line_char(view.cursor.line+1, view.cursor.character), + true); } else{ view_set_mark(app, &view, - seek_line_char(view.mark.line+1, view.mark.character)); + seek_line_char(view.mark.line+1, view.mark.character)); } range = get_range(&view); @@ -2623,10 +2623,10 @@ CUSTOM_COMMAND_SIG(execute_any_cli){ View_Summary view = get_active_view(app, access); exec_system_command(app, &view, - buffer_identifier(bar_out.string.str, bar_out.string.size), - hot_directory.str, hot_directory.size, - bar_cmd.string.str, bar_cmd.string.size, - CLI_OverlapWithConflict | CLI_CursorAtEnd); + buffer_identifier(bar_out.string.str, bar_out.string.size), + hot_directory.str, hot_directory.size, + bar_cmd.string.str, bar_cmd.string.size, + CLI_OverlapWithConflict | CLI_CursorAtEnd); } CUSTOM_COMMAND_SIG(execute_previous_cli){ @@ -2639,10 +2639,10 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){ View_Summary view = get_active_view(app, access); exec_system_command(app, &view, - buffer_identifier(out_buffer.str, out_buffer.size), - hot_directory.str, hot_directory.size, - cmd.str, cmd.size, - CLI_OverlapWithConflict | CLI_CursorAtEnd); + buffer_identifier(out_buffer.str, out_buffer.size), + hot_directory.str, hot_directory.size, + cmd.str, cmd.size, + CLI_OverlapWithConflict | CLI_CursorAtEnd); } } @@ -2665,7 +2665,7 @@ CUSTOM_COMMAND_SIG(increase_line_wrap){ Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessProtected); int32_t wrap = 0; - buffer_get_setting(app, &buffer, BufferSetting_WrapPosition, &wrap); + buffer_get_setting(app, &buffer, BufferSetting_WrapPosition, &wrap); buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, wrap + 10); } @@ -2984,7 +2984,7 @@ CUSTOM_COMMAND_SIG(word_complete){ complete_state.initialized = true; search_iter_init(&global_general, &complete_state.iter, size); buffer_read_range(app, &buffer, word_start, word_end, - complete_state.iter.word.str); + complete_state.iter.word.str); complete_state.iter.word.size = size; // NOTE(allen): Initialize the set of ranges to be searched. @@ -3045,15 +3045,15 @@ CUSTOM_COMMAND_SIG(word_complete){ char *spare = push_array(&global_part, char, match_size); buffer_read_range(app, &match.buffer, - match.start, match.end, spare); + match.start, match.end, spare); if (search_hit_add(&global_general, &complete_state.hits, &complete_state.str, spare, match_size)){ buffer_replace_range(app, &buffer, word_start, word_end, - spare, match_size); + spare, match_size); view_set_cursor(app, &view, - seek_pos(word_start + match_size), - true); + seek_pos(word_start + match_size), + true); complete_state.word_end = word_start + match_size; complete_state.set.ranges[0].mid_size = match_size; @@ -3075,10 +3075,10 @@ CUSTOM_COMMAND_SIG(word_complete){ match_size = complete_state.iter.word.size; char *str = complete_state.iter.word.str; buffer_replace_range(app, &buffer, word_start, word_end, - str, match_size); + str, match_size); view_set_cursor(app, &view, - seek_pos(word_start + match_size), - true); + seek_pos(word_start + match_size), + true); complete_state.word_end = word_start + match_size; complete_state.set.ranges[0].mid_size = match_size; @@ -3124,7 +3124,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_ if (!result){ int32_t len = directory_get_hot(app, dir_out->str, - dir_out->memory_size - dir_out->size); + dir_out->memory_size - dir_out->size); if (len + dir_out->size < dir_out->memory_size){ dir_out->size += len; result = BuildDir_AtHot; @@ -3165,10 +3165,10 @@ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary exec_system_command(app, view, - buffer_identifier(literal("*compilation*")), - dir->str, dir->size, - command->str, command->size, - CLI_OverlapWithConflict); + buffer_identifier(literal("*compilation*")), + dir->str, dir->size, + command->str, command->size, + CLI_OverlapWithConflict); result = true; break; } @@ -3182,10 +3182,10 @@ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary append_ss(&backup_command, make_lit_string("echo could not find ")); append_ss(&backup_command, filename); exec_system_command(app, view, - buffer_identifier(literal("*compilation*")), - dir->str, dir->size, - backup_command.str, backup_command.size, - CLI_OverlapWithConflict); + buffer_identifier(literal("*compilation*")), + dir->str, dir->size, + backup_command.str, backup_command.size, + CLI_OverlapWithConflict); } break; } @@ -3445,14 +3445,14 @@ SCROLL_RULE_SIG(smooth_scroll_rule){ velocity->x = 1.f; velocity->y = 1.f; } - + if (smooth_camera_step(target_y, scroll_y, &velocity->y, 80.f, 1.f/2.f)){ result = 1; } if (smooth_camera_step(target_x, scroll_x, &velocity->x, 80.f, 1.f/2.f)){ result = 1; } - + return(result); } @@ -3495,88 +3495,88 @@ process_config_file(Application_Links *app){ fseek(file, 0, SEEK_SET); int32_t check_size = (int32_t)fread(mem, 1, size, file); if (check_size == size){ - mem[size] = 0; - fclose(file); - - Cpp_Token_Array array; - array.count = 0; - array.max_count = (1 << 20)/sizeof(Cpp_Token); - array.tokens = push_array(&global_part, Cpp_Token, array.max_count); - - Cpp_Lex_Data S = cpp_lex_data_init(); - Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT); - - if (result == LexResult_Finished){ + mem[size] = 0; + fclose(file); - for (int32_t i = 0; i < array.count; ++i){ - int32_t read_setting_failed = 1; - Cpp_Token id_token = array.tokens[i]; - if (id_token.type == CPP_TOKEN_IDENTIFIER){ - ++i; - if (i < array.count){ - Cpp_Token eq_token = array.tokens[i]; - if (eq_token.type == CPP_TOKEN_EQ){ - ++i; - if (i < array.count){ - Cpp_Token val_token = array.tokens[i]; - { - ++i; - if (i < array.count){ - Cpp_Token semicolon_token = array.tokens[i]; - if (semicolon_token.type == CPP_TOKEN_SEMICOLON){ - read_setting_failed = 0; - - String id = make_string(mem + id_token.start, id_token.size); - - if (match(id, "enable_code_wrapping")){ - if (val_token.type == CPP_TOKEN_BOOLEAN_CONSTANT){ - String val = make_string(mem + val_token.start, val_token.size); - if (val.str[0] == 't'){ - enable_code_wrapping = 1; - } - else{ - enable_code_wrapping = 0; + Cpp_Token_Array array; + array.count = 0; + array.max_count = (1 << 20)/sizeof(Cpp_Token); + array.tokens = push_array(&global_part, Cpp_Token, array.max_count); + + Cpp_Lex_Data S = cpp_lex_data_init(); + Cpp_Lex_Result result = cpp_lex_step(&S, mem, size+1, HAS_NULL_TERM, &array, NO_OUT_LIMIT); + + if (result == LexResult_Finished){ + + for (int32_t i = 0; i < array.count; ++i){ + int32_t read_setting_failed = 1; + Cpp_Token id_token = array.tokens[i]; + if (id_token.type == CPP_TOKEN_IDENTIFIER){ + ++i; + if (i < array.count){ + Cpp_Token eq_token = array.tokens[i]; + if (eq_token.type == CPP_TOKEN_EQ){ + ++i; + if (i < array.count){ + Cpp_Token val_token = array.tokens[i]; + { + ++i; + if (i < array.count){ + Cpp_Token semicolon_token = array.tokens[i]; + if (semicolon_token.type == CPP_TOKEN_SEMICOLON){ + read_setting_failed = 0; + + String id = make_string(mem + id_token.start, id_token.size); + + if (match(id, "enable_code_wrapping")){ + if (val_token.type == CPP_TOKEN_BOOLEAN_CONSTANT){ + String val = make_string(mem + val_token.start, val_token.size); + if (val.str[0] == 't'){ + enable_code_wrapping = 1; + } + else{ + enable_code_wrapping = 0; + } } } - } - else if (match(id, "default_wrap_width")){ - if (val_token.type == CPP_TOKEN_INTEGER_CONSTANT){ - String val = make_string(mem + val_token.start, val_token.size); - default_wrap_width = str_to_int(val); + else if (match(id, "default_wrap_width")){ + if (val_token.type == CPP_TOKEN_INTEGER_CONSTANT){ + String val = make_string(mem + val_token.start, val_token.size); + default_wrap_width = str_to_int(val); + } } - } - else if (match(id, "default_min_base_width")){ - if (val_token.type == CPP_TOKEN_INTEGER_CONSTANT){ - String val = make_string(mem + val_token.start, val_token.size); - default_min_base_width = str_to_int(val); + else if (match(id, "default_min_base_width")){ + if (val_token.type == CPP_TOKEN_INTEGER_CONSTANT){ + String val = make_string(mem + val_token.start, val_token.size); + default_min_base_width = str_to_int(val); + } } + } - } } } } } } - } - - if (read_setting_failed){ - for (; i < array.count; ++i){ - Cpp_Token token = array.tokens[i]; - if (token.type == CPP_TOKEN_SEMICOLON){ - break; + + if (read_setting_failed){ + for (; i < array.count; ++i){ + Cpp_Token token = array.tokens[i]; + if (token.type == CPP_TOKEN_SEMICOLON){ + break; + } } } } } + + end_temp_memory(temp); + } + else{ + print_message(app, literal("Did not find config.4coder, using default settings")); } - - end_temp_memory(temp); } - else{ - print_message(app, literal("Did not find config.4coder, using default settings")); - } -} } #endif diff --git a/4coder_mem.h b/4coder_mem.h index e960893c..95e000c5 100644 --- a/4coder_mem.h +++ b/4coder_mem.h @@ -8,7 +8,8 @@ struct Partition{ char *base; - int32_t pos, max; + int32_t pos; + int32_t max; }; struct Temp_Memory{ @@ -16,6 +17,12 @@ struct Temp_Memory{ int32_t pos; }; +struct Tail_Temp_Partition{ + Partition part; + void *handle; + int32_t old_max; +}; + inline Partition make_part(void *memory, int32_t size){ Partition partition; @@ -43,12 +50,12 @@ partition_align(Partition *data, uint32_t boundary){ inline void* partition_current(Partition *data){ - return data->base + data->pos; + return(data->base + data->pos); } inline int32_t partition_remaining(Partition *data){ - return data->max - data->pos; + return(data->max - data->pos); } inline Partition @@ -58,7 +65,7 @@ partition_sub_part(Partition *data, int32_t size){ if (d){ result = make_part(d, size); } - return result; + return(result); } #define push_struct(part, T) (T*)partition_allocate(part, sizeof(T)) @@ -70,7 +77,7 @@ begin_temp_memory(Partition *data){ Temp_Memory result; result.handle = data; result.pos = data->pos; - return result; + return(result); } inline void @@ -78,6 +85,26 @@ end_temp_memory(Temp_Memory temp){ ((Partition*)temp.handle)->pos = temp.pos; } +inline Tail_Temp_Partition +begin_tail_part(Partition *data, int32_t size){ + Tail_Temp_Partition result = {0}; + if (data->pos + size <= data->max){ + result.handle = data; + result.old_max = data->max; + data->max -= size; + result.part = make_part(data->base + data->max, size); + } + return(result); +} + +inline void +end_tail_part(Tail_Temp_Partition temp){ + if (temp.handle){ + Partition *part = (Partition*)temp.handle; + part->max = temp.old_max; + } +} + /* NOTE(allen): This is a very week general purpose allocator system. diff --git a/TODO.txt b/TODO.txt index 661dece7..cce8a508 100644 --- a/TODO.txt +++ b/TODO.txt @@ -91,10 +91,6 @@ ; BEFORE I SHIP ; -; [X] query buffer font info -; [X] issues with drive letters -; [X] ad hoc call for setting up/down keys for interactive screens -; [X] miblo's various number editors ; [] decent options for indentation rules for text & presentation ; @@ -145,6 +141,14 @@ ; [X] use strange theme ; [X] cuber's return to previous buffer idea ; [X] find matches for current identifier +; [X] query buffer font info +; [X] issues with drive letters +; [X] ad hoc call for setting up/down keys for interactive screens +; [X] miblo's various number editors +; [X] eliminate the need for the lexer state's spare array. +; [X] fix buffer render item capacity issue +; [X] tab to complete folder names in the new file dialogue +; [X] API docs have duplicate ids? ; Token related upgrades ; [X] tokens in the custom API @@ -154,10 +158,6 @@ ; [X] inserting lines at end of block comment ; [] switch to line classification system ; [] more built in options for auto indenting -; -; [X] eliminate the need for the lexer state's spare array. -; [X] fix buffer render item capacity issue -; [X] tab to complete folder names in the new file dialogue ; Arbitrary wrap positions ; [X] allow for arbitrary wrap positions independent of view width @@ -196,7 +196,6 @@ ; [] user file bar string ; [] option to not open *messages* every startup -; [] API docs have duplicate ids? ; [] API docs as text file ; [] read only files ; [] option to hide hidden files diff --git a/build.cpp b/build.cpp index 1ea16a21..8ab8bc66 100644 --- a/build.cpp +++ b/build.cpp @@ -116,7 +116,8 @@ typedef union _LARGE_INTEGER { #endif extern "C"{ -DWORD WINAPI GetCurrentDirectoryA(_In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer); + DWORD WINAPI GetCurrentDirectoryA(_In_ DWORD nBufferLength, _Out_ LPTSTR lpBuffer); + BOOL WINAPI SetCurrentDirectoryA(_In_ LPCTSTR lpPathName); BOOL WINAPI QueryPerformanceCounter(_Out_ LARGE_INTEGER *lpPerformanceCount); @@ -130,10 +131,17 @@ DWORD WINAPI GetCurrentDirectoryA(_In_ DWORD nBufferLength, _Out_ LPTSTR lpBuf static uint64_t perf_frequency; static Temp_Dir -pushdir(char *dir){} +pushdir(char *dir){ + Temp_Dir temp = {0}; + GetCurrentDirectoryA(sizeof(temp.dir), temp.dir); + SetCurrentDirectoryA(dir); + return(temp); +} static void -popdir(Temp_Dir temp){} +popdir(Temp_Dir temp){ + SetCurrentDirectoryA(temp.dir); +} static void init_time_system(){ @@ -922,9 +930,14 @@ standard_build(char *cdir, uint32_t flags){ static void site_build(char *cdir, uint32_t flags){ { - BEGIN_TIME_SECTION(); - build(OPTS | SITE_INCLUDES | flags, cdir, "site/sitegen.cpp", BUILD_SITE_DIR, "sitegen", 0); - END_TIME_SECTION("build sitegen"); + BEGIN_TIME_SECTION(); + // TODO(allen): Figure out how to do these strings the right way... fuck. +#if defined(IS_WINDOWS) + build(OPTS | SITE_INCLUDES | flags, cdir, "site\\sitegen.cpp", BUILD_SITE_DIR, "sitegen", 0); +#else + build(OPTS | SITE_INCLUDES | flags, cdir, "site/sitegen.cpp", BUILD_SITE_DIR, "sitegen", 0); +#endif + END_TIME_SECTION("build sitegen"); } { @@ -932,7 +945,7 @@ site_build(char *cdir, uint32_t flags){ #if defined(IS_WINDOWS) systemf("..\\build\\site\\sitegen . ..\\foreign\\site-resources site\\source_material ..\\site"); - #else +#else systemf("../build/site/sitegen . ../foreign/site-resources site/source_material ../site"); #endif diff --git a/buildsuper.bat b/buildsuper.bat index e8f4d306..b9945780 100644 --- a/buildsuper.bat +++ b/buildsuper.bat @@ -1,8 +1,6 @@ @echo off -REM this is not really working... it's slowing down the build time -REM IF NOT DEFINED clset (call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64) -REM SET clset=64 +IF NOT DEFINED LIB (call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64) SET SRC=%1 if "%SRC%" == "" SET SRC=4coder_default_bindings.cpp diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp index c429e47b..2a586d9d 100644 --- a/power/4coder_experiments.cpp +++ b/power/4coder_experiments.cpp @@ -305,7 +305,7 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){ finished:; if (found_result){ - view_set_cursor(app, &view, seek_pos(result), 0); + view_set_cursor(app, &view, seek_pos(result), 1); } } diff --git a/site/4ed_site.ctm b/site/4ed_site.ctm index 6993139f3310cd4f5a790106d1ee2c4d6d313505..cb30c61614a1b2ea30bd26b758cd6be94a1217fc 100644 GIT binary patch delta 1701 zcmYk+e@xV67y$4G&cpryX-zJbI~dAQcqSm^F)@nKsR08Kp@HIt2%^lLLr`P6?;&=A zIzr6INh{HUl=84-h=QOL=&&V)KPH6e$vS41VTOd^^LWqG?!Wi*KF{<1{(d`ye_3ej zoUT;eP2bV*POqCA0OY<5;5a(m^$q()9l(Zw`dk~^76_1Sofp%{-ik#Fhx*r?V*iEC zvvzD2e~fOsy3Ha^_6Mj=eRKP_oFAlaOW)Fa~6Ft|9*hes4-r7DS4oClJD7Y_vjFZ%MdirkTeEk#!;L-wnTs3zT zU_tGik^EEavKIhS0xm=c#XBdQR09m@sxCZWzm56B=E9Oc&~$7 z9U;>OX#?$+4@&;z{F%y20B2s=b5J_Ey#Y?TU-_I&1s+&nZL3s0WYdW>3?_`tNN`Tr zg-Pzs6%*o(=-ErMGG=0&>Ps=-$B<^9?~k7kE9IDVUguvH${n7Jeev)!ilIN+Q+c{BRW$^ywA*R$vD`qU$(7w8eCoj7`vE{CtSMFoj)( zu6;dJGnnLzd*h?*nfS+e8%_1Au&6H4FIJp^PWDxq#B`#kzYJeSR;VBWJN793D+$^3$NxjPd zuk?w>KsK~a$EWz@w7F4YdJ`kFEnC$JC(x0sk33P}fu<{=&#dc~qk@c0Fk#%- zk>;ai5295+JC2J}(U(IL`^Z#JCwT3L(Hjz{A5~^{%$US!{7$c+r-~%dj-JMEa@X+$ z^y8Qhk<-PrgInH%hsZPmefL>;Ya1j^CpaFgx+xAvd#(O(R7~U7W?C&#Gy80Oy-m$s> delta 7 Ocmca&c0_Z-5fK0nI|G0K diff --git a/site/abstract_document.cpp b/site/abstract_document.cpp index 738b5827..d6ee1883 100644 --- a/site/abstract_document.cpp +++ b/site/abstract_document.cpp @@ -91,10 +91,22 @@ static Document_Item null_document_item = {0}; enum{ ItemType_Document, ItemType_Image, + ItemType_GenericFile, // never below this ItemType_COUNT, }; +struct Basic_Node{ + Basic_Node *next; +}; + +#define NodeGetData(node, T) ((T*) ((node)+1)) + +struct Basic_List{ + Basic_Node *head; + Basic_Node *tail; +}; + struct Abstract_Item{ int32_t item_type; char *name; @@ -110,26 +122,21 @@ struct Abstract_Item{ // Image value members char *source_file; - char *out_file; + char *extension; float w_h_ratio; float h_w_ratio; + Basic_List img_instantiations; }; static Abstract_Item null_abstract_item = {0}; -struct Basic_Node{ - Basic_Node *next; -}; - -#define NodeGetData(node, T) ((T*) ((node)+1)) - -struct Basic_List{ - Basic_Node *head; - Basic_Node *tail; +struct Image_Instantiation{ + int32_t w, h; }; struct Document_System{ Basic_List doc_list; Basic_List img_list; + Basic_List file_list; Partition *part; }; @@ -195,20 +202,42 @@ get_item_by_name(Basic_List list, char *name){ return(result); } +static Image_Instantiation* +get_image_instantiation(Basic_List list, int32_t w, int32_t h){ + Image_Instantiation *result = 0; + + for (Basic_Node *node = list.head; + node != 0; + node = node->next){ + Image_Instantiation *instantiation = NodeGetData(node, Image_Instantiation); + if (instantiation->w == w && instantiation->h == h){ + result = instantiation; + break; + } + } + + return(result); +} + static Abstract_Item* create_item(Partition *part, Basic_List *list, char *name){ - int32_t is_new_name = 1; - Abstract_Item *lookup = get_item_by_name(*list, name); Abstract_Item *result = 0; - if (is_new_name){ + if (lookup == 0){ result = (Abstract_Item*)push_item_on_list(part, list, sizeof(Abstract_Item)); } return(result); } +static void +add_image_instantiation(Partition *part, Basic_List *list, int32_t w, int32_t h){ + Image_Instantiation *instantiation = (Image_Instantiation*)push_item_on_list(part, list, sizeof(Image_Instantiation)); + instantiation->w = w; + instantiation->h = h; +} + static void set_section_name(Partition *part, Document_Item *item, char *name, int32_t show_title){ int32_t name_len = str_size(name); @@ -241,26 +270,37 @@ begin_document_description(Abstract_Item *doc, Partition *part, char *title, int } static Abstract_Item* -add_image_description(Document_System *system, char *asset_directory, char *source_file, char *out_file, char *name){ +add_generic_file(Document_System *system, char *source_file, char *extension, char *name){ + Abstract_Item *item = create_item(system->part, &system->file_list, name); + if (item){ + item->item_type = ItemType_GenericFile; + item->extension = extension; + item->source_file = source_file; + item->name = name; + } + return(item); +} + +static Abstract_Item* +add_image_description(Document_System *system, char *source_file, char *extension, char *name){ Abstract_Item *item = create_item(system->part, &system->img_list, name); if (item){ item->item_type = ItemType_Image; + item->extension = extension; item->source_file = source_file; - item->out_file = out_file; item->name = name; - char str[256]; - String s = make_fixed_width_string(str); - append_sc(&s, asset_directory); - append_sc(&s, "/"); - append_sc(&s, source_file); - terminate_with_null(&s); - int32_t w = 0, h = 0, comp = 0; - int32_t stbi_r = stbi_info(str, &w, &h, &comp); - assert(stbi_r); + int32_t stbi_r = stbi_info(source_file, &w, &h, &comp); + if (!stbi_r){ + fprintf(stderr, "Did not find file %s\n", source_file); + item->w_h_ratio = 1.f; + item->h_w_ratio = 1.f; + } + else{ item->w_h_ratio = ((float)w/(float)h); item->h_w_ratio = ((float)h/(float)w); + } } return(item); } @@ -453,9 +493,17 @@ doc_get_link_string(Abstract_Item *doc, char *space, int32_t capacity){ } static int32_t -img_get_link_string(Abstract_Item *img, char *space, int32_t capacity){ +img_get_link_string(Abstract_Item *img, char *space, int32_t capacity, int32_t w, int32_t h){ String str = make_string_cap(space, 0, capacity); - append_sc(&str, img->out_file); + append_sc(&str, img->name); + + append_sc(&str, "_"); + append_int_to_str(&str, w); + append_sc(&str, "_"); + append_int_to_str(&str, h); + + append_sc(&str, "."); + append_sc(&str, img->extension); int32_t result = terminate_with_null(&str); return(result); } @@ -477,7 +525,7 @@ append_section_number(String *out, Section_Counter *section_counter){ } static int32_t -extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_start_out, int32_t *body_end_out, String command_name){ +extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_start_out, int32_t *body_end_out, String command_name, int32_t require_body){ int32_t result = 0; int32_t i = *i_in_out; @@ -507,6 +555,7 @@ extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_sta result = 1; } else{ + if (require_body){ #define STR_START "! Doc generator error: missing body for " #define STR_SLOW " !" append_sc(out, STR_START); @@ -515,6 +564,7 @@ extract_command_body(String *out, String l, int32_t *i_in_out, int32_t *body_sta #undef STR fprintf(stderr, "error: missing body for %.*s\n", command_name.size, command_name.str); + } } *i_in_out = i; @@ -559,7 +609,7 @@ html_render_section_header(String *out, String section_name, String section_id, #define HTML_WIDTH 800 static void -write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){ +write_enriched_text_html(String *out, Partition *part, Enriched_Text *text, Document_System *doc_system, Section_Counter *section_counter){ String source = text->source; append_sc(out, "
"); @@ -609,6 +659,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ Cmd_BeginLink, Cmd_EndLink, Cmd_Image, + Cmd_Video, // never below this Cmd_COUNT, }; @@ -629,6 +680,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ enriched_commands[Cmd_BeginLink] = make_lit_string("BEGIN_LINK"); enriched_commands[Cmd_EndLink] = make_lit_string("END_LINK"); enriched_commands[Cmd_Image] = make_lit_string("IMAGE"); + enriched_commands[Cmd_Video] = make_lit_string("VIDEO"); i = command_end; @@ -641,7 +693,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ case Cmd_BeginStyle: { int32_t body_start = 0, body_end = 0; - int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string); + int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 1); if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); @@ -660,7 +712,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ case Cmd_DocLink: { int32_t body_start = 0, body_end = 0; - int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string); + int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 1); if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); @@ -703,7 +755,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ { // TODO(allen): undo the duplication of this body extraction code. int32_t body_start = 0, body_end = 0; - int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string); + int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 1); if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); @@ -717,7 +769,7 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ case Cmd_BeginLink: { int32_t body_start = 0, body_end = 0; - int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string); + int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 1); if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); @@ -746,7 +798,6 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ append_ss(out, body_text); } append_sc(out, "'>"); - } }break; @@ -757,19 +808,32 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ case Cmd_Image: { + // TODO(allen): generalize this int32_t body_start = 0, body_end = 0; - int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string); + int32_t has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 1); + if (has_body){ String body_text = substr(l, body_start, body_end - body_start); body_text = skip_chop_whitespace(body_text); int32_t pixel_height = 10; - int32_t pixel_width = HTML_WIDTH / 4; + int32_t pixel_width = HTML_WIDTH; + + body_start = 0, body_end = 0; + has_body = extract_command_body(out, l, &i, &body_start, &body_end, command_string, 0); + if (has_body){ + String size_parameter = substr(l, body_start, body_end - body_start); + if (match_part_sc(size_parameter, "width:")){ + String width_string = substr_tail(size_parameter, sizeof("width:")-1); + if (str_is_int_s(width_string)){ + pixel_width = str_to_int_s(width_string); + } + } + } - Abstract_Item *img_lookup = 0; if (match_part_sc(body_text, "image:")){ String img_name = substr_tail(body_text, sizeof("image:")-1); - img_lookup = get_item_by_name(doc_system->img_list, img_name); + Abstract_Item *img_lookup = get_item_by_name(doc_system->img_list, img_name); if (img_lookup){ pixel_height = CEIL32(pixel_width*img_lookup->h_w_ratio); @@ -777,8 +841,9 @@ write_enriched_text_html(String *out, Enriched_Text *text, Document_System *doc_ append_sc(out, " "); + } + } + }break; } } else{ @@ -1428,6 +1520,7 @@ doc_item_head_html(String *out, Partition *part, Document_System *doc_system, Us append_sc(out, "" "" + "" ""); append_ss(out, item->section.name); @@ -1505,7 +1598,7 @@ doc_item_head_html(String *out, Partition *part, Document_System *doc_system, Us case Doc_Enriched_Text: { - write_enriched_text_html(out, item->text.text, doc_system, section_counter); + write_enriched_text_html(out, part, item->text.text, doc_system, section_counter); }break; case Doc_Element_List: diff --git a/site/out_context.cpp b/site/out_context.cpp index d0d25def..cb72b558 100644 --- a/site/out_context.cpp +++ b/site/out_context.cpp @@ -69,18 +69,11 @@ make_out_string(int32_t x){ } static void -do_file_copy(Partition *part, char *src_dir, char *src_file, char *dst_dir, char *dst_file){ - char src[256]; +do_file_copy(Partition *part, char *src_file, char *dst_dir, char *dst_file){ char dst[256]; String str = {0}; int32_t success = 0; - str = make_fixed_width_string(src); - append_sc(&str, src_dir); - append_sc(&str, "/"); - append_sc(&str, src_file); - terminate_with_null(&str); - str = make_fixed_width_string(dst); append_sc(&str, dst_dir); append_sc(&str, "/"); @@ -90,7 +83,7 @@ do_file_copy(Partition *part, char *src_dir, char *src_file, char *dst_dir, char Temp_Memory temp = begin_temp_memory(part); int32_t mem_size = partition_remaining(part); void *mem = push_block(part, mem_size); - FILE *in = fopen(src, "rb"); + FILE *in = fopen(src_file, "rb"); if (in){ fseek(in, 0, SEEK_END); int32_t file_size = ftell(in); @@ -111,7 +104,9 @@ do_file_copy(Partition *part, char *src_dir, char *src_file, char *dst_dir, char } end_temp_memory(temp); - assert(success); + if (!success){ + fprintf(stderr, "Could not copy from %s to %s\n", src_file, dst); + } } #endif diff --git a/site/sitegen.cpp b/site/sitegen.cpp index 076962ef..7007d0ba 100644 --- a/site/sitegen.cpp +++ b/site/sitegen.cpp @@ -11,6 +11,8 @@ #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" +#define STB_IMAGE_RESIZE_IMPLEMENTATION +#include "stb_image_resize.h" #include "4coder_version.h" #define FSTRING_IMPLEMENTATION @@ -125,9 +127,10 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){ static void do_html_output(Document_System *doc_system, Partition *part, char *dst_directory, Abstract_Item *doc){ // NOTE(allen): Output - Temp_Memory temp = begin_temp_memory(part); + int32_t out_size = 10 << 20; + Tail_Temp_Partition temp = begin_tail_part(part, out_size); - String out = str_alloc(part, 10 << 20); + String out = str_alloc(&temp.part, out_size); assert(out.str); Out_Context context = {0}; set_context_directory(&context, dst_directory); @@ -144,7 +147,7 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){ } } - end_temp_memory(temp); + end_tail_part(temp); } static Abstract_Item* @@ -319,6 +322,32 @@ assert_files_are_equal(char *directory, char *filename1, char *filename2){ return(doc); } + static Abstract_Item* + generate_tutorials(Document_System *doc_system, Partition *part, char *src_directory){ + Enriched_Text *roadmap = push_struct(part, Enriched_Text); + *roadmap = load_enriched_text(part, src_directory, "tutorials.txt"); + + Abstract_Item *doc = begin_document_description(doc_system, "4coder Tutorials", "tutorials", 0); + add_enriched_text(doc, roadmap); + end_document_description(doc); + + return(doc); + } + + static String + push_string(Partition *part, int32_t size){ + String str = {0}; + str.memory_size = size; + str.str = push_array(part, char, size); + partition_align(part, 4); + return(str); + } + + static void + do_image_resize(Partition *part, char *src_file, char *dst_dir, char *dst_file, int32_t w, int32_t h){ + do_file_copy(part, src_file, dst_dir, dst_file); + } + static void generate_site(char *code_directory, char *asset_directory, char *src_directory, char *dst_directory){ int32_t size = (512 << 20); @@ -327,22 +356,46 @@ generate_site(char *code_directory, char *asset_directory, char *src_directory, Partition part_ = make_part(mem, size); Partition *part = &part_; + String str; Document_System doc_system = create_document_system(part); - add_image_description(&doc_system, asset_directory, "4coder_green.png", "4coder_logo.png", "4coder_logo"); + + // TODO(allen): code compression here + str = push_string(part, 256); + append_sc(&str, asset_directory); + append_sc(&str, "/4coder_logo_low_green.png"); + terminate_with_null(&str); + add_image_description(&doc_system, str.str, "png", "4coder_logo"); + + str = push_string(part, 256); + append_sc(&str, asset_directory); + append_sc(&str, "/screen_1.png"); + terminate_with_null(&str); + add_image_description(&doc_system, str.str, "png", "screen_1"); + + str = push_string(part, 256); + append_sc(&str, asset_directory); + append_sc(&str, "/screen_2.png"); + terminate_with_null(&str); + add_image_description(&doc_system, str.str, "png", "screen_2"); + + str = push_string(part, 256); + append_sc(&str, asset_directory); + append_sc(&str, "/screen_3.png"); + terminate_with_null(&str); + add_image_description(&doc_system, str.str, "png", "screen_3"); + + str = push_string(part, 256); + append_sc(&str, asset_directory); + append_sc(&str, "/4coder_icon.ico"); + terminate_with_null(&str); + add_generic_file(&doc_system, str.str, "ico", "4coder_icon"); generate_homepage(&doc_system, part, src_directory); generate_4coder_docs(&doc_system, part, code_directory, src_directory); generate_feature_list(&doc_system, part, src_directory); generate_roadmap(&doc_system, part, src_directory); - - for (Basic_Node *node = doc_system.img_list.head; - node != 0; - node = node->next){ - Abstract_Item *img = NodeGetData(node, Abstract_Item); - assert(img->item_type == ItemType_Image); - do_file_copy(part, asset_directory, img->source_file, dst_directory, img->out_file); - } + generate_tutorials(&doc_system, part, src_directory); for (Basic_Node *node = doc_system.doc_list.head; node != 0; @@ -351,6 +404,40 @@ generate_site(char *code_directory, char *asset_directory, char *src_directory, assert(doc->item_type == ItemType_Document); do_html_output(&doc_system, part, dst_directory, doc); } + + for (Basic_Node *node = doc_system.file_list.head; + node != 0; + node = node->next){ + Abstract_Item *file = NodeGetData(node, Abstract_Item); + assert(file->item_type == ItemType_GenericFile); + + char space[256]; + String str = make_fixed_width_string(space); + append_sc(&str, file->name); + append_sc(&str, "."); + append_sc(&str, file->extension); + terminate_with_null(&str); + + do_file_copy(part, file->source_file, dst_directory, space); + } + + for (Basic_Node *node = doc_system.img_list.head; + node != 0; + node = node->next){ + Abstract_Item *img = NodeGetData(node, Abstract_Item); + assert(img->item_type == ItemType_Image); + + for (Basic_Node *node = img->img_instantiations.head; + node != 0; + node = node->next){ + Image_Instantiation *inst = NodeGetData(node, Image_Instantiation); + + char space[256]; + if (img_get_link_string(img, space, sizeof(space), inst->w, inst->h)){ + do_image_resize(part, img->source_file, dst_directory, space, inst->w, inst->h); + } + } + } } int main(int argc, char **argv){ diff --git a/site/source_material/feature_list.txt b/site/source_material/feature_list.txt index 0de28e84..1e764cc6 100644 --- a/site/source_material/feature_list.txt +++ b/site/source_material/feature_list.txt @@ -1,5 +1,7 @@ -\IMAGE{image:4coder_logo} +\BEGIN_LINK{document:home} +\IMAGE{image:4coder_logo}{width:200} +\END_LINK This page provides a list of 4coder features for anyone trying to determine whether 4coder is the right editor for them. If a feature is missing here you should check out the \BEGIN_LINK{document:roadmap} roadmap \END_LINK page to see what is coming in the future. If the feature you want is on neither, you should contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE. Some features that are already in 4coder might be missing from this list, if you want to be sure you should contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE. @@ -29,7 +31,6 @@ This page provides a list of 4coder features for anyone trying to determine whet \BEGIN_ITEM Easy key rebinding \END_ITEM \BEGIN_ITEM Create custom commands \END_ITEM \BEGIN_ITEM Buffer reading and editing \END_ITEM - \BEGIN_ITEM Buffer reading and editing \END_ITEM \BEGIN_ITEM View opening, closing, positioning \END_ITEM \BEGIN_ITEM Access to the code intelligence engine \END_ITEM \END_LIST diff --git a/site/source_material/home.txt b/site/source_material/home.txt index 412bc86c..4efbc2f6 100644 --- a/site/source_material/home.txt +++ b/site/source_material/home.txt @@ -1,14 +1,24 @@ -\IMAGE{image:4coder_logo} +\BEGIN_LINK{document:home} +\IMAGE{image:4coder_logo}{width:200} +\END_LINK -4coder is a code editor that first and foremost targets the needs C/C++ developers so that developers in that space can be as efficient as possible. Here you can learn about the features of 4coder, how to get started with 4coder, and how to get the absolute most out of 4cocer. +4coder is a code editor that first and foremost targets the needs of C/C++ developers so they can be as efficient as possible. Here you can learn about the features of 4coder, how to get started with 4coder, and how to get the absolute most out of 4coder. If you cannot find what you are looking for please contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE with questions. +\BEGIN_LINK{!http://patreon.com/mr4thdimention} Get an alpha build by supporting development \END_LINK + \BEGIN_LINK{document:features} The official 4coder feature list \END_LINK \BEGIN_LINK{document:roadmap} The official 4coder road map \END_LINK \BEGIN_LINK{document:custom_docs} The official documentation for the 4coder customization system \END_LINK +\BEGIN_LINK{document:tutorials} Using 4coder tutorials \END_LINK +\IMAGE{image:screen_1} + +\IMAGE{image:screen_2} + +\IMAGE{image:screen_3} diff --git a/site/source_material/roadmap.txt b/site/source_material/roadmap.txt index fcec4150..c3deb705 100644 --- a/site/source_material/roadmap.txt +++ b/site/source_material/roadmap.txt @@ -1,5 +1,7 @@ -\IMAGE{image:4coder_logo} +\BEGIN_LINK{document:home} +\IMAGE{image:4coder_logo}{width:200} +\END_LINK This page provides an outline of planned 4coder features roughly sorted by priority. If a feature is missing here it may be on the \BEGIN_LINK{document:features} features \END_LINK page which means it is already in 4coder. If a feature is missing from both lists and you would like to recommend it for consideration, send your recommendation to \BEGIN_STYLE{code} editor@4coder.net \END_STYLE. If you believe the priority sorting of the items should be tweaked because certain items are more important than others, that recommendation can also be sent to the same 4coder email as any other recommendation. @@ -8,28 +10,50 @@ Each section represents one major type of todo item, within each section the ite \SECTION{General Editing} \BEGIN_LIST \BEGIN_ITEM Unicode buffer formats \END_ITEM + \BEGIN_ITEM Fix up the undo/redo system - improve efficiency and fix a few buggy details \END_ITEM + \BEGIN_ITEM Properply handle files with read-only access \END_ITEM + \BEGIN_ITEM Options for hiding or showing hidden files \END_ITEM + \BEGIN_ITEM Change font size \END_ITEM \END_LIST \SECTION{Code Layout} \BEGIN_LIST + \BEGIN_ITEM Reduce code "jumpieness" by adding brace/paren m atching rules and scoping rules \END_ITEM + \BEGIN_ITEM Regain the ability to parse in parallel with a smarter background job system \END_ITEM + \BEGIN_ITEM Add partial remeasurement systems to decrease the amount of CPU work put into layout \END_ITEM + \BEGIN_ITEM Expand code layout to also virtualize trailing whitespace and newline characters \END_ITEM + \BEGIN_ITEM Expand code layout to virtualize all whitespace \END_ITEM \END_LIST \SECTION{Buffer Driven GUI} \BEGIN_LIST + \BEGIN_ITEM Labels \END_ITEM + \BEGIN_ITEM Clickable buttons \END_ITEM + \BEGIN_ITEM Arbitrary non-editable regions \END_ITEM + \BEGIN_ITEM Tables \END_ITEM \END_LIST \SECTION{Code Intelligence} \BEGIN_LIST + \BEGIN_ITEM Create a usable "in stream" preprocessor \END_ITEM + \BEGIN_ITEM Create a usable "in stream" parser \END_ITEM + \BEGIN_ITEM Preprocessor effect visualization \END_ITEM \END_LIST \SECTION{API "Main" Upgrade} \BEGIN_LIST + \BEGIN_ITEM Expose undo/redo grouping so that edits can be treated as one undo/redo event \END_ITEM + \BEGIN_ITEM Improve the control over the view/cursor positioning \END_ITEM + \BEGIN_ITEM Generic control over rendering cursor, mark, and highlight regions \END_ITEM + \BEGIN_ITEM Move the concept of the cursor and mark entirely onto the custom side \END_ITEM + \BEGIN_ITEM Virtual text for ghosted word completion and in-line compiler errors \END_ITEM \END_LIST \SECTION{API Miscellanea} \BEGIN_LIST \BEGIN_ITEM Expose the file bar string \END_ITEM \BEGIN_ITEM Expose the binding of initial files to views such as *messages* \END_ITEM + \BEGIN_ITEM Make command maps modifiable and allow them to be created and discarded at any time \END_ITEM \END_LIST \SECTION{Cross OS Miscellanea} diff --git a/site/source_material/tutorials.txt b/site/source_material/tutorials.txt new file mode 100644 index 00000000..a6ce1ada --- /dev/null +++ b/site/source_material/tutorials.txt @@ -0,0 +1,12 @@ + +\BEGIN_LINK{document:home} +\IMAGE{image:4coder_logo}{width:200} +\END_LINK + +Getting started with 4coder and navigating your files: + +\VIDEO{youtube:https://www.youtube.com/embed/h5cbOcnSrcc} + +More tutorials coming soon. + +