New hook for edited files::

This commit is contained in:
Allen Webster 2019-01-31 04:38:24 -08:00
parent 8b8d880561
commit 4867c26c43
16 changed files with 176 additions and 87 deletions

View File

@ -1087,6 +1087,8 @@ ENUM(int32_t, Special_Hook_ID){
/* DOC(TODO) */
special_hook_end_file,
/* DOC(TODO) */
special_hook_file_edit_finished,
/* DOC(TODO) */
special_hook_command_caller,
/* DOC(TODO) */
special_hook_render_caller,
@ -1112,6 +1114,9 @@ TYPEDEF_FUNC int32_t Hook_Function(struct Application_Links *app);
TYPEDEF_FUNC int32_t Open_File_Hook_Function(struct Application_Links *app, Buffer_ID buffer_id);
#define OPEN_FILE_HOOK_SIG(name) int32_t name(struct Application_Links *app, Buffer_ID buffer_id)
TYPEDEF_FUNC int32_t File_Edit_Finished_Function(struct Application_Links *app, Buffer_ID buffer_id);
#define FILE_EDIT_FINISHED_SIG(name) int32_t name(struct Application_Links *app, Buffer_ID buffer_id)
TYPEDEF_FUNC void Input_Filter_Function(Mouse_State *mouse);
#define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse)
@ -1119,7 +1124,6 @@ TYPEDEF_FUNC int32_t Scroll_Rule_Function(float target_x, float target_y, float
#define SCROLL_RULE_SIG(name) \
int32_t name(float target_x, float target_y, float *scroll_x, float *scroll_y, int32_t view_id, int32_t is_new_target, float dt)
STRUCT Buffer_Name_Conflict_Entry{
Buffer_ID buffer_id;
char *file_name;

View File

@ -750,6 +750,24 @@ OPEN_FILE_HOOK_SIG(default_file_save){
return(0);
}
OPEN_FILE_HOOK_SIG(default_file_edit){
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
Assert(buffer.exists);
if (buffer.buffer_name_len > 0 && buffer.buffer_name[0] != '*'){
char space[256];
String str = make_fixed_width_string(space);
append(&str, "edit finished: ");
append(&str, make_string(buffer.file_name, buffer.file_name_len));
append(&str, "\n");
print_message(app, str.str, str.size);
}
// no meaning for return
return(0);
}
OPEN_FILE_HOOK_SIG(default_end_file){
Buffer_Summary buffer = get_buffer(app, buffer_id, AccessAll);
Assert(buffer.exists);
@ -873,6 +891,7 @@ set_all_default_hooks(Bind_Helper *context){
set_open_file_hook(context, default_file_settings);
set_new_file_hook(context, default_new_file);
set_save_file_hook(context, default_file_save);
set_file_edit_finished_hook(context, default_file_edit);
set_end_file_hook(context, end_file_close_jump_list);

View File

@ -212,6 +212,15 @@ set_end_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
write_unit(helper, unit);
}
static void
set_file_edit_finished_hook(Bind_Helper *helper, File_Edit_Finished_Function *func){
Binding_Unit unit = {};
unit.type = unit_hook;
unit.hook.hook_id = special_hook_file_edit_finished;
unit.hook.func = (void*)func;
write_unit(helper, unit);
}
inline void
set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){
Binding_Unit unit = {};

30
4ed.cpp
View File

@ -228,6 +228,7 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
models->hook_new_file = 0;
models->hook_save_file = 0;
models->hook_end_file = 0;
models->hook_file_edit_finished = 0;
models->command_caller = 0;
models->render_caller = 0;
models->input_filter = 0;
@ -454,6 +455,11 @@ interpret_binding_buffer(Models *models, void *buffer, i32 size){
models->hook_end_file = (Open_File_Hook_Function*)unit->hook.func;
}break;
case special_hook_file_edit_finished:
{
models->hook_file_edit_finished = (File_Edit_Finished_Function*)unit->hook.func;
}break;
case special_hook_command_caller:
{
models->command_caller = (Command_Caller_Hook_Function*)unit->hook.func;
@ -1559,7 +1565,29 @@ App_Step_Sig(app_step){
}
}
// NOTE(allen): If the exit signal has been sent, run the exit hook.
// NOTE(allen): hook for marked edited files
{
File_Edit_Finished_Function *hook_file_edit_finished = models->hook_file_edit_finished;
if (hook_file_edit_finished != 0){
Working_Set *working_set = &models->working_set;
if (working_set->edit_finished_list.next != 0){
Node *first = working_set->edit_finished_list.next;
working_set->edit_finished_list.next = 0;
working_set->edit_finished_list.prev = 0;
for (Node *node = first, *next = 0;
node != 0;
node = next){
next = node->next;
Editing_File *file = CastFromMember(Editing_File, edit_finished_mark_node, node);
hook_file_edit_finished(&models->app_links, file->id.id);
node->next = 0;
node->prev = 0;
}
}
}
}
// NOTE(allen): if the exit signal has been sent, run the exit hook.
if (input->trying_to_kill){
models->keep_playing = false;
}

View File

@ -457,7 +457,9 @@ DOC(Gives the total number of buffers in the application.)
internal void
internal_get_buffer_first(Working_Set *working_set, Buffer_Summary *buffer){
if (working_set->file_count > 0){
fill_buffer_summary(buffer, (Editing_File*)working_set->used_sentinel.next, working_set);
Node *node = working_set->used_sentinel.next;
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
fill_buffer_summary(buffer, file, working_set);
}
}
@ -465,8 +467,9 @@ internal void
get_buffer_next__internal(Working_Set *working_set, Buffer_Summary *buffer){
Editing_File *file = working_set_get_active_file(working_set, buffer->buffer_id);
if (file != 0){
file = (Editing_File*)file->node.next;
if (file != (Editing_File*)&working_set->used_sentinel){
file = CastFromMember(Editing_File, main_chain_node, file->main_chain_node.next);
Editing_File *sentinel_file_ptr = CastFromMember(Editing_File, main_chain_node, &working_set->used_sentinel);
if (file != sentinel_file_ptr){
fill_buffer_summary(buffer, file, working_set);
}
else{
@ -1182,7 +1185,7 @@ DOC_SEE(Buffer_Create_Flag)
file = working_set_alloc_always(working_set, heap, &models->lifetime_allocator);
if (file != 0){
if (has_canon_name){
buffer_bind_file(system, heap, working_set, file, canon.name);
file_bind_filename(system, heap, working_set, file, canon.name);
}
buffer_bind_name(models, heap, part, working_set, file, front_of_directory(fname));
init_normal_file(system, models, 0, 0, file);
@ -1207,7 +1210,7 @@ DOC_SEE(Buffer_Create_Flag)
system->load_close(handle);
file = working_set_alloc_always(working_set, heap, &models->lifetime_allocator);
if (file != 0){
buffer_bind_file(system, heap, working_set, file, canon.name);
file_bind_filename(system, heap, working_set, file, canon.name);
buffer_bind_name(models, heap, part, working_set, file, front_of_directory(fname));
init_normal_file(system, models, buffer, size, file);
fill_buffer_summary(&result, file, &models->working_set);
@ -1327,8 +1330,8 @@ DOC_SEE(Buffer_Identifier)
file_free(system, &models->app_links, &models->mem.heap, &models->lifetime_allocator, file);
working_set_free_file(&models->mem.heap, working_set, file);
File_Node *used = &working_set->used_sentinel;
File_Node *node = used->next;
Node *used = &working_set->used_sentinel;
Node *node = used->next;
for (Panel *panel = models->layout.used_sentinel.next;
panel != &models->layout.used_sentinel;
panel = panel->next){
@ -1336,7 +1339,8 @@ DOC_SEE(Buffer_Identifier)
if (view->transient.file_data.file == file){
Assert(node != used);
view->transient.file_data.file = 0;
view_set_file(system, models, view, (Editing_File*)node);
Editing_File *new_file = CastFromMember(Editing_File, main_chain_node, node);
view_set_file(system, models, view, new_file);
if (node->next != used){
node = node->next;
}
@ -2373,6 +2377,10 @@ get_lifetime_object_from_workspace(Dynamic_Workspace *workspace){
View *vptr = (View*)workspace->user_back_ptr;
result = vptr->transient.lifetime_object;
}break;
default:
{
InvalidCodePath;
}break;
}
return(result);
}

View File

@ -44,16 +44,17 @@ struct Models{
Coroutine_Head *command_coroutine;
u32 command_coroutine_flags[2];
Hook_Function *hooks[hook_type_count];
Application_Links app_links;
Custom_API config_api;
Application_Links app_links;
Hook_Function *hooks[hook_type_count];
Start_Hook_Function *hook_start;
Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file;
Open_File_Hook_Function *hook_save_file;
Open_File_Hook_Function *hook_end_file;
File_Edit_Finished_Function *hook_file_edit_finished;
Command_Caller_Hook_Function *command_caller;
Render_Caller_Function *render_caller;
Input_Filter_Function *input_filter;

View File

@ -77,6 +77,8 @@ typedef double f64;
#define CastFromMember(S,m,ptr) (S*)( (uint8_t*)(ptr) - OffsetOfMember(S,m) )
#define IntAsPtr(a) (void*)(((uint8_t*)0) + a)
#define Stmnt(s) do{ s }while(0)
#define STR__(s) #s
#define STR_(s) STR__(s)
#define LINE_STR STR_(__LINE__)

View File

@ -246,6 +246,9 @@ edit_single__inner(System_Functions *system, Models *models, Editing_File *file,
if (file->settings.tokens_exist){
file_relex(system, models, file, start, end, shift_amount);
}
else{
file_mark_edit_finished(&models->working_set, file);
}
// NOTE(allen): meta data
Gap_Buffer *buffer = &file->state.buffer;
@ -362,6 +365,9 @@ edit_batch(System_Functions *system, Models *models, Editing_File *file,
Buffer_Edit *last_edit = batch + batch_size - 1;
file_relex(system, models, file, first_edit->start, last_edit->end, shift_total);
}
else{
file_mark_edit_finished(&models->working_set, file);
}
}break;
case BatchEdit_PreserveTokens:
@ -370,7 +376,7 @@ edit_batch(System_Functions *system, Models *models, Editing_File *file,
Cpp_Token_Array tokens = file->state.token_array;
Cpp_Token *token = tokens.tokens;
Cpp_Token *end_token = tokens.tokens + tokens.count;
Cpp_Token original = {(Cpp_Token_Type)0};
Cpp_Token original = {};
Buffer_Edit *edit = batch;
Buffer_Edit *end_edit = batch + batch_size;
@ -378,7 +384,7 @@ edit_batch(System_Functions *system, Models *models, Editing_File *file,
i32 shift_amount = 0;
i32 local_shift = 0;
for (; token < end_token; ++token){
for (;token < end_token; ++token){
original = *token;
for (; edit < end_edit && edit->start <= original.start; ++edit){
local_shift = (edit->len - (edit->end - edit->start));
@ -392,6 +398,7 @@ edit_batch(System_Functions *system, Models *models, Editing_File *file,
token->size += local_shift;
shift_amount += local_shift;
}
file_mark_edit_finished(&models->working_set, file);
}
}break;
}

View File

@ -478,7 +478,6 @@ internal void
file_create_from_string(System_Functions *system, Models *models, Editing_File *file, String val, u32 flags){
Heap *heap = &models->mem.heap;
Partition *part = &models->mem.part;
Open_File_Hook_Function *hook_open_file = models->hook_open_file;
Application_Links *app_links = &models->app_links;
memset(&file->state, 0, sizeof(file->state));
@ -549,6 +548,7 @@ file_create_from_string(System_Functions *system, Models *models, Editing_File *
file->state.undo.current_block_normal = 1;
}
Open_File_Hook_Function *hook_open_file = models->hook_open_file;
if (hook_open_file != 0){
hook_open_file(app_links, file->id.id);
}

View File

@ -99,14 +99,7 @@ struct Editing_File_Name{
String name;
};
struct File_Node{
File_Node *next;
File_Node *prev;
};
struct Editing_File{
// NOTE(allen): node must be the first member of Editing_File!
File_Node node;
Buffer_Slot_ID id;
Editing_File_Settings settings;
b32 is_loading;
@ -116,6 +109,8 @@ struct Editing_File{
Editing_File_Name base_name;
Editing_File_Name unique_name;
Editing_File_Name canon;
Node main_chain_node;
Node edit_finished_mark_node;
};
#endif

View File

@ -22,11 +22,6 @@ file_lex_chunks(Partition *part, Gap_Buffer *buffer){
return(result);
}
internal void
file_lex_mark_new_tokens(System_Functions *system, Models *models, Editing_File *file){
// TODO(allen): Figure out what we want to do to mark these files.
}
internal void
job_full_lex(System_Functions *system, Thread_Context *thread, Thread_Memory *memory, void *data[4]){
Editing_File *file = (Editing_File*)data[0];
@ -140,7 +135,7 @@ job_full_lex(System_Functions *system, Thread_Context *thread, Thread_Memory *me
}
file->state.tokens_complete = true;
file->state.still_lexing = false;
file_lex_mark_new_tokens(system, models, file);
file_mark_edit_finished(&models->working_set, file);
system->release_lock(FRAME_LOCK);
}
@ -282,7 +277,7 @@ file_first_lex_serial(System_Functions *system, Models *models, Editing_File *fi
end_temp_memory(temp);
file->state.tokens_complete = true;
file_lex_mark_new_tokens(system, models, file);
file_mark_edit_finished(&models->working_set, file);
}
}
@ -373,7 +368,7 @@ file_relex_parallel(System_Functions *system, Models *models, Editing_File *file
}
cpp_relex_complete(&state, array, &relex_array);
file_lex_mark_new_tokens(system, models, file);
file_mark_edit_finished(&models->working_set, file);
}
else{
cpp_relex_abort(&state, array);
@ -492,7 +487,7 @@ file_relex_serial(System_Functions *system, Models *models, Editing_File *file,
}
cpp_relex_complete(&state, array, &relex_array);
file_lex_mark_new_tokens(system, models, file);
file_mark_edit_finished(&models->working_set, file);
end_temp_memory(temp);

View File

@ -18,19 +18,26 @@
#define dll_remove(n) (n)->next->prev=(n)->prev,(n)->prev->next=(n)->next
#define zdll_push_back_(f,l,n) if(f==0){n->next=n->prev=0;f=l=n;}else{n->prev=l;n->next=0;l->next=n;l=n;}
#define zdll_push_back(f,l,n) do{ zdll_push_back_((f),(l),(n)) }while(0)
#define zdll_push_back(f,l,n) Stmnt( zdll_push_back_((f),(l),(n)) )
#define zdll_push_front_(f,l,n) if(f==0){n->prev=n->next=0;f=l=n;}else{n->next=l;n->prev=0;l->prev=n;l=n;}
#define zdll_push_front(f,l,n) Stmnt( zdll_push_front_((f),(l),(n)) )
#define zdll_remove_front_(f,l,n) if(f==l){f=l=0;}else{f=f->next;f->prev=0;}
#define zdll_remove_back_(f,l,n) if(f==l){f=l=0;}else{l=l->prev;l->next=0;}
#define zdll_remove_(f,l,n) if(f==n){zdll_remove_front_(f,l,n);}else if(l==n){zdll_remove_back_(f,l,n);}else{dll_remove(n);}
#define zdll_remove(f,l,n) do{ zdll_remove_((f),(l),(n)) }while(0)
#define zdll_remove(f,l,n) Stmnt( zdll_remove_((f),(l),(n)) )
#define sll_clear(f,l) (f)=(l)=0
#define sll_push(f,l,n) if((f)==0&&(l)==0){(f)=(l)=(n);}else{(l)->next=(n);(l)=(n);}(l)->next=0
#define sll_pop(f,l) if((f)!=(l)){(f)=(f)->next;}else{(f)=(l)=0;}
#define sll_push(f,l,n) Stmnt( if((f)==0&&(l)==0){(f)=(l)=(n);}else{(l)->next=(n);(l)=(n);}(l)->next=0; )
#define sll_pop(f,l) Stmnt( if((f)!=(l)){(f)=(f)->next;}else{(f)=(l)=0;} )
#define sll_init_sentinel(s) do{ (s)->next=(s); }while(0)
#define sll_insert(p,v) do{ (v)->next=(p)->next; (p)->next = (v); }while(0)
#define sll_remove(p,v) do{ Assert((p)->next == (v)); (p)->next = (v)->next; }while(0)
#define sll_init_sentinel(s) Stmnt( (s)->next=(s); )
#define sll_insert(p,v) Stmnt( (v)->next=(p)->next; (p)->next = (v); )
#define sll_remove(p,v) Stmnt( Assert((p)->next == (v)); (p)->next = (v)->next; )
struct Node{
Node *next;
Node *prev;
};
#endif

View File

@ -341,7 +341,7 @@ view_set_file(System_Functions *system, Models *models, View *view, Editing_File
Assert(file != 0);
if (view->transient.file_data.file != 0){
touch_file(&models->working_set, view->transient.file_data.file);
file_touch(&models->working_set, view->transient.file_data.file);
}
File_Edit_Positions *edit_pos = view->transient.edit_pos;
@ -433,10 +433,10 @@ file_set_font(System_Functions *system, Models *models, Editing_File *file, Face
internal void
global_set_font_and_update_files(System_Functions *system, Models *models, Face_ID font_id){
for (File_Node *node = models->working_set.used_sentinel.next;
for (Node *node = models->working_set.used_sentinel.next;
node != &models->working_set.used_sentinel;
node = node->next){
Editing_File *file = (Editing_File*)node;
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
file_set_font(system, models, file, font_id);
}
models->global_font_id = font_id;
@ -447,10 +447,10 @@ alter_font_and_update_files(System_Functions *system, Models *models, Face_ID fo
b32 success = false;
if (system->font.face_change_settings(font_id, new_settings)){
success = true;
for (File_Node *node = models->working_set.used_sentinel.next;
for (Node *node = models->working_set.used_sentinel.next;
node != &models->working_set.used_sentinel;
node = node->next){
Editing_File *file = (Editing_File*)node;
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
if (file->settings.font_id == font_id){
file_full_remeasure(system, models, file);
}
@ -475,10 +475,10 @@ release_font_and_update_files(System_Functions *system, Models *models, Face_ID
Assert(replacement_id <= largest_id && replacement_id > 0);
}
success = true;
for (File_Node *node = models->working_set.used_sentinel.next;
for (Node *node = models->working_set.used_sentinel.next;
node != &models->working_set.used_sentinel;
node = node->next){
Editing_File *file = (Editing_File*)node;
Editing_File *file = CastFromMember(Editing_File, main_chain_node, node);
if (file->settings.font_id == font_id){
file_set_font(system, models, file, replacement_id);
}

View File

@ -57,11 +57,11 @@ working_set_extend_memory(Working_Set *working_set, Editing_File *new_space, i16
id.part[1] = high_part;
Editing_File *file_ptr = new_space;
File_Node *free_sentinel = &working_set->free_sentinel;
Node *free_sentinel = &working_set->free_sentinel;
for (i16 i = 0; i < number_of_files; ++i, ++file_ptr){
id.part[0] = i;
file_ptr->id = id;
dll_insert(free_sentinel, &file_ptr->node);
dll_insert(free_sentinel, &file_ptr->main_chain_node);
}
}
@ -84,19 +84,19 @@ working_set_alloc_always(Working_Set *working_set, Heap *heap, Lifetime_Allocato
}
if (working_set->file_count < working_set->file_max){
File_Node *node = working_set->free_sentinel.next;
Node *node = working_set->free_sentinel.next;
Assert(node != &working_set->free_sentinel);
result = (Editing_File*)node;
result = CastFromMember(Editing_File, main_chain_node, node);
++working_set->file_count;
dll_remove(node);
dll_insert(&working_set->used_sentinel, node);
File_Node node_val = result->node;
Node node_val = result->main_chain_node;
Buffer_Slot_ID id_val = result->id;
memset(result, 0, sizeof(*result));
result->node = node_val;
result->main_chain_node = node_val;
result->id = id_val;
working_set_file_default_settings(working_set, result);
@ -107,13 +107,12 @@ working_set_alloc_always(Working_Set *working_set, Heap *heap, Lifetime_Allocato
inline void
working_set_free_file(Heap *heap, Working_Set *working_set, Editing_File *file){
if (working_set->sync_check_iter == &file->node){
if (working_set->sync_check_iter == &file->main_chain_node){
working_set->sync_check_iter = working_set->sync_check_iter->next;
}
file->is_dummy = true;
dll_remove(&file->node);
dll_insert(&working_set->free_sentinel, &file->node);
dll_remove(&file->main_chain_node);
dll_insert(&working_set->free_sentinel, &file->main_chain_node);
--working_set->file_count;
}
@ -173,8 +172,8 @@ working_set_init(Working_Set *working_set, Partition *partition, Heap *heap){
// NOTE(allen): init null file
{
Editing_File *null_file = working_set_index(working_set, 0);
dll_remove(&null_file->node);
null_file->is_dummy = 1;
dll_remove(&null_file->main_chain_node);
null_file->is_dummy = true;
++working_set->file_count;
}
#endif
@ -285,10 +284,10 @@ working_set_lookup_file(Working_Set *working_set, String string){
Editing_File *file = 0;
// TODO(allen): use the name table for this
for (File_Node *node = working_set->used_sentinel.next;
for (Node *node = working_set->used_sentinel.next;
node != &working_set->used_sentinel;
node = node->next){
Editing_File *nfile = (Editing_File*)node;
Editing_File *nfile = CastFromMember(Editing_File, main_chain_node, node);
if (string.size == 0 || match_ss(string, nfile->unique_name.name)){
file = nfile;
break;
@ -296,10 +295,10 @@ working_set_lookup_file(Working_Set *working_set, String string){
}
if (file == 0){
for (File_Node *node = working_set->used_sentinel.next;
for (Node *node = working_set->used_sentinel.next;
node != &working_set->used_sentinel;
node = node->next){
Editing_File *nfile = (Editing_File*)node;
Editing_File *nfile = CastFromMember(Editing_File, main_chain_node, node);
if (string.size == 0 || has_substr_s(nfile->unique_name.name, string)){
file = nfile;
break;
@ -310,14 +309,6 @@ working_set_lookup_file(Working_Set *working_set, String string){
return(file);
}
internal void
touch_file(Working_Set *working_set, Editing_File *file){
Assert(file != 0);
Assert(!file->is_dummy);
dll_remove(&file->node);
dll_insert(&working_set->used_sentinel, &file->node);
}
////////////////////////////////
// TODO(allen): Bring the clipboard fully to the custom side.
@ -405,10 +396,9 @@ get_canon_name(System_Functions *system, String filename, Editing_File_Name *can
}
internal void
buffer_bind_file(System_Functions *system, Heap *heap, Working_Set *working_set, Editing_File *file, String canon_filename){
file_bind_filename(System_Functions *system, Heap *heap, Working_Set *working_set, Editing_File *file, String canon_filename){
Assert(file->unique_name.name.size == 0);
Assert(file->canon.name.size == 0);
file->canon.name = make_fixed_width_string(file->canon.name_);
copy(&file->canon.name, canon_filename);
terminate_with_null(&file->canon.name);
@ -432,9 +422,10 @@ internal b32
buffer_name_has_conflict(Working_Set *working_set, String base_name){
b32 hit_conflict = false;
File_Node *used_nodes = &working_set->used_sentinel;
for (File_Node *node = used_nodes->next; node != used_nodes; node = node->next){
Editing_File *file_ptr = (Editing_File*)node;if (file_is_ready(file_ptr) && match(base_name, file_ptr->unique_name.name)){
Node *used_nodes = &working_set->used_sentinel;
for (Node *node = used_nodes->next; node != used_nodes; node = node->next){
Editing_File *file_ptr = CastFromMember(Editing_File, main_chain_node, node);
if (file_is_ready(file_ptr) && match(base_name, file_ptr->unique_name.name)){
hit_conflict = true;
break;
}
@ -508,9 +499,9 @@ buffer_bind_name(Models *models, Heap *heap, Partition *scratch,
++conflict_count;
}
File_Node *used_nodes = &working_set->used_sentinel;
for (File_Node *node = used_nodes->next; node != used_nodes; node = node->next){
Editing_File *file_ptr = (Editing_File*)node;
Node *used_nodes = &working_set->used_sentinel;
for (Node *node = used_nodes->next; node != used_nodes; node = node->next){
Editing_File *file_ptr = CastFromMember(Editing_File, main_chain_node, node);
if (file_is_ready(file_ptr) && match(base_name, file_ptr->base_name.name)){
Editing_File **new_file_ptr = push_array(scratch, Editing_File*, 1);
*new_file_ptr = file_ptr;
@ -586,7 +577,7 @@ open_file(System_Functions *system, Models *models, String filename){
Partition *part = &mem->part;
file = working_set_alloc_always(working_set, heap, &models->lifetime_allocator);
buffer_bind_file(system, heap, working_set, file, canon_name.name);
file_bind_filename(system, heap, working_set, file, canon_name.name);
buffer_bind_name(models, heap, part, working_set, file, front_of_directory(filename));
Temp_Memory temp = begin_temp_memory(part);
@ -618,5 +609,24 @@ open_file(System_Functions *system, Models *models, String filename){
return(file);
}
////////////////////////////////
internal void
file_touch(Working_Set *working_set, Editing_File *file){
Assert(file != 0);
Assert(!file->is_dummy);
dll_remove(&file->main_chain_node);
dll_insert(&working_set->used_sentinel, &file->main_chain_node);
}
internal void
file_mark_edit_finished(Working_Set *working_set, Editing_File *file){
if (file->edit_finished_mark_node.next == 0){
zdll_push_back(working_set->edit_finished_list.next,
working_set->edit_finished_list.prev,
&file->edit_finished_mark_node);
}
}
// BOTTOM

View File

@ -27,20 +27,22 @@ struct Working_Set{
i32 file_count, file_max;
i16 array_count, array_max;
File_Node free_sentinel;
File_Node used_sentinel;
Node free_sentinel;
Node used_sentinel;
Node edit_finished_list;
Table canon_table;
Table name_table;
// TODO(allen): WTF?
String clipboards[64];
i32 clipboard_size, clipboard_max_size;
i32 clipboard_current, clipboard_rolling;
i32 clipboard_size;
i32 clipboard_max_size;
i32 clipboard_current;
i32 clipboard_rolling;
//u64 unique_file_counter;
File_Node *sync_check_iter;
Node *sync_check_iter;
i32 default_display_width;
i32 default_minimum_base_display_width;
@ -51,6 +53,9 @@ struct File_Name_Entry{
Buffer_Slot_ID id;
};
internal void
file_mark_edit_finished(Working_Set *working_set, Editing_File *file);
#endif
// BOTTOM

View File

@ -265,7 +265,6 @@ enum{
internal void
emit_begin_mapping(Partition *part, Mapping_Array *array, char *name, char *description){
Assert(array->current_mapping == 0);
Mapping *mapping = push_array(part, Mapping, 1);
mapping->name = fm_basic_str(part, name);
mapping->name_len = str_size(name);