new bug fixed version ready to go (4.0.13)

master
Allen Webster 2016-11-12 16:33:54 -05:00
parent 1b38d319dc
commit 3b4876022d
9 changed files with 338 additions and 634 deletions

View File

@ -237,6 +237,7 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
}
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width);
buffer_set_setting(app, &buffer, BufferSetting_MinimumBaseWrapPosition, default_min_base_width);
buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file));
if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 18)){

View File

@ -810,8 +810,11 @@ CUSTOM_COMMAND_SIG(left_adjust_view){
GUI_Scroll_Vars scroll = view.scroll_vars;
float x = get_view_x(view);
x = x - 30.f;
float x = get_view_x(view) - 30.f;
if (x < 0){
x = 0.f;
}
scroll.target_x = (int32_t)(x + .5f);
view_set_scroll(app, &view, scroll);
}
@ -3133,14 +3136,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
// TODO(allen): Better names for the "standard build search" family.
static int32_t
standard_build_search(Application_Links *app,
View_Summary *view,
Buffer_Summary *active_buffer,
String *dir, String *command,
int32_t perform_backup,
int32_t use_path_in_command,
String filename,
String commandname){
standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, int32_t perform_backup, int32_t use_path_in_command, String filename, String commandname){
int32_t result = false;
for(;;){
@ -3489,10 +3485,11 @@ COMMAND_CALLER_HOOK(default_command_caller){
return(0);
}
// NOTE(allen|a4.0.12): A primordial config system (actually really hate this but it seems best)
// NOTE(allen|a4.0.12): A primordial config system (actually really hate this but it seems best at least right now... arg)
static bool32 enable_code_wrapping = 1;
static int32_t default_wrap_width = 672;
static int32_t default_min_base_width = 550;
#include <stdio.h>
@ -3558,6 +3555,13 @@ process_config_file(Application_Links *app){
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);
}
}
}
}
}

View File

@ -1,6 +1,6 @@
#define MAJOR 4
#define MINOR 0
#define PATCH 12
#define PATCH 13
#define VN__(a,b,c) #a"."#b"."#c
#define VN_(a,b,c) VN__(a,b,c)

View File

