Move all string config variables over to new config system
parent
a6c307944f
commit
2671dec536
|
@ -1340,9 +1340,6 @@ function void
|
|||
config_init_default(Config_Data *config){
|
||||
block_zero_struct(&config->code_exts);
|
||||
|
||||
config->mapping = SCu8(config->mapping_space, (u64)0);
|
||||
config->mode = SCu8(config->mode_space, (u64)0);
|
||||
|
||||
config->cursor_roundness = .45f;
|
||||
config->mark_thickness = 2.f;
|
||||
config->lister_roundness = .20f;
|
||||
|
@ -1352,21 +1349,7 @@ config_init_default(Config_Data *config){
|
|||
config->indent_width = 4;
|
||||
config->default_tab_width = 4;
|
||||
|
||||
config->default_theme_name = SCu8(config->default_theme_name_space, sizeof("4coder") - 1);
|
||||
block_copy(config->default_theme_name.str, "4coder", config->default_theme_name.size);
|
||||
|
||||
config->default_font_name = SCu8(config->default_font_name_space, (u64)0);
|
||||
config->default_font_size = 16;
|
||||
|
||||
config->default_compiler_bat = SCu8(config->default_compiler_bat_space, 2);
|
||||
block_copy(config->default_compiler_bat.str, "cl", 2);
|
||||
|
||||
config->default_flags_bat = SCu8(config->default_flags_bat_space, (u64)0);
|
||||
|
||||
config->default_compiler_sh = SCu8(config->default_compiler_sh_space, 3);
|
||||
block_copy(config->default_compiler_sh.str, "g++", 3);
|
||||
|
||||
config->default_flags_sh = SCu8(config->default_flags_sh_space, (u64)0);
|
||||
}
|
||||
|
||||
function Config*
|
||||
|
@ -1386,9 +1369,6 @@ config_parse__data(Application_Links *app, Arena *arena, String_Const_u8 file_na
|
|||
parse_extension_line_to_extension_list(app, arena, str);
|
||||
}
|
||||
|
||||
config_fixed_string_var(parsed, "mapping", 0, &config->mapping, config->mapping_space);
|
||||
config_fixed_string_var(parsed, "mode", 0, &config->mode, config->mode_space);
|
||||
|
||||
{
|
||||
i32 x = 0;
|
||||
if (config_int_var(parsed, "cursor_roundness", 0, &x)){
|
||||
|
@ -1407,21 +1387,7 @@ config_parse__data(Application_Links *app, Arena *arena, String_Const_u8 file_na
|
|||
config_int_var(parsed, "indent_width", 0, &config->indent_width);
|
||||
config_int_var(parsed, "default_tab_width", 0, &config->default_tab_width);
|
||||
|
||||
config_fixed_string_var(parsed, "default_theme_name", 0,
|
||||
&config->default_theme_name, config->default_theme_name_space);
|
||||
|
||||
config_fixed_string_var(parsed, "default_font_name", 0,
|
||||
&config->default_font_name, config->default_font_name_space);
|
||||
config_int_var(parsed, "default_font_size", 0, &config->default_font_size);
|
||||
|
||||
config_fixed_string_var(parsed, "default_compiler_bat", 0,
|
||||
&config->default_compiler_bat, config->default_compiler_bat_space);
|
||||
config_fixed_string_var(parsed, "default_flags_bat", 0,
|
||||
&config->default_flags_bat, config->default_flags_bat_space);
|
||||
config_fixed_string_var(parsed, "default_compiler_sh", 0,
|
||||
&config->default_compiler_sh, config->default_compiler_sh_space);
|
||||
config_fixed_string_var(parsed, "default_flags_sh", 0,
|
||||
&config->default_flags_sh, config->default_flags_sh_space);
|
||||
}
|
||||
|
||||
if (!success){
|
||||
|
@ -1580,17 +1546,13 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
|||
print_message(app, string_u8_litexpr("Using default config:\n"));
|
||||
Face_Description description = get_face_description(app, 0);
|
||||
if (description.font.file_name.str != 0){
|
||||
u64 size = Min(description.font.file_name.size, sizeof(config->default_font_name_space));
|
||||
block_copy(config->default_font_name_space, description.font.file_name.str, size);
|
||||
config->default_font_name.size = size;
|
||||
def_set_config_string(vars_save_string_lit("default_font_name"), description.font.file_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (config->default_font_name.size == 0){
|
||||
#define M "liberation-mono.ttf"
|
||||
block_copy(config->default_font_name_space, M, sizeof(M) - 1);
|
||||
config->default_font_name.size = sizeof(M) - 1;
|
||||
#undef M
|
||||
String_Const_u8 default_font_name = def_get_config_string(scratch, vars_save_string_lit("default_font_name"));
|
||||
if (default_font_name.size == 0){
|
||||
default_font_name = string_u8_litexpr("liberation-mono.ttf");
|
||||
}
|
||||
|
||||
// TODO(allen): this part seems especially weird now.
|
||||
|
@ -1598,12 +1560,14 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
|||
// not by a state that gets evaled and saved *now*!!
|
||||
|
||||
// Apply config
|
||||
change_mode(app, config->mode);
|
||||
String_Const_u8 mode = def_get_config_string(scratch, vars_save_string_lit("mode"));
|
||||
change_mode(app, mode);
|
||||
|
||||
b32 lalt_lctrl_is_altgr = def_get_config_b32(vars_save_string_lit("lalt_lctrl_is_altgr"));
|
||||
global_set_setting(app, GlobalSetting_LAltLCtrlIsAltGr, lalt_lctrl_is_altgr);
|
||||
|
||||
Color_Table *colors = get_color_table_by_name(config->default_theme_name);
|
||||
String_Const_u8 default_theme_name = def_get_config_string(scratch, vars_save_string_lit("default_theme_name"));
|
||||
Color_Table *colors = get_color_table_by_name(default_theme_name);
|
||||
set_active_color(colors);
|
||||
|
||||
Face_Description description = {};
|
||||
|
@ -1617,9 +1581,9 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
|||
b32 default_font_hinting = def_get_config_b32(vars_save_string_lit("default_font_hinting"));
|
||||
description.parameters.hinting = default_font_hinting || override_hinting;
|
||||
|
||||
description.font.file_name = config->default_font_name;
|
||||
description.font.file_name = default_font_name;
|
||||
if (!modify_global_face_by_description(app, description)){
|
||||
description.font.file_name = get_file_path_in_fonts_folder(scratch, config->default_font_name);
|
||||
description.font.file_name = get_file_path_in_fonts_folder(scratch, default_font_name);
|
||||
modify_global_face_by_description(app, description);
|
||||
}
|
||||
|
||||
|
|
|
@ -180,12 +180,6 @@ struct Config_Get_Result_List{
|
|||
struct Config_Data{
|
||||
String_Const_u8_Array code_exts;
|
||||
|
||||
u8 mapping_space[64];
|
||||
String_Const_u8 mapping;
|
||||
|
||||
u8 mode_space[64];
|
||||
String_Const_u8 mode;
|
||||
|
||||
f32 cursor_roundness;
|
||||
f32 mark_thickness;
|
||||
f32 lister_roundness;
|
||||
|
@ -195,24 +189,7 @@ struct Config_Data{
|
|||
i32 indent_width;
|
||||
i32 default_tab_width;
|
||||
|
||||
u8 default_theme_name_space[256];
|
||||
String_Const_u8 default_theme_name;
|
||||
|
||||
u8 default_font_name_space[256];
|
||||
String_Const_u8 default_font_name;
|
||||
i32 default_font_size;
|
||||
|
||||
u8 default_compiler_bat_space[256];
|
||||
String_Const_u8 default_compiler_bat;
|
||||
|
||||
u8 default_flags_bat_space[1024];
|
||||
String_Const_u8 default_flags_bat;
|
||||
|
||||
u8 default_compiler_sh_space[256];
|
||||
String_Const_u8 default_compiler_sh;
|
||||
|
||||
u8 default_flags_sh_space[1024];
|
||||
String_Const_u8 default_flags_sh;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
|
|
@ -614,13 +614,17 @@ default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_nam
|
|||
print_message(app, string_u8_litexpr(M));
|
||||
#undef M
|
||||
|
||||
Scratch_Block scratch(app);
|
||||
|
||||
load_config_and_apply(app, &global_config_arena, &global_config, override_font_size, override_hinting);
|
||||
|
||||
String_Const_u8 bindings_file_name = string_u8_litexpr("bindings.4coder");
|
||||
if (string_match(global_config.mapping, string_u8_litexpr("mac-default"))){
|
||||
String_Const_u8 mapping = def_get_config_string(scratch, vars_save_string_lit("mapping"));
|
||||
|
||||
if (string_match(mapping, string_u8_litexpr("mac-default"))){
|
||||
bindings_file_name = string_u8_litexpr("mac-bindings.4coder");
|
||||
}
|
||||
else if (OS_MAC && string_match(global_config.mapping, string_u8_litexpr("choose"))){
|
||||
else if (OS_MAC && string_match(mapping, string_u8_litexpr("choose"))){
|
||||
bindings_file_name = string_u8_litexpr("mac-bindings.4coder");
|
||||
}
|
||||
|
||||
|
@ -633,11 +637,10 @@ default_4coder_initialize(Application_Links *app, String_Const_u8_Array file_nam
|
|||
setup_essential_mapping(&framework_mapping, global_map_id, file_map_id, code_map_id);
|
||||
}
|
||||
else{
|
||||
setup_built_in_mapping(app, global_config.mapping, &framework_mapping, global_map_id, file_map_id, code_map_id);
|
||||
setup_built_in_mapping(app, mapping, &framework_mapping, global_map_id, file_map_id, code_map_id);
|
||||
}
|
||||
|
||||
// open command line files
|
||||
Scratch_Block scratch(app);
|
||||
String_Const_u8 hot_directory = push_hot_directory(app, scratch);
|
||||
for (i32 i = 0; i < file_names.count; i += 1){
|
||||
Temp_Memory_Block temp(scratch);
|
||||
|
|
|
@ -1278,9 +1278,10 @@ project_setup_scripts__generic(Application_Links *app, b32 do_project_file, b32
|
|||
// Generate Scripts
|
||||
if (do_bat_script){
|
||||
if (!status.bat_exists){
|
||||
if (!project_generate_bat_script(scratch,
|
||||
global_config.default_flags_bat,
|
||||
global_config.default_compiler_bat,
|
||||
String_Const_u8 default_flags_bat = def_get_config_string(scratch, vars_save_string_lit("default_flags_bat"));
|
||||
String_Const_u8 default_compiler_bat = def_get_config_string(scratch, vars_save_string_lit("default_compiler_bat"));
|
||||
|
||||
if (!project_generate_bat_script(scratch, default_flags_bat, default_compiler_bat,
|
||||
script_path, keys.script_file,
|
||||
keys.code_file, keys.output_dir, keys.binary_file)){
|
||||
print_message(app, string_u8_litexpr("could not create build.bat for new project\n"));
|
||||
|
@ -1293,9 +1294,9 @@ project_setup_scripts__generic(Application_Links *app, b32 do_project_file, b32
|
|||
|
||||
if (do_sh_script){
|
||||
if (!status.bat_exists){
|
||||
if (!project_generate_sh_script(scratch,
|
||||
global_config.default_flags_sh,
|
||||
global_config.default_compiler_sh,
|
||||
String_Const_u8 default_flags_sh = def_get_config_string(scratch, vars_save_string_lit("default_flags_sh"));
|
||||
String_Const_u8 default_compiler_sh = def_get_config_string(scratch, vars_save_string_lit("default_compiler_sh"));
|
||||
if (!project_generate_sh_script(scratch, default_flags_sh, default_compiler_sh,
|
||||
script_path, keys.script_file,
|
||||
keys.code_file, keys.output_dir, keys.binary_file)){
|
||||
print_message(app, string_u8_litexpr("could not create build.sh for new project\n"));
|
||||
|
|
|
@ -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, 963 },
|
||||
{ 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, 1652 },
|
||||
{ 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, 1616 },
|
||||
{ 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, 535 },
|
||||
{ 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, 547 },
|
||||
{ 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, 1495 },
|
||||
|
@ -436,7 +436,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 },
|
||||
{ PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 },
|
||||
{ PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "W:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 },
|
||||
{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1389 },
|
||||
{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1390 },
|
||||
{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 971 },
|
||||
{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 997 },
|
||||
{ PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1282 },
|
||||
|
@ -477,10 +477,10 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 },
|
||||
{ PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 499 },
|
||||
{ PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 493 },
|
||||
{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1338 },
|
||||
{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1350 },
|
||||
{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1344 },
|
||||
{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1331 },
|
||||
{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1339 },
|
||||
{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1351 },
|
||||
{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1345 },
|
||||
{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1332 },
|
||||
{ PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 },
|
||||
{ PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 },
|
||||
{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 993 },
|
||||
|
|
Loading…
Reference in New Issue