From a541d4b4c94ba27a9381e0bf453f57632368ce1d Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 24 Nov 2020 18:04:46 -0800 Subject: [PATCH] Run variable dump on config apply; fix bugs in variable dump --- custom/4coder_config.cpp | 7 +++++++ custom/4coder_variables.cpp | 4 ++-- custom/generated/command_metadata.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/custom/4coder_config.cpp b/custom/4coder_config.cpp index 3e520b6d..a74fea66 100644 --- a/custom/4coder_config.cpp +++ b/custom/4coder_config.cpp @@ -1418,6 +1418,8 @@ config_parse__data(Application_Links *app, Arena *arena, String_Const_u8 file_na if (parsed != 0){ success = true; + + config_fixed_string_var(parsed, "user_name", 0, &config->user_name, config->user_name_space); @@ -1669,6 +1671,11 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con if (error_text.str != 0){ print_message(app, error_text); } + + // NOTE(allen): Save As Variables + if (error_text.str == 0){ + def_var_from_config(app, vars_get_root(), string_litinit("config"), parsed); + } } else{ print_message(app, string_u8_litexpr("Using default config:\n")); diff --git a/custom/4coder_variables.cpp b/custom/4coder_variables.cpp index 6547e559..95b45ac8 100644 --- a/custom/4coder_variables.cpp +++ b/custom/4coder_variables.cpp @@ -202,7 +202,7 @@ vars_new_variable(Variable_Handle var, String_ID key){ } else{ handle.ptr = vars_free_variables; - if (handle.ptr == 0){ + if (handle.ptr != 0){ sll_stack_pop(vars_free_variables); } else{ @@ -222,7 +222,7 @@ vars_new_variable(Variable_Handle var, String_ID key){ function Variable_Handle vars_new_variable(Variable_Handle var, String_ID key, String_ID string){ Variable_Handle result = vars_new_variable(var, key); - vars_set_string(var, string); + vars_set_string(result, string); return(result); } diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index 8abb116a..4111b991 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -372,7 +372,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, { PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 867 }, -{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1797 }, +{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1805 }, { PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 }, { PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 }, { PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 },