Take out explicit config writer
parent
a541d4b4c9
commit
a0bca352ce
|
@ -1663,18 +1663,17 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
|||
Config *parsed = config_parse__file_name(app, out_arena, "config.4coder", config);
|
||||
|
||||
if (parsed != 0){
|
||||
// Top
|
||||
print_message(app, string_u8_litexpr("Loaded config file:\n"));
|
||||
|
||||
// Errors
|
||||
String_Const_u8 error_text = config_stringize_errors(app, scratch, parsed);
|
||||
if (error_text.str != 0){
|
||||
print_message(app, string_u8_litexpr("trying to load config file:\n"));
|
||||
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);
|
||||
Variable_Handle config_var = def_var_from_config(app, vars_get_root(), string_litinit("config"), parsed);
|
||||
vars_print(app, config_var);
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -1694,66 +1693,6 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
|||
#undef M
|
||||
}
|
||||
|
||||
{
|
||||
// Values
|
||||
Temp_Memory temp2 = begin_temp(scratch);
|
||||
List_String_Const_u8 list = {};
|
||||
|
||||
config_feedback_string(scratch, &list, "user_name", config->user_name);
|
||||
config_feedback_extension_list(scratch, &list, "treat_as_code", &config->code_exts);
|
||||
|
||||
config_feedback_string(scratch, &list, "mapping", config->mapping);
|
||||
config_feedback_string(scratch, &list, "mode", config->mode);
|
||||
|
||||
config_feedback_bool(scratch, &list, "bind_by_physical_key", config->bind_by_physical_key);
|
||||
config_feedback_bool(scratch, &list, "use_scroll_bars", config->use_scroll_bars);
|
||||
config_feedback_bool(scratch, &list, "use_file_bars", config->use_file_bars);
|
||||
config_feedback_bool(scratch, &list, "hide_file_bar_in_ui", config->hide_file_bar_in_ui);
|
||||
config_feedback_bool(scratch, &list, "use_error_highlight", config->use_error_highlight);
|
||||
config_feedback_bool(scratch, &list, "use_jump_highlight", config->use_jump_highlight);
|
||||
config_feedback_bool(scratch, &list, "use_scope_highlight", config->use_scope_highlight);
|
||||
config_feedback_bool(scratch, &list, "use_paren_helper", config->use_paren_helper);
|
||||
config_feedback_bool(scratch, &list, "use_comment_keyword", config->use_comment_keyword);
|
||||
config_feedback_bool(scratch, &list, "lister_whole_word_backspace_when_modified", config->lister_whole_word_backspace_when_modified);
|
||||
config_feedback_bool(scratch, &list, "show_line_number_margins", config->show_line_number_margins);
|
||||
config_feedback_bool(scratch, &list, "enable_output_wrapping", config->enable_output_wrapping);
|
||||
config_feedback_bool(scratch, &list, "enable_undo_fade_out", config->enable_undo_fade_out);
|
||||
|
||||
config_feedback_int(scratch, &list, "cursor_roundness", (i32)(config->cursor_roundness*100.f));
|
||||
config_feedback_int(scratch, &list, "mark_thickness", (i32)(config->mark_thickness));
|
||||
config_feedback_int(scratch, &list, "lister_roundness", (i32)(config->lister_roundness*100.f));
|
||||
|
||||
config_feedback_bool(scratch, &list, "enable_virtual_whitespace", config->enable_virtual_whitespace);
|
||||
config_feedback_int(scratch, &list, "virtual_whitespace_regular_indent", config->virtual_whitespace_regular_indent);
|
||||
config_feedback_bool(scratch, &list, "enable_code_wrapping", config->enable_code_wrapping);
|
||||
config_feedback_bool(scratch, &list, "automatically_indent_text_on_save", config->automatically_indent_text_on_save);
|
||||
config_feedback_bool(scratch, &list, "automatically_save_changes_on_build", config->automatically_save_changes_on_build);
|
||||
config_feedback_bool(scratch, &list, "automatically_load_project", config->automatically_load_project);
|
||||
|
||||
config_feedback_bool(scratch, &list, "indent_with_tabs", config->indent_with_tabs);
|
||||
config_feedback_int(scratch, &list, "indent_width", config->indent_width);
|
||||
config_feedback_int(scratch, &list, "default_tab_width", config->default_tab_width);
|
||||
|
||||
config_feedback_string(scratch, &list, "default_theme_name", config->default_theme_name);
|
||||
config_feedback_bool(scratch, &list, "highlight_line_at_cursor", config->highlight_line_at_cursor);
|
||||
|
||||
config_feedback_string(scratch, &list, "default_font_name", config->default_font_name);
|
||||
config_feedback_int(scratch, &list, "default_font_size", config->default_font_size);
|
||||
config_feedback_bool(scratch, &list, "default_font_hinting", config->default_font_hinting);
|
||||
|
||||
config_feedback_string(scratch, &list, "default_compiler_bat", config->default_compiler_bat);
|
||||
config_feedback_string(scratch, &list, "default_flags_bat", config->default_flags_bat);
|
||||
config_feedback_string(scratch, &list, "default_compiler_sh", config->default_compiler_sh);
|
||||
config_feedback_string(scratch, &list, "default_flags_sh", config->default_flags_sh);
|
||||
|
||||
config_feedback_bool(scratch, &list, "lalt_lctrl_is_altgr", config->lalt_lctrl_is_altgr);
|
||||
|
||||
string_list_push_u8_lit(scratch, &list, "\n");
|
||||
String_Const_u8 message = string_list_flatten(scratch, list);
|
||||
print_message(app, message);
|
||||
end_temp(temp2);
|
||||
}
|
||||
|
||||
// Apply config
|
||||
//setup_built_in_mapping(app, config->mapping, &framework_mapping, mapid_global, mapid_file, mapid_code);
|
||||
change_mode(app, config->mode);
|
||||
|
|
|
@ -82,7 +82,7 @@ vars_get_nil(void){
|
|||
|
||||
function b32
|
||||
vars_is_nil(Variable_Handle var){
|
||||
return(var.ptr == &vars_nil);
|
||||
return(var.ptr == 0 || var.ptr == &vars_nil);
|
||||
}
|
||||
|
||||
function b32
|
||||
|
@ -90,6 +90,41 @@ vars_match(Variable_Handle a, Variable_Handle b){
|
|||
return(a.ptr == b.ptr);
|
||||
}
|
||||
|
||||
function Variable_Handle
|
||||
vars_first_child(Variable_Handle var){
|
||||
Variable_Handle result = {};
|
||||
if (var.ptr != 0){
|
||||
result.ptr = var.ptr->first;
|
||||
}
|
||||
else{
|
||||
result.ptr = &vars_nil;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Variable_Handle
|
||||
vars_next_sibling(Variable_Handle var){
|
||||
Variable_Handle result = {};
|
||||
if (var.ptr != 0){
|
||||
result.ptr = var.ptr->next;
|
||||
}
|
||||
else{
|
||||
result.ptr = &vars_nil;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String_ID
|
||||
vars_key_id_from_var(Variable_Handle var){
|
||||
return(var.ptr->key);
|
||||
}
|
||||
|
||||
function String_Const_u8
|
||||
vars_key_from_var(Arena *arena, Variable_Handle var){
|
||||
String_ID id = vars_key_id_from_var(var);
|
||||
String_Const_u8 result = vars_read_string(arena, id);
|
||||
return(result);
|
||||
}
|
||||
|
||||
function String_ID
|
||||
vars_string_id_from_var(Variable_Handle var){
|
||||
|
@ -233,5 +268,36 @@ vars_clear_keys(Variable_Handle var){
|
|||
}
|
||||
}
|
||||
|
||||
function void
|
||||
vars_print_indented(Application_Links *app, Variable_Handle var, i32 indent){
|
||||
Scratch_Block scratch(app);
|
||||
local_persist char spaces[] =
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" ";
|
||||
|
||||
String_Const_u8 var_key = vars_key_from_var(scratch, var);
|
||||
String_Const_u8 var_val = vars_string_from_var(scratch, var);
|
||||
|
||||
String_Const_u8 line = push_stringf(scratch, "%.*s%.*s: \"%.*s\"\n",
|
||||
clamp_top(indent, sizeof(spaces)), spaces,
|
||||
string_expand(var_key),
|
||||
string_expand(var_val));
|
||||
print_message(app, line);
|
||||
|
||||
i32 sub_indent = indent + 1;
|
||||
for (Variable_Handle sub = vars_first_child(var);
|
||||
!vars_is_nil(sub);
|
||||
sub = vars_next_sibling(sub)){
|
||||
vars_print_indented(app, sub, sub_indent);
|
||||
}
|
||||
}
|
||||
|
||||
function void
|
||||
vars_print(Application_Links *app, Variable_Handle var){
|
||||
vars_print_indented(app, var, 0);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
|
@ -36,7 +36,12 @@ function Variable_Handle vars_get_nil(void);
|
|||
function b32 vars_is_nil(Variable_Handle var);
|
||||
function b32 vars_match(Variable_Handle a, Variable_Handle b);
|
||||
|
||||
function Variable_Handle vars_first_child(Variable_Handle var);
|
||||
function Variable_Handle vars_next_sibling(Variable_Handle var);
|
||||
|
||||
function Variable_Handle vars_read_key(Variable_Handle var, String_ID key);
|
||||
function String_ID vars_key_id_from_var(Variable_Handle var);
|
||||
function String_Const_u8 vars_key_from_var(Arena *arena, Variable_Handle var);
|
||||
function String_ID vars_string_id_from_var(Variable_Handle var);
|
||||
function String_Const_u8 vars_string_from_var(Arena *arena, Variable_Handle var);
|
||||
|
||||
|
@ -46,6 +51,9 @@ function Variable_Handle vars_new_variable(Variable_Handle var, String_ID key);
|
|||
function Variable_Handle vars_new_variable(Variable_Handle var, String_ID key, String_ID string);
|
||||
function void vars_clear_keys(Variable_Handle var);
|
||||
|
||||
function void vars_print_indented(Application_Links *app, Variable_Handle var, i32 indent);
|
||||
function void vars_print(Application_Links *app, Variable_Handle var);
|
||||
|
||||
#endif //4CODER_VARIABLES_H
|
||||
|
||||
// BOTTOM
|
||||
|
|
|
@ -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, 1805 },
|
||||
{ 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, 1744 },
|
||||
{ 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 },
|
||||
|
|
Loading…
Reference in New Issue