Sort away project v1 -> v2 conversion code
This commit is contained in:
parent
b8e2d60e2c
commit
3beb070c05
|
@ -56,6 +56,7 @@
|
|||
#include "4coder_jump_sticky.h"
|
||||
#include "4coder_jump_lister.h"
|
||||
#include "4coder_project_commands.h"
|
||||
#include "4coder_prj_v1.h"
|
||||
#include "4coder_function_list.h"
|
||||
#include "4coder_scope_commands.h"
|
||||
#include "4coder_combined_write_commands.h"
|
||||
|
@ -127,6 +128,7 @@
|
|||
#include "4coder_cli_command.cpp"
|
||||
#include "4coder_build_commands.cpp"
|
||||
#include "4coder_project_commands.cpp"
|
||||
#include "4coder_prj_v1.cpp"
|
||||
#include "4coder_function_list.cpp"
|
||||
#include "4coder_scope_commands.cpp"
|
||||
#include "4coder_combined_write_commands.cpp"
|
||||
|
|
|
@ -0,0 +1,506 @@
|
|||
/*
|
||||
4coder_prj_v1.cpp - parsing and converting v0 and v1 projects
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Project v0-v1 Functions
|
||||
|
||||
function void
|
||||
prj_v1_parse_pattern_list(Arena *arena, Config *parsed, char *name, Prj_Pattern_List *list_out){
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, name, 0, &compound)){
|
||||
Config_Get_Result_List list = typed_string_array_reference_list(arena, parsed, compound);
|
||||
for (Config_Get_Result_Node *cfg_node = list.first;
|
||||
cfg_node != 0;
|
||||
cfg_node = cfg_node->next){
|
||||
Prj_Pattern_Node *node = push_array(arena, Prj_Pattern_Node, 1);
|
||||
sll_queue_push(list_out->first, list_out->last, node);
|
||||
list_out->count += 1;
|
||||
String8 str = push_string_copy(arena, cfg_node->result.string);
|
||||
node->pattern.absolutes = string_split_wildcards(arena, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Prj_V1_OS_Match_Level
|
||||
prj_v1_parse_os_match(String8 str, String8 this_os_str){
|
||||
Prj_V1_OS_Match_Level result = PrjV1OSMatchLevel_NoMatch;
|
||||
if (string_match(str, this_os_str)){
|
||||
result = PrjV1OSMatchLevel_ActiveMatch;
|
||||
}
|
||||
else if (string_match(str, string_u8_litexpr("all"))){
|
||||
result = PrjV1OSMatchLevel_ActiveMatch;
|
||||
}
|
||||
else if (string_match(str, string_u8_litexpr("default"))){
|
||||
result = PrjV1OSMatchLevel_PassiveMatch;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Prj_V1*
|
||||
prj_v1_parse_from_config(Application_Links *app, Arena *arena, String8 dir, Config *parsed){
|
||||
Prj_V1 *project = push_array_zero(arena, Prj_V1, 1);
|
||||
|
||||
// Set new project directory
|
||||
project->dir = push_string_copy(arena, dir);
|
||||
|
||||
// project_name
|
||||
{
|
||||
String8 str = {};
|
||||
if (config_string_var(parsed, "project_name", 0, &str)){
|
||||
project->name = push_string_copy(arena, str);
|
||||
}
|
||||
else{
|
||||
project->name = SCu8("");
|
||||
}
|
||||
}
|
||||
|
||||
// patterns
|
||||
prj_v1_parse_pattern_list(arena, parsed, "patterns", &project->pattern_list);
|
||||
|
||||
// blacklist_patterns
|
||||
prj_v1_parse_pattern_list(arena, parsed, "blacklist_patterns", &project->blacklist_pattern_list);
|
||||
|
||||
// load_paths
|
||||
{
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, "load_paths", 0, &compound)){
|
||||
b32 found_match = false;
|
||||
Config_Compound *best_paths = 0;
|
||||
|
||||
for (i32 i = 0;; ++i){
|
||||
Config_Iteration_Step_Result result = typed_array_iteration_step(parsed, compound, ConfigRValueType_Compound, i);
|
||||
if (result.step == Iteration_Skip){
|
||||
continue;
|
||||
}
|
||||
else if (result.step == Iteration_Quit){
|
||||
break;
|
||||
}
|
||||
Config_Compound *paths_option = result.get.compound;
|
||||
|
||||
Config_Compound *paths = 0;
|
||||
if (config_compound_compound_member(parsed, paths_option, "paths", 0, &paths)){
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, paths_option, "os", 1, &str)){
|
||||
Prj_V1_OS_Match_Level r = prj_v1_parse_os_match(str, string_u8_litexpr(OS_NAME));
|
||||
if (r == PrjV1OSMatchLevel_ActiveMatch){
|
||||
found_match = true;
|
||||
best_paths = paths;
|
||||
break;
|
||||
}
|
||||
else if (r == PrjV1OSMatchLevel_PassiveMatch){
|
||||
if (!found_match){
|
||||
found_match = true;
|
||||
best_paths = paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found_match){
|
||||
Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, best_paths);
|
||||
|
||||
project->load_path_array.paths = push_array(arena, Prj_V1_File_Load_Path, list.count);
|
||||
project->load_path_array.count = list.count;
|
||||
|
||||
Prj_V1_File_Load_Path *dst = project->load_path_array.paths;
|
||||
for (Config_Get_Result_Node *node = list.first;
|
||||
node != 0;
|
||||
node = node->next, ++dst){
|
||||
Config_Compound *src = node->result.compound;
|
||||
block_zero_struct(dst);
|
||||
dst->recursive = true;
|
||||
dst->relative = true;
|
||||
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, src, "path", 0, &str)){
|
||||
dst->path = push_string_copy(arena, str);
|
||||
}
|
||||
|
||||
config_compound_bool_member(parsed, src, "recursive", 1, &dst->recursive);
|
||||
config_compound_bool_member(parsed, src, "relative", 2, &dst->relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// command_list
|
||||
{
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, "command_list", 0, &compound)){
|
||||
Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, compound);
|
||||
|
||||
project->command_array.commands = push_array(arena, Prj_V1_Command, list.count);
|
||||
project->command_array.count = list.count;
|
||||
|
||||
Prj_V1_Command *dst = project->command_array.commands;
|
||||
for (Config_Get_Result_Node *node = list.first;
|
||||
node != 0;
|
||||
node = node->next, ++dst){
|
||||
u8 *pos = node->result.pos;
|
||||
Config_Compound *src = node->result.compound;
|
||||
block_zero_struct(dst);
|
||||
|
||||
b32 can_emit_command = true;
|
||||
|
||||
Config_Get_Result cmd_result = {};
|
||||
Config_Compound *cmd_set = 0;
|
||||
u8 *cmd_pos = 0;
|
||||
String8 cmd_str = {};
|
||||
String8 out = {};
|
||||
b32 footer_panel = false;
|
||||
b32 save_dirty_files = true;
|
||||
b32 cursor_at_end = false;
|
||||
String8 name = {};
|
||||
|
||||
if (!config_compound_string_member(parsed, src, "name", 0, &name)){
|
||||
can_emit_command = false;
|
||||
def_config_push_error(arena, parsed, pos, "a command must have a string type name member");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
cmd_result = config_compound_member(parsed, src, string_u8_litexpr("cmd"), 1);
|
||||
if (cmd_result.success && cmd_result.type == ConfigRValueType_Compound){
|
||||
cmd_set = cmd_result.compound;
|
||||
cmd_pos = cmd_result.pos;
|
||||
}
|
||||
else{
|
||||
can_emit_command = false;
|
||||
def_config_push_error(arena, parsed, pos, "a command must have an array type cmd member");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
can_emit_command = false;
|
||||
for (i32 j = 0;; ++j){
|
||||
Config_Iteration_Step_Result result = typed_array_iteration_step(parsed, cmd_set, ConfigRValueType_Compound, j);
|
||||
if (result.step == Iteration_Skip){
|
||||
continue;
|
||||
}
|
||||
else if (result.step == Iteration_Quit){
|
||||
break;
|
||||
}
|
||||
Config_Compound *cmd_option = result.get.compound;
|
||||
|
||||
String8 cmd = {};
|
||||
if (config_compound_string_member(parsed, cmd_option, "cmd", 0, &cmd)){
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, cmd_option, "os", 1, &str)){
|
||||
Prj_V1_OS_Match_Level r = prj_v1_parse_os_match(str, string_u8_litexpr(OS_NAME));
|
||||
if (r == PrjV1OSMatchLevel_ActiveMatch){
|
||||
can_emit_command = true;
|
||||
cmd_str = cmd;
|
||||
break;
|
||||
}
|
||||
else if (r == PrjV1OSMatchLevel_PassiveMatch){
|
||||
if (!can_emit_command){
|
||||
can_emit_command = true;
|
||||
cmd_str = cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!can_emit_command){
|
||||
def_config_push_error(arena, parsed, cmd_pos, "no usable command strings found in cmd");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
config_compound_string_member(parsed, src, "out", 2, &out);
|
||||
config_compound_bool_member(parsed, src, "footer_panel", 3, &footer_panel);
|
||||
config_compound_bool_member(parsed, src, "save_dirty_files", 4,
|
||||
&save_dirty_files);
|
||||
config_compound_bool_member(parsed, src, "cursor_at_end", 5,
|
||||
&cursor_at_end);
|
||||
|
||||
dst->name = push_string_copy(arena, name);
|
||||
dst->cmd = push_string_copy(arena, cmd_str);
|
||||
dst->out = push_string_copy(arena, out);
|
||||
dst->footer_panel = footer_panel;
|
||||
dst->save_dirty_files = save_dirty_files;
|
||||
dst->cursor_at_end = cursor_at_end;
|
||||
|
||||
finish_command:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fkey_command
|
||||
{
|
||||
for (i32 i = 1; i <= 16; ++i){
|
||||
String8 name = {};
|
||||
i32 index = -1;
|
||||
if (config_string_var(parsed, "fkey_command", i, &name)){
|
||||
i32 count = project->command_array.count;
|
||||
Prj_V1_Command *command_ptr = project->command_array.commands;
|
||||
for (i32 j = 0; j < count; ++j, ++command_ptr){
|
||||
if (string_match(command_ptr->name, name)){
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
project->fkey_commands[i - 1] = index;
|
||||
}
|
||||
}
|
||||
|
||||
project->loaded = true;
|
||||
return(project);
|
||||
}
|
||||
|
||||
#if 0
|
||||
function void
|
||||
project_v1_deep_copy__pattern_list(Arena *arena, Prj_Pattern_List *src_list, Prj_Pattern_List *dst_list){
|
||||
for (Prj_Pattern_Node *src_node = src_list->first;
|
||||
src_node != 0;
|
||||
src_node = src_node->next){
|
||||
Prj_Pattern_Node *dst_node = push_array(arena, Prj_Pattern_Node, 1);
|
||||
sll_queue_push(dst_list->first, dst_list->last, dst_node);
|
||||
dst_list->count += 1;
|
||||
|
||||
for (String8Node *node = src_node->pattern.absolutes.first;
|
||||
node != 0;
|
||||
node = node->next){
|
||||
String8 string = push_string_copy(arena, node->string);
|
||||
string_list_push(arena, &dst_node->pattern.absolutes, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Prj
|
||||
project_v1_deep_copy__inner(Arena *arena, Prj *project){
|
||||
Prj result = {};
|
||||
result.dir = push_string_copy(arena, project->dir);
|
||||
result.name = push_string_copy(arena, project->name);
|
||||
project_deep_copy__pattern_list(arena, &project->pattern_list, &result.pattern_list);
|
||||
project_deep_copy__pattern_list(arena, &project->blacklist_pattern_list, &result.blacklist_pattern_list);
|
||||
|
||||
{
|
||||
i32 path_count = project->load_path_array.count;
|
||||
result.load_path_array.paths = push_array(arena, Prj_File_Load_Path, path_count);
|
||||
result.load_path_array.count = path_count;
|
||||
|
||||
Prj_File_Load_Path *dst = result.load_path_array.paths;
|
||||
Prj_File_Load_Path *src = project->load_path_array.paths;
|
||||
for (i32 i = 0; i < path_count; ++i, ++dst, ++src){
|
||||
dst->path = push_string_copy(arena, src->path);
|
||||
dst->recursive = src->recursive;
|
||||
dst->relative = src->relative;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
i32 command_count = project->command_array.count;
|
||||
result.command_array.commands = push_array_zero(arena, Prj_Command, command_count);
|
||||
result.command_array.count = command_count;
|
||||
|
||||
Prj_Command *dst = result.command_array.commands;
|
||||
Prj_Command *src = project->command_array.commands;
|
||||
for (i32 i = 0; i < command_count; ++i, ++dst, ++src){
|
||||
if (src->name.str != 0){
|
||||
dst->name = push_string_copy(arena, src->name);
|
||||
}
|
||||
if (src->cmd.str != 0){
|
||||
dst->cmd = push_string_copy(arena, src->cmd);
|
||||
}
|
||||
if (src->out.str != 0){
|
||||
dst->out = push_string_copy(arena, src->out);
|
||||
}
|
||||
dst->footer_panel = src->footer_panel;
|
||||
dst->save_dirty_files = src->save_dirty_files;
|
||||
dst->cursor_at_end = src->cursor_at_end;
|
||||
}
|
||||
}
|
||||
|
||||
block_copy_array(result.fkey_commands, project->fkey_commands);
|
||||
|
||||
result.loaded = true;
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Prj
|
||||
project_v1_deep_copy(Arena *arena, Prj *project){
|
||||
Temp_Memory restore_point = begin_temp(arena);
|
||||
Prj result = project_deep_copy__inner(arena, project);
|
||||
if (!result.loaded){
|
||||
end_temp(restore_point);
|
||||
block_zero_struct(&result);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
#endif
|
||||
|
||||
// NOTE(allen): string list join ("flatten") doesn't really work... :(
|
||||
function String8
|
||||
prj_v1_join_pattern_string(Arena *arena, String8List list){
|
||||
String8 pattern_string = {};
|
||||
pattern_string.size = list.total_size + list.node_count - 1;
|
||||
pattern_string.str = push_array(arena, u8, pattern_string.size + 1);
|
||||
u8 *ptr = pattern_string.str;
|
||||
String8Node *node = list.first;
|
||||
if (node != 0){
|
||||
for (;;){
|
||||
block_copy(ptr, node->string.str, node->string.size);
|
||||
ptr += node->string.size;
|
||||
node = node->next;
|
||||
if (node == 0){
|
||||
break;
|
||||
}
|
||||
*ptr = '*';
|
||||
ptr += 1;
|
||||
}
|
||||
}
|
||||
pattern_string.str[pattern_string.size] = 0;
|
||||
return(pattern_string);
|
||||
}
|
||||
|
||||
function String8
|
||||
prj_v1_sanitize_string(Arena *arena, String8 string){
|
||||
String8 result = {};
|
||||
|
||||
if (string.size > 0){
|
||||
result.size = string.size;
|
||||
result.str = push_array(arena, u8, result.size + 2);
|
||||
|
||||
u8 *in = string.str;
|
||||
u8 *out = result.str;
|
||||
|
||||
if (character_is_base10(*in)){
|
||||
*out = '_';
|
||||
out += 1;
|
||||
result.size += 1;
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < string.size; i += 1, in += 1, out += 1){
|
||||
u8 c = *in;
|
||||
if (!character_is_alpha_numeric(c)){
|
||||
c = '_';
|
||||
}
|
||||
*out = c;
|
||||
}
|
||||
|
||||
result.str[result.size] = 0;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Variable_Handle
|
||||
prj_v1_to_v2(Application_Links *app, String8 dir, Config *parsed){
|
||||
Scratch_Block scratch(app);
|
||||
|
||||
Prj_V1 *project = prj_v1_parse_from_config(app, scratch, dir, parsed);
|
||||
|
||||
String_ID project_id = vars_save_string_lit("prj_config");
|
||||
String_ID version_id = vars_save_string(str8_lit("version"));
|
||||
String_ID project_name_id = vars_save_string(str8_lit("project_name"));
|
||||
String_ID patterns_id = vars_save_string(str8_lit("patterns"));
|
||||
String_ID blacklist_patterns_id = vars_save_string(str8_lit("blacklist_patterns"));
|
||||
|
||||
String_ID load_paths_id = vars_save_string(str8_lit("load_paths"));
|
||||
String_ID path_id = vars_save_string(str8_lit("path"));
|
||||
String_ID recursive_id = vars_save_string(str8_lit("recursive"));
|
||||
String_ID relative_id = vars_save_string(str8_lit("relative"));
|
||||
String_ID true_id = vars_save_string(str8_lit("true"));
|
||||
String_ID false_id = vars_save_string(str8_lit("false"));
|
||||
String_ID commands_id = vars_save_string(str8_lit("commands"));
|
||||
|
||||
String_ID out_id = vars_save_string(str8_lit("out"));
|
||||
String_ID footer_panel_id = vars_save_string(str8_lit("footer_panel"));
|
||||
String_ID save_dirty_files_id = vars_save_string(str8_lit("save_dirty_files"));
|
||||
String_ID cursor_at_end_id = vars_save_string(str8_lit("cursor_at_end"));
|
||||
|
||||
String_ID fkey_command_id = vars_save_string(str8_lit("fkey_command"));
|
||||
|
||||
String_ID os_id = vars_save_string(str8_lit(OS_NAME));;
|
||||
|
||||
Variable_Handle proj_var = vars_new_variable(vars_get_root(), project_id, vars_save_string(parsed->file_name));
|
||||
|
||||
if (parsed->version != 0){
|
||||
String8 version_str = push_stringf(scratch, "%d", *parsed->version);
|
||||
vars_new_variable(proj_var, version_id, vars_save_string(version_str));
|
||||
}
|
||||
|
||||
vars_new_variable(proj_var, project_name_id, vars_save_string(project->name));
|
||||
|
||||
// NOTE(allen): Load Pattern
|
||||
struct PatternVars{
|
||||
String_ID id;
|
||||
Prj_Pattern_List list;
|
||||
};
|
||||
PatternVars pattern_vars[] = {
|
||||
{ patterns_id, project-> pattern_list},
|
||||
{blacklist_patterns_id, project->blacklist_pattern_list},
|
||||
};
|
||||
|
||||
PatternVars *pattern_var = pattern_vars;
|
||||
PatternVars *opl = pattern_vars + ArrayCount(pattern_vars);
|
||||
for (; pattern_var < opl; pattern_var += 1){
|
||||
Variable_Handle patterns = vars_new_variable(proj_var, pattern_var->id);
|
||||
|
||||
i32 i = 0;
|
||||
for (Prj_Pattern_Node *node = pattern_var->list.first;
|
||||
node != 0;
|
||||
node = node->next, i += 1){
|
||||
String8 pattern_string = prj_v1_join_pattern_string(scratch, node->pattern.absolutes);
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
String_ID pattern_id = vars_save_string(pattern_string);
|
||||
vars_new_variable(patterns, key, pattern_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): Load Paths
|
||||
{
|
||||
Variable_Handle load_paths = vars_new_variable(proj_var, load_paths_id);
|
||||
Variable_Handle os_var = vars_new_variable(load_paths, os_id);
|
||||
i32 count = project->load_path_array.count;
|
||||
Prj_V1_File_Load_Path *load_path = project->load_path_array.paths;
|
||||
for (i32 i = 0; i < count; i += 1, load_path += 1){
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
Variable_Handle path_var = vars_new_variable(os_var, key);
|
||||
vars_new_variable(path_var, path_id, vars_save_string(load_path->path));
|
||||
vars_new_variable(path_var, recursive_id, load_path->recursive?true_id:false_id);
|
||||
vars_new_variable(path_var, relative_id, load_path->recursive?true_id:false_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): Commands
|
||||
{
|
||||
Variable_Handle cmd_list_var = vars_new_variable(proj_var, commands_id);
|
||||
i32 count = project->command_array.count;
|
||||
Prj_V1_Command *cmd = project->command_array.commands;
|
||||
for (i32 i = 0; i < count; i += 1, cmd += 1){
|
||||
String8 cmd_name = prj_v1_sanitize_string(scratch, cmd->name);
|
||||
Variable_Handle cmd_var = vars_new_variable(cmd_list_var, vars_save_string(cmd_name));
|
||||
vars_new_variable(cmd_var, os_id, vars_save_string(cmd->cmd));
|
||||
vars_new_variable(cmd_var, out_id, vars_save_string(cmd->out));
|
||||
vars_new_variable(cmd_var, footer_panel_id, cmd->footer_panel?true_id:false_id);
|
||||
vars_new_variable(cmd_var, save_dirty_files_id, cmd->save_dirty_files?true_id:false_id);
|
||||
vars_new_variable(cmd_var, cursor_at_end_id, cmd->cursor_at_end?true_id:false_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): FKey Commands
|
||||
{
|
||||
Variable_Handle fkeys_var = vars_new_variable(proj_var, fkey_command_id);
|
||||
for (i32 i = 0; i < 16; i += 1){
|
||||
i32 cmd_index = project->fkey_commands[i];
|
||||
if (0 <= cmd_index && cmd_index < project->command_array.count){
|
||||
Prj_V1_Command *cmd = project->command_array.commands + cmd_index;
|
||||
if (cmd->name.size > 0){
|
||||
String8 cmd_name = prj_v1_sanitize_string(scratch, cmd->name);
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
String_ID val = vars_save_string(cmd_name);
|
||||
vars_new_variable(fkeys_var, key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(proj_var);
|
||||
}
|
||||
|
||||
// BOTTOM
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
4coder_prj_v1.h - type header paired with 4coder_prj_v1.cpp
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#ifndef FCODER_PRJ_V1_H
|
||||
#define FCODER_PRJ_V1_H
|
||||
|
||||
///////////////////////////////
|
||||
// NOTE(allen): Project v0-v1 Structure
|
||||
|
||||
struct Prj_V1_File_Load_Path{
|
||||
String8 path;
|
||||
b32 recursive;
|
||||
b32 relative;
|
||||
};
|
||||
|
||||
struct Prj_V1_File_Load_Path_Array{
|
||||
Prj_V1_File_Load_Path *paths;
|
||||
i32 count;
|
||||
};
|
||||
|
||||
struct Prj_V1_Command{
|
||||
String8 name;
|
||||
String8 cmd;
|
||||
String8 out;
|
||||
b32 footer_panel;
|
||||
b32 save_dirty_files;
|
||||
b32 cursor_at_end;
|
||||
};
|
||||
|
||||
struct Prj_V1_Command_Array{
|
||||
Prj_V1_Command *commands;
|
||||
i32 count;
|
||||
};
|
||||
|
||||
struct Prj_V1{
|
||||
b32 loaded;
|
||||
|
||||
String8 dir;
|
||||
String8 name;
|
||||
|
||||
Prj_Pattern_List pattern_list;
|
||||
Prj_Pattern_List blacklist_pattern_list;
|
||||
Prj_V1_File_Load_Path_Array load_path_array;
|
||||
Prj_V1_Command_Array command_array;
|
||||
|
||||
i32 fkey_commands[16];
|
||||
};
|
||||
|
||||
enum Prj_V1_OS_Match_Level{
|
||||
PrjV1OSMatchLevel_NoMatch = 0,
|
||||
PrjV1OSMatchLevel_PassiveMatch = 1,
|
||||
PrjV1OSMatchLevel_ActiveMatch = 2,
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Project v0-v1 -> v2 Function
|
||||
|
||||
function Variable_Handle prj_v1_to_v2(Application_Links *app, String8 dir, Config *parsed);
|
||||
|
||||
|
||||
#endif //4CODER_PRJ_V1_H
|
||||
|
||||
// BOTTOM
|
|
@ -166,501 +166,6 @@ prj_open_all_files_with_ext_in_hot(Application_Links *app, String8Array array, P
|
|||
prj_open_files_pattern_filter(app, hot, whitelist, blacklist, flags);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Project Parse
|
||||
|
||||
function void
|
||||
prj_parse_pattern_list(Arena *arena, Config *parsed, char *root_variable_name, Prj_Pattern_List *list_out){
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, root_variable_name, 0, &compound)){
|
||||
Config_Get_Result_List list = typed_string_array_reference_list(arena, parsed, compound);
|
||||
for (Config_Get_Result_Node *cfg_node = list.first;
|
||||
cfg_node != 0;
|
||||
cfg_node = cfg_node->next){
|
||||
Prj_Pattern_Node *node = push_array(arena, Prj_Pattern_Node, 1);
|
||||
sll_queue_push(list_out->first, list_out->last, node);
|
||||
list_out->count += 1;
|
||||
String8 str = push_string_copy(arena, cfg_node->result.string);
|
||||
node->pattern.absolutes = string_split_wildcards(arena, str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Prj_OS_Match_Level
|
||||
prj_parse_v1_os_match(String8 str, String8 this_os_str){
|
||||
Prj_OS_Match_Level result = PrjOSMatchLevel_NoMatch;
|
||||
if (string_match(str, this_os_str)){
|
||||
result = PrjOSMatchLevel_ActiveMatch;
|
||||
}
|
||||
else if (string_match(str, string_u8_litexpr("all"))){
|
||||
result = PrjOSMatchLevel_ActiveMatch;
|
||||
}
|
||||
else if (string_match(str, string_u8_litexpr("default"))){
|
||||
result = PrjOSMatchLevel_PassiveMatch;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Prj*
|
||||
prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root_dir, Config *parsed){
|
||||
Prj *project = push_array_zero(arena, Prj, 1);
|
||||
|
||||
// Set new project directory
|
||||
project->dir = push_string_copy(arena, root_dir);
|
||||
|
||||
// project_name
|
||||
{
|
||||
String8 str = {};
|
||||
if (config_string_var(parsed, "project_name", 0, &str)){
|
||||
project->name = push_string_copy(arena, str);
|
||||
}
|
||||
else{
|
||||
project->name = SCu8("");
|
||||
}
|
||||
}
|
||||
|
||||
// patterns
|
||||
prj_parse_pattern_list(arena, parsed, "patterns", &project->pattern_list);
|
||||
|
||||
// blacklist_patterns
|
||||
prj_parse_pattern_list(arena, parsed, "blacklist_patterns", &project->blacklist_pattern_list);
|
||||
|
||||
// load_paths
|
||||
{
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, "load_paths", 0, &compound)){
|
||||
b32 found_match = false;
|
||||
Config_Compound *best_paths = 0;
|
||||
|
||||
for (i32 i = 0;; ++i){
|
||||
Config_Iteration_Step_Result result = typed_array_iteration_step(parsed, compound, ConfigRValueType_Compound, i);
|
||||
if (result.step == Iteration_Skip){
|
||||
continue;
|
||||
}
|
||||
else if (result.step == Iteration_Quit){
|
||||
break;
|
||||
}
|
||||
Config_Compound *paths_option = result.get.compound;
|
||||
|
||||
Config_Compound *paths = 0;
|
||||
if (config_compound_compound_member(parsed, paths_option, "paths", 0, &paths)){
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, paths_option, "os", 1, &str)){
|
||||
Prj_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME));
|
||||
if (r == PrjOSMatchLevel_ActiveMatch){
|
||||
found_match = true;
|
||||
best_paths = paths;
|
||||
break;
|
||||
}
|
||||
else if (r == PrjOSMatchLevel_PassiveMatch){
|
||||
if (!found_match){
|
||||
found_match = true;
|
||||
best_paths = paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found_match){
|
||||
Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, best_paths);
|
||||
|
||||
project->load_path_array.paths = push_array(arena, Prj_File_Load_Path, list.count);
|
||||
project->load_path_array.count = list.count;
|
||||
|
||||
Prj_File_Load_Path *dst = project->load_path_array.paths;
|
||||
for (Config_Get_Result_Node *node = list.first;
|
||||
node != 0;
|
||||
node = node->next, ++dst){
|
||||
Config_Compound *src = node->result.compound;
|
||||
block_zero_struct(dst);
|
||||
dst->recursive = true;
|
||||
dst->relative = true;
|
||||
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, src, "path", 0, &str)){
|
||||
dst->path = push_string_copy(arena, str);
|
||||
}
|
||||
|
||||
config_compound_bool_member(parsed, src, "recursive", 1, &dst->recursive);
|
||||
config_compound_bool_member(parsed, src, "relative", 2, &dst->relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// command_list
|
||||
{
|
||||
Config_Compound *compound = 0;
|
||||
if (config_compound_var(parsed, "command_list", 0, &compound)){
|
||||
Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, compound);
|
||||
|
||||
project->command_array.commands = push_array(arena, Prj_Command, list.count);
|
||||
project->command_array.count = list.count;
|
||||
|
||||
Prj_Command *dst = project->command_array.commands;
|
||||
for (Config_Get_Result_Node *node = list.first;
|
||||
node != 0;
|
||||
node = node->next, ++dst){
|
||||
u8 *pos = node->result.pos;
|
||||
Config_Compound *src = node->result.compound;
|
||||
block_zero_struct(dst);
|
||||
|
||||
b32 can_emit_command = true;
|
||||
|
||||
Config_Get_Result cmd_result = {};
|
||||
Config_Compound *cmd_set = 0;
|
||||
u8 *cmd_pos = 0;
|
||||
String8 cmd_str = {};
|
||||
String8 out = {};
|
||||
b32 footer_panel = false;
|
||||
b32 save_dirty_files = true;
|
||||
b32 cursor_at_end = false;
|
||||
String8 name = {};
|
||||
|
||||
if (!config_compound_string_member(parsed, src, "name", 0, &name)){
|
||||
can_emit_command = false;
|
||||
def_config_push_error(arena, parsed, pos, "a command must have a string type name member");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
cmd_result = config_compound_member(parsed, src, string_u8_litexpr("cmd"), 1);
|
||||
if (cmd_result.success && cmd_result.type == ConfigRValueType_Compound){
|
||||
cmd_set = cmd_result.compound;
|
||||
cmd_pos = cmd_result.pos;
|
||||
}
|
||||
else{
|
||||
can_emit_command = false;
|
||||
def_config_push_error(arena, parsed, pos, "a command must have an array type cmd member");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
can_emit_command = false;
|
||||
for (i32 j = 0;; ++j){
|
||||
Config_Iteration_Step_Result result = typed_array_iteration_step(parsed, cmd_set, ConfigRValueType_Compound, j);
|
||||
if (result.step == Iteration_Skip){
|
||||
continue;
|
||||
}
|
||||
else if (result.step == Iteration_Quit){
|
||||
break;
|
||||
}
|
||||
Config_Compound *cmd_option = result.get.compound;
|
||||
|
||||
String8 cmd = {};
|
||||
if (config_compound_string_member(parsed, cmd_option, "cmd", 0, &cmd)){
|
||||
String8 str = {};
|
||||
if (config_compound_string_member(parsed, cmd_option, "os", 1, &str)){
|
||||
Prj_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME));
|
||||
if (r == PrjOSMatchLevel_ActiveMatch){
|
||||
can_emit_command = true;
|
||||
cmd_str = cmd;
|
||||
break;
|
||||
}
|
||||
else if (r == PrjOSMatchLevel_PassiveMatch){
|
||||
if (!can_emit_command){
|
||||
can_emit_command = true;
|
||||
cmd_str = cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!can_emit_command){
|
||||
def_config_push_error(arena, parsed, cmd_pos, "no usable command strings found in cmd");
|
||||
goto finish_command;
|
||||
}
|
||||
|
||||
config_compound_string_member(parsed, src, "out", 2, &out);
|
||||
config_compound_bool_member(parsed, src, "footer_panel", 3, &footer_panel);
|
||||
config_compound_bool_member(parsed, src, "save_dirty_files", 4,
|
||||
&save_dirty_files);
|
||||
config_compound_bool_member(parsed, src, "cursor_at_end", 5,
|
||||
&cursor_at_end);
|
||||
|
||||
dst->name = push_string_copy(arena, name);
|
||||
dst->cmd = push_string_copy(arena, cmd_str);
|
||||
dst->out = push_string_copy(arena, out);
|
||||
dst->footer_panel = footer_panel;
|
||||
dst->save_dirty_files = save_dirty_files;
|
||||
dst->cursor_at_end = cursor_at_end;
|
||||
|
||||
finish_command:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fkey_command
|
||||
{
|
||||
for (i32 i = 1; i <= 16; ++i){
|
||||
String8 name = {};
|
||||
i32 index = -1;
|
||||
if (config_string_var(parsed, "fkey_command", i, &name)){
|
||||
i32 count = project->command_array.count;
|
||||
Prj_Command *command_ptr = project->command_array.commands;
|
||||
for (i32 j = 0; j < count; ++j, ++command_ptr){
|
||||
if (string_match(command_ptr->name, name)){
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
project->fkey_commands[i - 1] = index;
|
||||
}
|
||||
}
|
||||
|
||||
project->loaded = true;
|
||||
return(project);
|
||||
}
|
||||
|
||||
function void
|
||||
project_deep_copy__pattern_list(Arena *arena, Prj_Pattern_List *src_list, Prj_Pattern_List *dst_list){
|
||||
for (Prj_Pattern_Node *src_node = src_list->first;
|
||||
src_node != 0;
|
||||
src_node = src_node->next){
|
||||
Prj_Pattern_Node *dst_node = push_array(arena, Prj_Pattern_Node, 1);
|
||||
sll_queue_push(dst_list->first, dst_list->last, dst_node);
|
||||
dst_list->count += 1;
|
||||
|
||||
for (String8Node *node = src_node->pattern.absolutes.first;
|
||||
node != 0;
|
||||
node = node->next){
|
||||
String8 string = push_string_copy(arena, node->string);
|
||||
string_list_push(arena, &dst_node->pattern.absolutes, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Prj
|
||||
project_deep_copy__inner(Arena *arena, Prj *project){
|
||||
Prj result = {};
|
||||
result.dir = push_string_copy(arena, project->dir);
|
||||
result.name = push_string_copy(arena, project->name);
|
||||
project_deep_copy__pattern_list(arena, &project->pattern_list, &result.pattern_list);
|
||||
project_deep_copy__pattern_list(arena, &project->blacklist_pattern_list, &result.blacklist_pattern_list);
|
||||
|
||||
{
|
||||
i32 path_count = project->load_path_array.count;
|
||||
result.load_path_array.paths = push_array(arena, Prj_File_Load_Path, path_count);
|
||||
result.load_path_array.count = path_count;
|
||||
|
||||
Prj_File_Load_Path *dst = result.load_path_array.paths;
|
||||
Prj_File_Load_Path *src = project->load_path_array.paths;
|
||||
for (i32 i = 0; i < path_count; ++i, ++dst, ++src){
|
||||
dst->path = push_string_copy(arena, src->path);
|
||||
dst->recursive = src->recursive;
|
||||
dst->relative = src->relative;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
i32 command_count = project->command_array.count;
|
||||
result.command_array.commands = push_array_zero(arena, Prj_Command, command_count);
|
||||
result.command_array.count = command_count;
|
||||
|
||||
Prj_Command *dst = result.command_array.commands;
|
||||
Prj_Command *src = project->command_array.commands;
|
||||
for (i32 i = 0; i < command_count; ++i, ++dst, ++src){
|
||||
if (src->name.str != 0){
|
||||
dst->name = push_string_copy(arena, src->name);
|
||||
}
|
||||
if (src->cmd.str != 0){
|
||||
dst->cmd = push_string_copy(arena, src->cmd);
|
||||
}
|
||||
if (src->out.str != 0){
|
||||
dst->out = push_string_copy(arena, src->out);
|
||||
}
|
||||
dst->footer_panel = src->footer_panel;
|
||||
dst->save_dirty_files = src->save_dirty_files;
|
||||
dst->cursor_at_end = src->cursor_at_end;
|
||||
}
|
||||
}
|
||||
|
||||
block_copy_array(result.fkey_commands, project->fkey_commands);
|
||||
|
||||
result.loaded = true;
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Prj
|
||||
project_deep_copy(Arena *arena, Prj *project){
|
||||
Temp_Memory restore_point = begin_temp(arena);
|
||||
Prj result = project_deep_copy__inner(arena, project);
|
||||
if (!result.loaded){
|
||||
end_temp(restore_point);
|
||||
block_zero_struct(&result);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
// NOTE(allen): string list join ("flatten") doesn't really work... :(
|
||||
function String8
|
||||
prj_join_pattern_string(Arena *arena, String8List list){
|
||||
String8 pattern_string = {};
|
||||
pattern_string.size = list.total_size + list.node_count - 1;
|
||||
pattern_string.str = push_array(arena, u8, pattern_string.size + 1);
|
||||
u8 *ptr = pattern_string.str;
|
||||
String8Node *node = list.first;
|
||||
if (node != 0){
|
||||
for (;;){
|
||||
block_copy(ptr, node->string.str, node->string.size);
|
||||
ptr += node->string.size;
|
||||
node = node->next;
|
||||
if (node == 0){
|
||||
break;
|
||||
}
|
||||
*ptr = '*';
|
||||
ptr += 1;
|
||||
}
|
||||
}
|
||||
pattern_string.str[pattern_string.size] = 0;
|
||||
return(pattern_string);
|
||||
}
|
||||
|
||||
function String8
|
||||
prj_sanitize_string(Arena *arena, String8 string){
|
||||
String8 result = {};
|
||||
|
||||
if (string.size > 0){
|
||||
result.size = string.size;
|
||||
result.str = push_array(arena, u8, result.size + 2);
|
||||
|
||||
u8 *in = string.str;
|
||||
u8 *out = result.str;
|
||||
|
||||
if (character_is_base10(*in)){
|
||||
*out = '_';
|
||||
out += 1;
|
||||
result.size += 1;
|
||||
}
|
||||
|
||||
for (u64 i = 0; i < string.size; i += 1, in += 1, out += 1){
|
||||
u8 c = *in;
|
||||
if (!character_is_alpha_numeric(c)){
|
||||
c = '_';
|
||||
}
|
||||
*out = c;
|
||||
}
|
||||
|
||||
result.str[result.size] = 0;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Variable_Handle
|
||||
prj_version_1_to_version_2(Application_Links *app, Config *parsed, Prj *project){
|
||||
Scratch_Block scratch(app);
|
||||
|
||||
String_ID project_id = vars_save_string_lit("prj_config");
|
||||
String_ID version_id = vars_save_string(str8_lit("version"));
|
||||
String_ID project_name_id = vars_save_string(str8_lit("project_name"));
|
||||
String_ID patterns_id = vars_save_string(str8_lit("patterns"));
|
||||
String_ID blacklist_patterns_id = vars_save_string(str8_lit("blacklist_patterns"));
|
||||
|
||||
String_ID load_paths_id = vars_save_string(str8_lit("load_paths"));
|
||||
String_ID path_id = vars_save_string(str8_lit("path"));
|
||||
String_ID recursive_id = vars_save_string(str8_lit("recursive"));
|
||||
String_ID relative_id = vars_save_string(str8_lit("relative"));
|
||||
String_ID true_id = vars_save_string(str8_lit("true"));
|
||||
String_ID false_id = vars_save_string(str8_lit("false"));
|
||||
String_ID commands_id = vars_save_string(str8_lit("commands"));
|
||||
|
||||
String_ID out_id = vars_save_string(str8_lit("out"));
|
||||
String_ID footer_panel_id = vars_save_string(str8_lit("footer_panel"));
|
||||
String_ID save_dirty_files_id = vars_save_string(str8_lit("save_dirty_files"));
|
||||
String_ID cursor_at_end_id = vars_save_string(str8_lit("cursor_at_end"));
|
||||
|
||||
String_ID fkey_command_id = vars_save_string(str8_lit("fkey_command"));
|
||||
|
||||
String_ID os_id = vars_save_string(str8_lit(OS_NAME));;
|
||||
|
||||
Variable_Handle proj_var = vars_new_variable(vars_get_root(), project_id, vars_save_string(parsed->file_name));
|
||||
|
||||
if (parsed->version != 0){
|
||||
String8 version_str = push_stringf(scratch, "%d", *parsed->version);
|
||||
vars_new_variable(proj_var, version_id, vars_save_string(version_str));
|
||||
}
|
||||
|
||||
vars_new_variable(proj_var, project_name_id, vars_save_string(project->name));
|
||||
|
||||
// NOTE(allen): Load Pattern
|
||||
struct PatternVars{
|
||||
String_ID id;
|
||||
Prj_Pattern_List list;
|
||||
};
|
||||
PatternVars pattern_vars[] = {
|
||||
{ patterns_id, project-> pattern_list},
|
||||
{blacklist_patterns_id, project->blacklist_pattern_list},
|
||||
};
|
||||
|
||||
PatternVars *pattern_var = pattern_vars;
|
||||
PatternVars *opl = pattern_vars + ArrayCount(pattern_vars);
|
||||
for (; pattern_var < opl; pattern_var += 1){
|
||||
Variable_Handle patterns = vars_new_variable(proj_var, pattern_var->id);
|
||||
|
||||
i32 i = 0;
|
||||
for (Prj_Pattern_Node *node = pattern_var->list.first;
|
||||
node != 0;
|
||||
node = node->next, i += 1){
|
||||
String8 pattern_string = prj_join_pattern_string(scratch, node->pattern.absolutes);
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
String_ID pattern_id = vars_save_string(pattern_string);
|
||||
vars_new_variable(patterns, key, pattern_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): Load Paths
|
||||
{
|
||||
Variable_Handle load_paths = vars_new_variable(proj_var, load_paths_id);
|
||||
Variable_Handle os_var = vars_new_variable(load_paths, os_id);
|
||||
i32 count = project->load_path_array.count;
|
||||
Prj_File_Load_Path *load_path = project->load_path_array.paths;
|
||||
for (i32 i = 0; i < count; i += 1, load_path += 1){
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
Variable_Handle path_var = vars_new_variable(os_var, key);
|
||||
vars_new_variable(path_var, path_id, vars_save_string(load_path->path));
|
||||
vars_new_variable(path_var, recursive_id, load_path->recursive?true_id:false_id);
|
||||
vars_new_variable(path_var, relative_id, load_path->recursive?true_id:false_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): Commands
|
||||
{
|
||||
Variable_Handle cmd_list_var = vars_new_variable(proj_var, commands_id);
|
||||
i32 count = project->command_array.count;
|
||||
Prj_Command *cmd = project->command_array.commands;
|
||||
for (i32 i = 0; i < count; i += 1, cmd += 1){
|
||||
String8 cmd_name = prj_sanitize_string(scratch, cmd->name);
|
||||
Variable_Handle cmd_var = vars_new_variable(cmd_list_var, vars_save_string(cmd_name));
|
||||
vars_new_variable(cmd_var, os_id, vars_save_string(cmd->cmd));
|
||||
vars_new_variable(cmd_var, out_id, vars_save_string(cmd->out));
|
||||
vars_new_variable(cmd_var, footer_panel_id, cmd->footer_panel?true_id:false_id);
|
||||
vars_new_variable(cmd_var, save_dirty_files_id, cmd->save_dirty_files?true_id:false_id);
|
||||
vars_new_variable(cmd_var, cursor_at_end_id, cmd->cursor_at_end?true_id:false_id);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE(allen): FKey Commands
|
||||
{
|
||||
Variable_Handle fkeys_var = vars_new_variable(proj_var, fkey_command_id);
|
||||
for (i32 i = 0; i < 16; i += 1){
|
||||
i32 cmd_index = project->fkey_commands[i];
|
||||
if (0 <= cmd_index && cmd_index < project->command_array.count){
|
||||
Prj_Command *cmd = project->command_array.commands + cmd_index;
|
||||
if (cmd->name.size > 0){
|
||||
String8 cmd_name = prj_sanitize_string(scratch, cmd->name);
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
String_ID val = vars_save_string(cmd_name);
|
||||
vars_new_variable(fkeys_var, key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(proj_var);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Project Files
|
||||
|
||||
|
@ -1180,8 +685,7 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t
|
|||
case 0:
|
||||
case 1:
|
||||
{
|
||||
Prj *project = prj_parse_from_v1_config_data(app, scratch, project_root, config_parse);
|
||||
proj_var = prj_version_1_to_version_2(app, config_parse, project);
|
||||
proj_var = prj_v1_to_v2(app, project_root, config_parse);
|
||||
}break;
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -30,54 +30,6 @@ enum{
|
|||
PrjOpenFileFlag_Recursive = 1,
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
// NOTE(allen): Project v0-v1 Structure
|
||||
|
||||
struct Prj_File_Load_Path{
|
||||
String8 path;
|
||||
b32 recursive;
|
||||
b32 relative;
|
||||
};
|
||||
|
||||
struct Prj_File_Load_Path_Array{
|
||||
Prj_File_Load_Path *paths;
|
||||
i32 count;
|
||||
};
|
||||
|
||||
struct Prj_Command{
|
||||
String8 name;
|
||||
String8 cmd;
|
||||
String8 out;
|
||||
b32 footer_panel;
|
||||
b32 save_dirty_files;
|
||||
b32 cursor_at_end;
|
||||
};
|
||||
|
||||
struct Prj_Command_Array{
|
||||
Prj_Command *commands;
|
||||
i32 count;
|
||||
};
|
||||
|
||||
struct Prj{
|
||||
b32 loaded;
|
||||
|
||||
String8 dir;
|
||||
String8 name;
|
||||
|
||||
Prj_Pattern_List pattern_list;
|
||||
Prj_Pattern_List blacklist_pattern_list;
|
||||
Prj_File_Load_Path_Array load_path_array;
|
||||
Prj_Command_Array command_array;
|
||||
|
||||
i32 fkey_commands[16];
|
||||
};
|
||||
|
||||
enum Prj_OS_Match_Level{
|
||||
PrjOSMatchLevel_NoMatch = 0,
|
||||
PrjOSMatchLevel_PassiveMatch = 1,
|
||||
PrjOSMatchLevel_ActiveMatch = 2,
|
||||
};
|
||||
|
||||
///////////////////////////////
|
||||
// NOTE(allen): Project Files
|
||||
|
||||
|
@ -116,18 +68,6 @@ function void prj_close_files_with_ext(Application_Links *app, String8Array exte
|
|||
function void prj_open_files_pattern_filter(Application_Links *app, String8 dir, Prj_Pattern_List whitelist, Prj_Pattern_List blacklist, Prj_Open_File_Flags flags);
|
||||
function void prj_open_all_files_with_ext_in_hot(Application_Links *app, String8Array array, Prj_Open_File_Flags flags);
|
||||
|
||||
////////////////////////////////
|
||||
// NOTE(allen): Project Parse
|
||||
|
||||
function void prj_parse_pattern_list(Arena *arena, Config *parsed, char *root_variable_name, Prj_Pattern_List *list_out);
|
||||
function Prj_OS_Match_Level prj_parse_v1_os_match(String8 str, String8 this_os_str);
|
||||
function Prj *prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root_dir, Config *parsed);
|
||||
|
||||
function String8 prj_join_pattern_string(Arena *arena, String8List list);
|
||||
function String8 prj_sanitize_string(Arena *arena, String8 string);
|
||||
function Variable_Handle prj_version_1_to_version_2(Application_Links *app, Config *parsed, Prj *project);
|
||||
|
||||
// TODO(allen): sort away the old version convert up stuff
|
||||
// TODO(allen): add in re-print stuff
|
||||
|
||||
////////////////////////////////
|
||||
|
|
|
@ -295,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 },
|
||||
{ PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 },
|
||||
{ PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 },
|
||||
{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1123 },
|
||||
{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 628 },
|
||||
{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 175 },
|
||||
{ PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 },
|
||||
{ PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 },
|
||||
|
@ -371,7 +371,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 },
|
||||
{ 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, 1150 },
|
||||
{ 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, 655 },
|
||||
{ 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, 1583 },
|
||||
{ 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 },
|
||||
|
@ -414,8 +414,8 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 },
|
||||
{ PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 213 },
|
||||
{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 232 },
|
||||
{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1132 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1141 },
|
||||
{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 637 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 646 },
|
||||
{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1576 },
|
||||
{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2059 },
|
||||
{ PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 },
|
||||
|
@ -436,9 +436,9 @@ 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, 1329 },
|
||||
{ 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, 1267 },
|
||||
{ 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, 1293 },
|
||||
{ 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, 833 },
|
||||
{ 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, 771 },
|
||||
{ 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, 797 },
|
||||
{ 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 },
|
||||
{ PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1303 },
|
||||
{ PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1319 },
|
||||
|
@ -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, 1311 },
|
||||
{ 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, 1323 },
|
||||
{ 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, 1317 },
|
||||
{ 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, 1304 },
|
||||
{ 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, 815 },
|
||||
{ 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, 827 },
|
||||
{ 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, 821 },
|
||||
{ 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, 808 },
|
||||
{ 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, 991 },
|
||||
|
|
Loading…
Reference in New Issue