@ -4,6 +4,8 @@ The implementation for the custom API
// TOP
#define API_EXPORT
inline b32
access_test(u32 lock_flags, u32 access_flags){
b32 result = 0;
@ -153,15 +155,12 @@ imp_get_view(Command_Data *cmd, View_Summary *view){
return(vptr);
}
#define API_EXPORT
API_EXPORT bool32
Exec_Command(Application_Links *app, Command_ID command_id)
/*
DOC_PARAM(command_id, The command_id parameter specifies which internal command to execute.)
DOC_RETURN(This call returns non-zero if command_id named a valid internal command.)
DOC(A call to exec_command executes an internal command.
If command_id is invalid a warning is posted to *messages*.)
DOC(A call to exec_command executes an internal command. If command_id is invalid a warning is posted to *messages*.)
DOC_SEE(Command_ID)
*/{
bool32 result = false;
@ -719,17 +718,20 @@ DOC_RETURN(returns non-zero on success)
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
int32_t result = 0;
if (file){
result = 1;
switch (setting){
case BufferSetting_Lex: result = file->settings.tokens_exist; break;
case BufferSetting_WrapLine: result = !file->settings.unwrapped_lines; break;
case BufferSetting_WrapPosition: result = file->settings.display_width; break;
case BufferSetting_MapID: result = file->settings.base_map_id; break;
case BufferSetting_Eol: result = file->settings.dos_write_mode; break;
case BufferSetting_Unimportant: result = file->settings.unimportant; break;
case BufferSetting_ReadOnly: result = file->settings.read_only; break;
case BufferSetting_VirtualWhitespace: result = file->settings.virtual_white; break;
case BufferSetting_Lex: *value_out = file->settings.tokens_exist; break;
case BufferSetting_WrapLine: *value_out = !file->settings.unwrapped_lines; break;
case BufferSetting_WrapPosition: *value_out = file->settings.display_width; break;
case BufferSetting_MinimumBaseWrapPosition: *value_out = file->settings.minimum_base_display_width; break;
case BufferSetting_MapID: *value_out = file->settings.base_map_id; break;
case BufferSetting_Eol: *value_out = file->settings.dos_write_mode; break;
case BufferSetting_Unimportant: *value_out = file->settings.unimportant; break;
case BufferSetting_ReadOnly: *value_out = file->settings.read_only; break;
case BufferSetting_VirtualWhitespace: *value_out = file->settings.virtual_white; break;
default: result = 0; break;
}
}
@ -1542,12 +1544,14 @@ DOC_RETURN(returns non-zero on success)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
int32_t result = -1;
int32_t result = 0;
if (vptr){
result = 1;
switch (setting){
case ViewSetting_ShowWhitespace: result = vptr->file_data.show_whitespace; break;
case ViewSetting_ShowScrollbar: result = !vptr->hide_scrollbar; break;
case ViewSetting_ShowWhitespace: *value_out = vptr->file_data.show_whitespace; break;
case ViewSetting_ShowScrollbar: *value_out = !vptr->hide_scrollbar; break;
default: result = 0; break;
}
}

View File

@ -284,8 +284,8 @@ view_file_display_width(View *view){
inline f32
view_file_minimum_base__width(View *view){
Editing_File *file = view->file_data.file;
f32 result = (f32)file->settings.display_width;
return(result);
f32 result = (f32)file->settings.display_width;
return(result);
}
inline f32
@ -1066,7 +1066,7 @@ wrap_state_consume_token(Code_Wrap_State *state, i32 fixed_end_point){
}
if (state->in_pp_body){
if (!(state->token_ptr->flags & CPP_TFLAG_PP_BODY)){
if (!(state->token_ptr->flags & CPP_TFLAG_PP_BODY)){
state->in_pp_body = 0;
state->wrap_x = state->plane_wrap_x;
}
@ -1252,7 +1252,7 @@ stickieness_guess(Cpp_Token_Type type, Cpp_Token_Type other_type, u16 flags, u16
}
else{
if (other_is_words){
guess = 100;
guess = 100;
}
}
}
@ -1365,49 +1365,49 @@ get_current_shift(Code_Wrap_State *wrap_state, i32 next_line_start, b32 *adjust_
if (wrap_state->wrap_x.paren_safe_top != 0 && prev_token.type == CPP_TOKEN_PARENTHESE_OPEN){
current_shift = wrap_state->wrap_x.paren_nesting[wrap_state->wrap_x.paren_safe_top-1] + wrap_state->tab_indent_amount;
*adjust_top_to_this = 1;
}
f32 statement_continuation_indent = 0.f;
if (current_shift != 0.f && wrap_state->wrap_x.paren_safe_top == 0){
if (!(prev_token.flags & CPP_TFLAG_PP_BODY) && !(prev_token.flags & CPP_TFLAG_PP_DIRECTIVE)){
switch (prev_token.type){
case CPP_TOKEN_BRACKET_OPEN:
case CPP_TOKEN_BRACE_OPEN:
case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_SEMICOLON:
case CPP_TOKEN_COLON:
case CPP_TOKEN_COMMA:
case CPP_TOKEN_COMMENT: break;
default: statement_continuation_indent += wrap_state->tab_indent_amount; break;
}
}
}
switch (wrap_state->token_ptr->type){
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACE_OPEN: break;
default: current_shift += statement_continuation_indent; break;
}
}
f32 statement_continuation_indent = 0.f;
if (current_shift != 0.f && wrap_state->wrap_x.paren_safe_top == 0){
if (!(prev_token.flags & CPP_TFLAG_PP_BODY) && !(prev_token.flags & CPP_TFLAG_PP_DIRECTIVE)){
switch (prev_token.type){
case CPP_TOKEN_BRACKET_OPEN:
case CPP_TOKEN_BRACE_OPEN:
case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_SEMICOLON:
case CPP_TOKEN_COLON:
case CPP_TOKEN_COMMA:
case CPP_TOKEN_COMMENT: break;
default: statement_continuation_indent += wrap_state->tab_indent_amount; break;
}
}
}
switch (wrap_state->token_ptr->type){
case CPP_TOKEN_BRACE_CLOSE: case CPP_TOKEN_BRACE_OPEN: break;
default: current_shift += statement_continuation_indent; break;
if (wrap_state->token_ptr->start < next_line_start){
if (wrap_state->token_ptr->flags & CPP_TFLAG_PP_DIRECTIVE){
current_shift = 0;
}
else{
switch (wrap_state->token_ptr->type){
case CPP_TOKEN_BRACE_CLOSE:
{
if (wrap_state->wrap_x.paren_safe_top == 0){
current_shift -= wrap_state->tab_indent_amount;
}
}
if (wrap_state->token_ptr->start < next_line_start){
if (wrap_state->token_ptr->flags & CPP_TFLAG_PP_DIRECTIVE){
current_shift = 0;
}
else{
switch (wrap_state->token_ptr->type){
case CPP_TOKEN_BRACE_CLOSE:
{
if (wrap_state->wrap_x.paren_safe_top == 0){
current_shift -= wrap_state->tab_indent_amount;
}
}break;
}
}
}
}break;
}
}
}
return(current_shift);
}
@ -1499,7 +1499,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
b32 still_looping = 0;
do{
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
u8 ch = stream.data[i];
switch (word_stage){
case 0:
@ -1549,13 +1549,16 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
if (use_tokens){
Code_Wrap_State original_wrap_state = wrap_state;
i32 next_line_start = params.buffer->line_starts[stop.line_index+1];
i32 next_line_start = buffer_size(params.buffer);
if (stop.line_index+1 < params.buffer->line_count){
next_line_start = params.buffer->line_starts[stop.line_index+1];
}
f32 base_adjusted_width = wrap_state.wrap_x.base_x + minimum_base_width;
if (minimum_base_width != 0 && current_width < base_adjusted_width){
current_width = base_adjusted_width;
}
current_width = base_adjusted_width;
}
if (stop.status == BLStatus_NeedLineShift){
real_count = 0;
@ -1580,7 +1583,8 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
b32 emit_comment_position = 0;
b32 first_word = 1;
if (wrap_state.token_ptr->type == CPP_TOKEN_COMMENT){
if (wrap_state.token_ptr->type == CPP_TOKEN_COMMENT ||
wrap_state.token_ptr->type == CPP_TOKEN_STRING_CONSTANT){
i32 i = wrap_state.token_ptr->start;
i32 end_i = i + wrap_state.token_ptr->size;
@ -1607,74 +1611,86 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
potential_wrap.wrap_x = x;
potential_wrap.adjust_top_to_this = 0;
if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){
b32 still_looping = 1;
do{
while (still_looping){
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
if (char_is_whitespace(ch)){
goto doublebreak_stage1;
}
f32 adv = params.adv[ch];
x += adv;
if (!first_word && x > current_width){
emit_comment_position = 1;
goto doublebreak_stage1;
if (buffer_stringify_loop(&stream, params.buffer, i, end_i)){
b32 still_looping = 1;
while(still_looping){
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
if (!char_is_whitespace(ch)){
goto doublebreak_stage_vspace;
}
}
still_looping = buffer_stringify_next(&stream);
}
doublebreak_stage1:;
first_word = 0;
if (emit_comment_position){
step.position_end = i;
step.final_x = x;
goto finished_comment_split;
}
while(still_looping){
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
if (!char_is_whitespace(ch)){
goto doublebreak_stage2;
}
still_looping = buffer_stringify_next(&stream);
}
doublebreak_stage_vspace:;
do{
while (still_looping){
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
if (char_is_whitespace(ch)){
goto doublebreak_stage1;
}
f32 adv = params.adv[ch];
x += adv;
if (!first_word && x > current_width){
emit_comment_position = 1;
goto doublebreak_stage1;
}
}
still_looping = buffer_stringify_next(&stream);
}
doublebreak_stage1:;
first_word = 0;
if (emit_comment_position){
step.position_end = i;
step.final_x = x;
goto finished_comment_split;
}
f32 adv = params.adv[ch];
x += adv;
while(still_looping){
for (; i < stream.end; ++i){
u8 ch = stream.data[i];
if (!char_is_whitespace(ch)){
goto doublebreak_stage2;
}
f32 adv = params.adv[ch];
x += adv;
}
still_looping = buffer_stringify_next(&stream);
}
doublebreak_stage2:;
potential_wrap.wrap_position = i;
potential_wrap.wrap_x = x;
}while(still_looping);
}
still_looping = buffer_stringify_next(&stream);
}
doublebreak_stage2:;
potential_wrap.wrap_position = i;
potential_wrap.wrap_x = x;
}while(still_looping);
}
finished_comment_split:;
if (emit_comment_position){
potential_marks[potential_count] = potential_wrap;
++potential_count;
}
}
finished_comment_split:;
if (emit_comment_position){
potential_marks[potential_count] = potential_wrap;
++potential_count;
}
}
if (!emit_comment_position){
step = wrap_state_consume_token(&wrap_state, next_line_start-1);
}
if (!emit_comment_position){
step = wrap_state_consume_token(&wrap_state, next_line_start-1);
}
b32 need_to_choose_a_wrap = 0;
if (step.final_x > current_width){
need_to_choose_a_wrap = 1;
}
adjust_top_to_this = 0;
current_shift = get_current_shift(&wrap_state, next_line_start, &adjust_top_to_this);
adjust_top_to_this = 0;
current_shift = get_current_shift(&wrap_state, next_line_start, &adjust_top_to_this);
b32 next_token_is_on_line = 0;
if (wrap_state.token_ptr->start < next_line_start){
@ -2146,78 +2162,78 @@ file_first_lex_serial(System_Functions *system, Mem_Options *mem, Editing_File *
Temp_Memory temp = begin_temp_memory(part);
Buffer_Type *buffer = &file->state.buffer;
i32 text_size = buffer_size(buffer);
i32 text_size = buffer_size(buffer);
i32 mem_size = partition_remaining(part);
Cpp_Token_Array tokens;
tokens.max_count = mem_size / sizeof(Cpp_Token);
tokens.count = 0;
tokens.tokens = push_array(part, Cpp_Token, tokens.max_count);
b32 still_lexing = 1;
Cpp_Lex_Data lex = cpp_lex_data_init();
// TODO(allen): deduplicate this against relex
char *chunks[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
chunks[1] = buffer->data + buffer->size1 + buffer->gap_size;
chunk_sizes[1] = buffer->size2;
chunks[2] = 0;
chunk_sizes[2] = 0;
i32 chunk_index = 0;
do{
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
i32 result = cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, NO_OUT_LIMIT);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
case LexResult_NeedTokenMemory: InvalidCodePath;
case LexResult_HitTokenLimit: InvalidCodePath;
case LexResult_Finished: still_lexing = 0; break;
}
} while (still_lexing);
i32 new_max = LargeRoundUp(tokens.count+1, Kbytes(1));
{
Assert(file->state.swap_array.tokens == 0);
file->state.swap_array.tokens = (Cpp_Token*) general_memory_allocate(system, general, new_max*sizeof(Cpp_Token));
}
u8 *dest = (u8*)file->state.swap_array.tokens;
u8 *src = (u8*)tokens.tokens;
memcpy(dest, src, tokens.count*sizeof(Cpp_Token));
{
Cpp_Token_Array *file_token_array = &file->state.token_array;
file_token_array->count = tokens.count;
file_token_array->max_count = new_max;
if (file_token_array->tokens){
general_memory_free(system, general, file_token_array->tokens);
}
file_token_array->tokens = file->state.swap_array.tokens;
file->state.swap_array.tokens = 0;
}
// NOTE(allen): These are outside the locked section because I don't
// think getting these out of order will cause critical bugs, and I
// want to minimize what's done in locked sections.
file->state.tokens_complete = 1;
file->state.still_lexing = 0;
end_temp_memory(temp);
b32 still_lexing = 1;
Cpp_Lex_Data lex = cpp_lex_data_init();
// TODO(allen): deduplicate this against relex
char *chunks[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
chunks[1] = buffer->data + buffer->size1 + buffer->gap_size;
chunk_sizes[1] = buffer->size2;
chunks[2] = 0;
chunk_sizes[2] = 0;
i32 chunk_index = 0;
do{
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
i32 result = cpp_lex_step(&lex, chunk, chunk_size, text_size, &tokens, NO_OUT_LIMIT);
switch (result){
case LexResult_NeedChunk: ++chunk_index; break;
case LexResult_NeedTokenMemory: InvalidCodePath;
case LexResult_HitTokenLimit: InvalidCodePath;
case LexResult_Finished: still_lexing = 0; break;
}
} while (still_lexing);
i32 new_max = LargeRoundUp(tokens.count+1, Kbytes(1));
{
Assert(file->state.swap_array.tokens == 0);
file->state.swap_array.tokens = (Cpp_Token*) general_memory_allocate(system, general, new_max*sizeof(Cpp_Token));
}
u8 *dest = (u8*)file->state.swap_array.tokens;
u8 *src = (u8*)tokens.tokens;
memcpy(dest, src, tokens.count*sizeof(Cpp_Token));
{
Cpp_Token_Array *file_token_array = &file->state.token_array;
file_token_array->count = tokens.count;
file_token_array->max_count = new_max;
if (file_token_array->tokens){
general_memory_free(system, general, file_token_array->tokens);
}
file_token_array->tokens = file->state.swap_array.tokens;
file->state.swap_array.tokens = 0;
}
// NOTE(allen): These are outside the locked section because I don't
// think getting these out of order will cause critical bugs, and I
// want to minimize what's done in locked sections.
file->state.tokens_complete = 1;
file->state.still_lexing = 0;
end_temp_memory(temp);
}
file->state.tokens_complete = 1;
@ -2363,69 +2379,69 @@ file_relex_serial(System_Functions *system, Mem_Options *mem, Editing_File *file
Assert(!file->state.still_lexing);
Buffer_Type *buffer = &file->state.buffer;
Cpp_Token_Array *array = &file->state.token_array;
Temp_Memory temp = begin_temp_memory(part);
Cpp_Token_Array relex_array;
relex_array.count = 0;
Buffer_Type *buffer = &file->state.buffer;
Cpp_Token_Array *array = &file->state.token_array;
Temp_Memory temp = begin_temp_memory(part);
Cpp_Token_Array relex_array;
relex_array.count = 0;
relex_array.max_count = partition_remaining(part) / sizeof(Cpp_Token);
relex_array.tokens = push_array(part, Cpp_Token, relex_array.max_count);
relex_array.tokens = push_array(part, Cpp_Token, relex_array.max_count);
i32 size = buffer_size(buffer);
Cpp_Relex_Data state = cpp_relex_init(array, start_i, end_i, shift_amount);
char *chunks[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
chunks[1] = buffer->data + buffer->size1 + buffer->gap_size;
chunk_sizes[1] = buffer->size2;
chunks[2] = 0;
chunk_sizes[2] = 0;
i32 chunk_index = 0;
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, chunk_size)){
++chunk_index;
chunk = chunks[chunk_index];
chunk_size = chunk_sizes[chunk_index];
}
for(;;){
Cpp_Lex_Result lex_result = cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
i32 size = buffer_size(buffer);
Cpp_Relex_Data state = cpp_relex_init(array, start_i, end_i, shift_amount);
char *chunks[3];
i32 chunk_sizes[3];
chunks[0] = buffer->data;
chunk_sizes[0] = buffer->size1;
chunks[1] = buffer->data + buffer->size1 + buffer->gap_size;
chunk_sizes[1] = buffer->size2;
chunks[2] = 0;
chunk_sizes[2] = 0;
i32 chunk_index = 0;
char *chunk = chunks[chunk_index];
i32 chunk_size = chunk_sizes[chunk_index];
while (!cpp_relex_is_start_chunk(&state, chunk, chunk_size)){
switch (lex_result){
case LexResult_NeedChunk:
++chunk_index;
chunk = chunks[chunk_index];
chunk_size = chunk_sizes[chunk_index];
}
for(;;){
Cpp_Lex_Result lex_result = cpp_relex_step(&state, chunk, chunk_size, size, array, &relex_array);
break;
switch (lex_result){
case LexResult_NeedChunk:
++chunk_index;
chunk = chunks[chunk_index];
chunk_size = chunk_sizes[chunk_index];
break;
case LexResult_NeedTokenMemory: InvalidCodePath;
case LexResult_Finished: goto doublebreak;
}
}
doublebreak:;
i32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
if (new_count > array->max_count){
i32 new_max = LargeRoundUp(new_count, Kbytes(1));
array->tokens = (Cpp_Token*)
general_memory_reallocate(system, general, array->tokens, array->count*sizeof(Cpp_Token), new_max*sizeof(Cpp_Token));
array->max_count = new_max;
}
case LexResult_NeedTokenMemory: InvalidCodePath;
cpp_relex_complete(&state, array, &relex_array);
end_temp_memory(temp);
case LexResult_Finished: goto doublebreak;
}
}
doublebreak:;
i32 new_count = cpp_relex_get_new_count(&state, array->count, &relex_array);
if (new_count > array->max_count){
i32 new_max = LargeRoundUp(new_count, Kbytes(1));
array->tokens = (Cpp_Token*)
general_memory_reallocate(system, general, array->tokens, array->count*sizeof(Cpp_Token), new_max*sizeof(Cpp_Token));
array->max_count = new_max;
}
cpp_relex_complete(&state, array, &relex_array);
end_temp_memory(temp);
return(1);
}
@ -2755,7 +2771,7 @@ view_get_relative_scrolling(View *view){
internal void
view_set_relative_scrolling(View *view, Relative_Scrolling scrolling){
f32 cursor_y = view_get_cursor_y(view);
if (view->edit_pos){
view->edit_pos->scroll.scroll_y = cursor_y - scrolling.scroll_y;
view->edit_pos->scroll.target_y =
@ -3116,7 +3132,7 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
// NOTE(allen): token fixing
if (file->settings.tokens_exist){
if (!file->settings.virtual_white){
file_relex_parallel(system, mem, file, start, end, shift_amount);
file_relex_parallel(system, mem, file, start, end, shift_amount);
}
else{
file_relex_serial(system, mem, file, start, end, shift_amount);
@ -3208,7 +3224,7 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
Buffer_Edit *last_edit = batch + batch_size - 1;
if (!file->settings.virtual_white){
file_relex_parallel(system, mem, file, first_edit->start, last_edit->end, shift_total);
file_relex_parallel(system, mem, file, first_edit->start, last_edit->end, shift_total);
}
else{
file_relex_serial(system, mem, file, first_edit->start, last_edit->end, shift_total);
@ -3724,13 +3740,13 @@ make_string_terminated(Partition *part, char *str, i32 len){
internal void
init_normal_file(System_Functions *system, Models *models, Editing_File *file, char *buffer, i32 size){
String val = make_string(buffer, size);
String val = make_string(buffer, size);
file_create_from_string(system, models, file, val);
Mem_Options *mem = &models->mem;
if (file->settings.tokens_exist && file->state.token_array.tokens == 0){
if (!file->settings.virtual_white){
file_first_lex_parallel(system, mem, file);
file_first_lex_parallel(system, mem, file);
}
else{
file_first_lex_serial(system, mem, file);
@ -3796,7 +3812,7 @@ view_open_file(System_Functions *system, Models *models, View *view, String file
init_normal_file(system, models, file, buffer, size);
}
else{
system->load_close(handle);
system->load_close(handle);
}
if (gen_buffer){
@ -4037,24 +4053,24 @@ update_highlighting(View *view){
view->highlight = {};
return;
}
Editing_File *file = file_view->file;
if (!file || !file_is_ready(file)){
view->highlight = {};
return;
}
Models *models = view->persistent.models;
Style *style = &models->style;
i32 pos = view_get_cursor_pos(file_view);
char c = buffer_get_char(&file->state.buffer, pos);
if (c == '\r'){
view->highlight.ids[0] =
raw_ptr_dif(&style->main.special_character_color, style);
}
else if (file->state.tokens_complete){
Cpp_Token_Stack *tokens = &file->state.token_array;
Cpp_Get_Token_Result result = cpp_get_token(tokens, pos);
@ -4080,7 +4096,7 @@ update_highlighting(View *view){
raw_ptr_dif(&style->main.highlight_white_color, style);
}
}
else{
if (char_is_whitespace(c)){
view->highlight.ids[0] = 0;
@ -4093,7 +4109,7 @@ update_highlighting(View *view){
view->highlight.ids[1] = 0;
}
}
if (file_view->show_temp_highlight){
view->highlight.ids[2] =
raw_ptr_dif(&style->main.highlight_color, style);
@ -4123,9 +4139,9 @@ internal void
intbar_draw_string(Render_Target *target, File_Bar *bar, String str, u32 char_color){
i16 font_id = bar->font_id;
draw_string(target, font_id, str,
(i32)(bar->pos_x + bar->text_shift_x),
(i32)(bar->pos_y + bar->text_shift_y),
char_color);
(i32)(bar->pos_x + bar->text_shift_x),
(i32)(bar->pos_y + bar->text_shift_y),
char_color);
bar->pos_x += font_string_width(target, font_id, str);
}
@ -4408,10 +4424,10 @@ app_single_line_input_core(System_Functions *system, Working_Set *working_set, K
inline Single_Line_Input_Step
app_single_line_input_step(System_Functions *system, Key_Event_Data key, String *string){
Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING;
mode.string = string;
return app_single_line_input_core(system, 0, key, mode);
Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING;
mode.string = string;
return app_single_line_input_core(system, 0, key, mode);
}
inline Single_Line_Input_Step
@ -4434,7 +4450,7 @@ app_single_number_input_step(System_Functions *system, Key_Event_Data key, Strin
Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING;
mode.string = string;
char c = (char)key.character;
if (c == 0 || c == '\n' || char_is_numeric(c))
result = app_single_line_input_core(system, 0, key, mode);
@ -5583,7 +5599,7 @@ click_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *user
b32 result = 0;
i32 mx = user_input->mouse.x;
i32 my = user_input->mouse.y;
if (hit_check(mx, my, session->rect)){
target->hover = b->id;
if (user_input->mouse.press_l){
@ -5609,7 +5625,7 @@ scroll_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *use
b32 result = 0;
i32 mx = user_input->mouse.x;
i32 my = user_input->mouse.y;
if (hit_check(mx, my, session->rect)){
target->hover = id;
if (user_input->mouse.l){

View File

@ -822,17 +822,17 @@ do_buildsuper(char *cdir){
//terminate_with_null(&str);
//buildsuper(cdir, BUILD_DIR, str.str);
#if defined(IS_WINDOWS)
//copy_sc(&str, "../code/internal_4coder_tests.cpp");
//terminate_with_null(&str);
//buildsuper(cdir, BUILD_DIR, str.str);
copy_sc(&str, "../code/internal_4coder_tests.cpp");
terminate_with_null(&str);
buildsuper(cdir, BUILD_DIR, str.str);
#else
copy_sc(&str, "../code/power/4coder_experiments.cpp");
terminate_with_null(&str);
buildsuper(cdir, BUILD_DIR, str.str);
#endif
copy_sc(&str, "../code/power/4coder_casey.cpp");
terminate_with_null(&str);
buildsuper(cdir, BUILD_DIR, str.str);
//copy_sc(&str, "../code/power/4coder_casey.cpp");
//terminate_with_null(&str);
//buildsuper(cdir, BUILD_DIR, str.str);
//copy_sc(&str, "../4vim/4coder_chronal.cpp");
//terminate_with_null(&str);
//buildsuper(cdir, BUILD_DIR, str.str);

View File

@ -1763,15 +1763,12 @@ This call returns non-zero on success.) */{
CPP_NAME(string_set_match)
API_EXPORT FSTRING_LINK fstr_bool
string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index)/*
DOC_PARAM(str_set, The str_set parameter may be an array of any type.
It should point at the String in the first element of the array.)
DOC_PARAM(count, The item_size parameter should describe the "stride" from one String to the next, in other
words it should be the size of one element of the array.)
DOC_PARAM(str_set, The str_set parameter may be an array of any type. It should point at the String in the first element of the array.)
DOC_PARAM(count, The item_size parameter should describe the "stride" from one String to the next, in other words it should be the size of one element of the array.)
DOC_PARAM(count, The count parameter specifies the number of elements in the str_set array.)
DOC_PARAM(str, The str parameter specifies the string to match against the str_set.)
DOC_PARAM(match_index, If this call succeeds match_index is filled with the index into str_set where the match occurred.)
DOC(This call tries to see if str matches any of the strings in str_set. If there is a match the call
succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.)
DOC(This call tries to see if str matches any of the strings in str_set. If there is a match the call succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.)
DOC_SEE(match) */{
fstr_bool result = 0;
int32_t i = 0;
@ -1792,15 +1789,19 @@ DOC_PARAM(str_set, The str_set parameter is an array of String structs specifyin
DOC_PARAM(count, The count parameter specifies the number of String structs in the str_set array.)
DOC_PARAM(str, The str parameter specifies the string to match against the str_set.)
DOC_PARAM(match_index, If this call succeeds match_index is filled with the index into str_set where the match occurred.)
DOC(This call tries to see if str matches any of the strings in str_set. If there is a match the call
succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.)
DOC(This call tries to see if str matches any of the strings in str_set. If there is a match the call succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.)
DOC_SEE(match) */{
fstr_bool result = string_set_match_table(str_set, sizeof(String), count, str, match_index);
return(result);
}
API_EXPORT FSTRING_LINK String
get_first_double_line(String source){
get_first_double_line(String source)/*
DOC_PARAM(source, the source string accross which a 'double line' iteration will occur)
DOC_RETURN(The returned value is the first 'double line' in the source string.)
DOC(A 'double line' is a string of characters delimited by two new line characters. This call begins an iteration over all the double lines in the given source string.)
DOC_SEE(get_next_double_line)
*/{
String line = {0};
int32_t pos0 = find_substr_s(source, 0, make_lit_string("\n\n"));
int32_t pos1 = find_substr_s(source, 0, make_lit_string("\r\n\r\n"));
@ -1812,7 +1813,12 @@ get_first_double_line(String source){
}
API_EXPORT FSTRING_LINK String
get_next_double_line(String source, String line){
get_next_double_line(String source, String line)/*
DOC_PARAM(source, the source string accross which the 'double line' iteration is occurring)
DOC_PARAM(line, the value returned from the previous call of get_first_double_line or get_next_double_line)
DOC_RETURN(The returned value is the first 'double line' in the source string.)
DOC_SEE(get_first_double_line)
*/{
String next = {0};
int32_t pos = (int32_t)(line.str - source.str) + line.size;
int32_t start = 0, pos0 = 0, pos1 = 0;
@ -1835,7 +1841,12 @@ get_next_double_line(String source, String line){
}
API_EXPORT FSTRING_LINK String
get_next_word(String source, String prev_word){
get_next_word(String source, String prev_word)/*
DOC_PARAM(source, the source string accross which the 'word' iteration is occurring)
DOC_PARAM(line, the value returned from the previous call of get_first_word or get_next_word)
DOC_RETURN(The returned value is the first 'word' in the source string.)
DOC_SEE(get_first_word)
*/{
String word = {0};
int32_t pos0 = (int32_t)(prev_word.str - source.str) + prev_word.size;
@ -1864,7 +1875,12 @@ get_next_word(String source, String prev_word){
}
API_EXPORT FSTRING_LINK String
get_first_word(String source){
get_first_word(String source)/*
DOC_PARAM(source, the source string accross which a 'word' iteration will occur)
DOC_RETURN(The returned value is the first 'word' in the source string.)
DOC(A 'word' is a string of characters delimited by whitespace or parentheses. This call begins an iteration over all the double lines in the given source string.)
DOC_SEE(get_next_word)
*/{
String start_str = make_string(source.str, 0);
String word = get_next_word(source, start_str);
return(word);

Binary file not shown.

View File

@ -289,342 +289,8 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
Out_Context context = {0};
set_context_directory(&context, dst_directory);
// Output Docs - General Document Generator
if (begin_file_out(&context, "gen-test.html", &out)){
generate_document_html(&out, part, &doc);
end_file_out(context);
}
else{
// TODO(allen): warning
}
// Output Docs - Direct Method
// Output Docs
if (begin_file_out(&context, API_DOC, &out)){
Used_Links used_links = {0};
init_used_links(part, &used_links, 4000);
append_sc(&out,
"<html lang=\"en-US\">"
"<head>"
"<title>4coder API Docs</title>"
"<style>"
"body { "
"background: " BACK_COLOR "; "
"color: " TEXT_COLOR "; "
"}"
// H things
"h1,h2,h3,h4 { "
"color: " POP_COLOR_1 "; "
"margin: 0; "
"}"
"h2 { "
"margin-top: 6mm; "
"}"
"h3 { "
"margin-top: 5mm; margin-bottom: 5mm; "
"}"
"h4 { "
"font-size: 1.1em; "
"}"
// ANCHORS
"a { "
"color: " POP_COLOR_1 "; "
"text-decoration: none; "
"}"
"a:visited { "
"color: " VISITED_LINK "; "
"}"
"a:hover { "
"background: " POP_BACK_1 "; "
"}"
// LIST
"ul { "
"list-style: none; "
"padding: 0; "
"margin: 0; "
"}"
"</style>"
"</head>\n"
"<body>"
"<div style='font-family:Arial; margin: 0 auto; "
"width: 800px; text-align: justify; line-height: 1.25;'>"
//"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4cpp Lexing Library</h1>");
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API Docs</h1>");
struct Section{
char *id_string;
char *display_string;
};
static int32_t msection = -1;
static Section sections[] = {
{"introduction", "Introduction"},
{"4coder_systems", "4coder Systems"},
{"types_and_functions", "Types and Functions"},
{"string_library", "String Library"},
{"lexer_library", "Lexer Library"}
};
append_sc(&out, "<h3 style='margin:0;'>Table of Contents</h3><ul>");
int32_t section_count = ArrayCount(sections);
for (int32_t i = 0; i < section_count; ++i){
append_sc (&out, "<li><a href='#section_");
append_sc (&out, sections[i].id_string);
append_sc (&out, "'>&sect;");
append_int_to_str (&out, i+1);
append_s_char (&out, ' ');
append_sc (&out, sections[i].display_string);
append_sc (&out, "</a></li>");
}
append_sc(&out, "</ul>");
#define MAJOR_SECTION "1"
msection = 0;
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[msection].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[msection].display_string);
append_sc(&out, "</h2>");
#if 0
// NOTE(allen): doc intro for lexer standalone
append_sc(&out,
"<div>"
"<p>This is the documentation for the 4cpp lexer version 1.1. "
"The documentation is the newest piece of this lexer project "
"so it may still have problems. What is here should be correct "
"and mostly complete.</p>"
"<p>If you have questions or discover errors please contact "
"<span style='"CODE_STYLE"'>editor@4coder.net</span> or "
"to get help from community members you can post on the "
"4coder forums hosted on handmade.network at "
"<span style='"CODE_STYLE"'>4coder.handmade.network</span>.</p>"
"</div>");
#endif
append_sc(&out,
"<div>"
"<p>This is the documentation for " VERSION ". The documentation is still "
"under construction so some of the links are linking to sections that "
"have not been written yet. What is here should be correct and I suspect "
"useful even without some of the other sections.</p>"
"<p>If you have questions or discover errors please contact "
"<span style='"CODE_STYLE"'>editor@4coder.net</span> or "
"to get help from members of the 4coder and handmade network community you "
"can post on the 4coder forums hosted at "
"<span style='"CODE_STYLE"'>4coder.handmade.network</span>.</p>"
"</div>");
#undef MAJOR_SECTION
#define MAJOR_SECTION "2"
msection = 1;
// TODO(allen): Write the 4coder system descriptions.
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[msection].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[msection].display_string);
append_sc(&out, "</h2>");
append_sc(&out, "<div><i>Coming Soon</i><div>");
#undef MAJOR_SECTION
#define MAJOR_SECTION "3"
msection = 2;
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[msection].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[msection].display_string);
append_sc(&out, "</h2>");
#undef SECTION
#define SECTION MAJOR_SECTION".1"
append_sc(&out, "<h3>&sect;"SECTION" Function List</h3><ul>");
for (int32_t i = 0; i < custom_funcs_unit.set.count; ++i){
print_item_in_list(&out, custom_func_names.names[i].public_name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".2"
append_sc(&out, "<h3>&sect;"SECTION" Type List</h3><ul>");
for (int32_t i = 0; i < custom_types_unit.set.count; ++i){
print_item_in_list(&out, custom_types_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".3"
append_sc(&out, "<h3>&sect;"SECTION" Function Descriptions</h3>");
for (int32_t i = 0; i < custom_funcs_unit.set.count; ++i){
Item_Node *item = &custom_funcs_unit.set.items[i];
String name = custom_func_names.names[i].public_name;
append_sc (&out, "<div id='");
append_ss (&out, name);
append_sc (&out, "_doc' style='margin-bottom: 1cm;'>");
append_sc (&out, "<h4>&sect;"SECTION".");
append_int_to_str(&out, i+1);
append_sc (&out, ": ");
append_ss (&out, name);
append_sc (&out, "</h4><div style='"CODE_STYLE" "DESCRIPT_SECTION_STYLE"'>");
print_function_html(&out, &used_links, item->cpp_name, item->ret, "", name, item->breakdown);
append_sc(&out, "</div>");
print_function_docs(&out, part, name, item->doc_string);
append_sc(&out, "</div><hr>");
}
#undef SECTION
#define SECTION MAJOR_SECTION".4"
append_sc(&out, "<h3>&sect;"SECTION" Type Descriptions</h3>");
int32_t I = 1;
for (int32_t i = 0; i < custom_types_unit.set.count; ++i, ++I){
print_item_html(&out, part, &used_links, custom_types_unit.set.items + i, "_doc", SECTION, I, 0, 0);
}
#undef MAJOR_SECTION
#define MAJOR_SECTION "4"
msection = 3;
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[msection].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[msection].display_string);
append_sc(&out, "</h2>");
#undef SECTION
#define SECTION MAJOR_SECTION".1"
append_sc(&out, "<h3>&sect;"SECTION" String Library Intro</h3>");
append_sc(&out, "<div><i>Coming Soon</i><div>");
#undef SECTION
#define SECTION MAJOR_SECTION".2"
append_sc(&out, "<h3>&sect;"SECTION" String Function List</h3>");
append_sc(&out, "<ul>");
for (int32_t i = 0; i < string_unit.set.count; ++i){
print_item_in_list(&out, string_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".3"
append_sc(&out, "<h3>&sect;"SECTION" String Function Descriptions</h3>");
for (int32_t i = 0; i < string_unit.set.count; ++i){
print_item_html(&out, part, &used_links, string_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
#undef MAJOR_SECTION
#define MAJOR_SECTION "5"
msection = 4;
append_sc(&out, "\n<h2 id='section_");
append_sc(&out, sections[msection].id_string);
append_sc(&out, "'>&sect;"MAJOR_SECTION" ");
append_sc(&out, sections[msection].display_string);
append_sc(&out, "</h2>");
#undef SECTION
#define SECTION MAJOR_SECTION".1"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Intro</h3>");
append_sc(&out,
"<div>"
"<p>The 4cpp lexer system provides a polished, fast, flexible system that "
"takes in C/C++ and outputs a tokenization of the text data. There are "
"two API levels. One level is setup to let you easily get a tokenization "
"of the file. This level manages memory for you with malloc to make it "
"as fast as possible to start getting your tokens. The second level "
"enables deep integration by allowing control over allocation, data "
"chunking, and output rate control.</p>"
"<p>To use the quick setup API you simply include 4cpp_lexer.h and read the "
"documentation at <a href='#cpp_lex_file_doc'>cpp_lex_file</a>.</p>"
"<p>To use the the fancier API include 4cpp_lexer.h and read the "
"documentation at <a href='#cpp_lex_step_doc'>cpp_lex_step</a>. "
"If you want to be absolutely sure you are not including malloc into "
"your program you can define FCPP_FORBID_MALLOC before the include and "
"the \"step\" API will continue to work.</p>"
"<p>There are a few more features in 4cpp that are not documented yet. "
"You are free to try to use these, but I am not totally sure they are "
"ready yet, and when they are they will be documented.</p>"
"</div>");
#undef SECTION
#define SECTION MAJOR_SECTION".2"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Function List</h3>");
append_sc(&out, "<ul>");
for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){
print_item_in_list(&out, lexer_funcs_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".3"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Type List</h3>");
append_sc(&out, "<ul>");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
print_item_in_list(&out, lexer_types_unit.set.items[i].name, "_doc");
}
append_sc(&out, "</ul>");
#undef SECTION
#define SECTION MAJOR_SECTION".4"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Function Descriptions</h3>");
for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){
print_item_html(&out, part, &used_links, lexer_funcs_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
#undef SECTION
#define SECTION MAJOR_SECTION".5"
append_sc(&out, "<h3>&sect;"SECTION" Lexer Type Descriptions</h3>");
for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){
print_item_html(&out, part, &used_links, lexer_types_unit.set.items+i, "_doc", SECTION, i+1, 0, 0);
}
append_sc(&out, "</div></body></html>");
end_file_out(context);
}
else{
// TODO(allen): warning
}
// Here to test the file equality tester
// Output Docs - General Document Generator
if (begin_file_out(&context, "gen-test2.html", &out)){
generate_document_html(&out, part, &doc);
end_file_out(context);
}
@ -632,9 +298,6 @@ generate_site(char *code_directory, char *src_directory, char *dst_directory){
// TODO(allen): warning
}
assert_files_are_equal(dst_directory, API_DOC, API_DOC);
assert_files_are_equal(dst_directory, "gen-test.html", "gen-test2.html");
assert_files_are_equal(dst_directory, API_DOC, "gen-test.html");
}
int main(int argc, char **argv){