Adding dirty file reloading

This commit is contained in:
PS 2024-02-10 14:25:22 -08:00
parent 80b780278a
commit 0a03ea05f1
1 changed files with 22 additions and 11 deletions

View File

@ -80,7 +80,6 @@ CUSTOM_DOC("Input consumption loop for default view behavior")
Managed_Scope scope = view_get_managed_scope(app, view);
for (;;){
// NOTE(allen): Get input
User_Input input = get_next_input(app, EventPropertyGroup_Any, 0);
if (input.abort){
break;
@ -149,30 +148,42 @@ code_index_update_tick(Application_Links *app){
buffer_modified_set_clear();
}
f32 time_since_last_dirty_buffers_check = 0;
function void
reload_clean_buffers_on_filesystem_change(Application_Links *app, Frame_Info frame_info)
{
time_since_last_dirty_buffers_check += frame_info.literal_dt;
if (time_since_last_dirty_buffers_check > 1)
{
time_since_last_dirty_buffers_check = 0;
for (Buffer_ID buffer = get_buffer_next(app, 0, Access_Always);
buffer != 0;
buffer = get_buffer_next(app, buffer, Access_Always)) {
Dirty_State dirty = buffer_get_dirty_state(app, buffer);
if (dirty == DirtyState_UnloadedChanges) {
buffer_reopen(app, buffer, 0);
}
}
}
}
function void
default_tick(Application_Links *app, Frame_Info frame_info){
////////////////////////////////
// NOTE(allen): Update code index
code_index_update_tick(app);
////////////////////////////////
// NOTE(allen): Update fade ranges
if (tick_all_fade_ranges(app, frame_info.animation_dt)){
animate_in_n_milliseconds(app, 0);
}
////////////////////////////////
// NOTE(allen): Clear layouts if virtual whitespace setting changed.
{
{ // Clear layouts if virtual whitespace setting changed
b32 enable_virtual_whitespace = def_get_config_b32(vars_save_string_lit("enable_virtual_whitespace"));
if (enable_virtual_whitespace != def_enable_virtual_whitespace){
def_enable_virtual_whitespace = enable_virtual_whitespace;
clear_all_layouts(app);
}
}
reload_clean_buffers_on_filesystem_change(app, frame_info);
}
function Rect_f32