Moved the entire project system over to the new config parsing base

This commit is contained in:
Allen Webster 2018-05-19 15:05:31 -07:00
parent b4607ec3ad
commit cb1273d4cb
9 changed files with 678 additions and 616 deletions

View File

@ -63,10 +63,10 @@ config_parser__advance_to_next(Config_Parser *ctx){
} }
static Config_Parser static Config_Parser
make_config_parser(Partition *arena, char *file_name, String data, Cpp_Token_Array array){ make_config_parser(Partition *arena, String file_name, String data, Cpp_Token_Array array){
Config_Parser ctx = {0}; Config_Parser ctx = {0};
ctx.start = array.tokens; ctx.start = array.tokens;
ctx.token = ctx.start; ctx.token = ctx.start - 1;
ctx.end = ctx.start + array.count; ctx.end = ctx.start + array.count;
ctx.file_name = file_name; ctx.file_name = file_name;
ctx.data = data; ctx.data = data;
@ -96,10 +96,19 @@ config_parser__get_lexeme(Config_Parser *ctx){
return(lexeme); return(lexeme);
} }
static int32_t static Config_Integer
config_parser__get_integer(Config_Parser *ctx){ config_parser__get_int(Config_Parser *ctx){
Config_Integer config_integer = {0};
String str = config_parser__get_lexeme(ctx); String str = config_parser__get_lexeme(ctx);
return(str_to_int(str)); if (match(substr(str, 0, 2), "0x")){
config_integer.is_signed = false;
config_integer.uinteger = hexstr_to_int(substr_tail(str, 2));
}
else{
config_integer.is_signed = true;
config_integer.integer = str_to_int(str);
}
return(config_integer);
} }
static bool32 static bool32
@ -145,7 +154,7 @@ static Config_Compound *config_parser__compound(Config_Parser *ctx);
static Config_Compound_Element *config_parser__element(Config_Parser *ctx); static Config_Compound_Element *config_parser__element(Config_Parser *ctx);
static Config* static Config*
config_parse(Partition *arena, char *file_name, String data, Cpp_Token_Array array){ text_data_and_token_array_to_parse_data(Partition *arena, String file_name, String data, Cpp_Token_Array array){
Temp_Memory restore_point = begin_temp_memory(arena); Temp_Memory restore_point = begin_temp_memory(arena);
Config_Parser ctx = make_config_parser(arena, file_name, data, array); Config_Parser ctx = make_config_parser(arena, file_name, data, array);
Config *config = config_parser__config(&ctx); Config *config = config_parser__config(&ctx);
@ -170,6 +179,7 @@ config_parser__config(Config_Parser *ctx){
} }
Config *config = push_array(ctx->arena, Config, 1); Config *config = push_array(ctx->arena, Config, 1);
memset(config, 0, sizeof(*config));
config->version = version; config->version = version;
config->first = first; config->first = first;
config->last = last; config->last = last;
@ -182,11 +192,11 @@ config_parser__version(Config_Parser *ctx){
require(config_parser__match_text(ctx, make_lit_string("version"))); require(config_parser__match_text(ctx, make_lit_string("version")));
require(config_parser__match_token(ctx, CPP_TOKEN_PARENTHESE_OPEN)); require(config_parser__match_token(ctx, CPP_TOKEN_PARENTHESE_OPEN));
require(config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)); require(config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT));
int32_t value = config_parser__get_integer(ctx); Config_Integer value = config_parser__get_int(ctx);
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
require(config_parser__match_token(ctx, CPP_TOKEN_PARENTHESE_CLOSE)); require(config_parser__match_token(ctx, CPP_TOKEN_PARENTHESE_CLOSE));
int32_t *ptr = push_array(ctx->arena, int32_t, 1); int32_t *ptr = push_array(ctx->arena, int32_t, 1);
*ptr = value; *ptr = value.integer;
return(ptr); return(ptr);
} }
@ -200,6 +210,7 @@ config_parser__assignment(Config_Parser *ctx){
require(config_parser__match_token(ctx, CPP_TOKEN_SEMICOLON)); require(config_parser__match_token(ctx, CPP_TOKEN_SEMICOLON));
Config_Assignment *assignment = push_array(ctx->arena, Config_Assignment, 1); Config_Assignment *assignment = push_array(ctx->arena, Config_Assignment, 1);
memset(assignment, 0, sizeof(*assignment));
assignment->l = l; assignment->l = l;
assignment->r = r; assignment->r = r;
return(assignment); return(assignment);
@ -214,12 +225,14 @@ config_parser__lvalue(Config_Parser *ctx){
int32_t index = 0; int32_t index = 0;
if (config_parser__match_token(ctx, CPP_TOKEN_BRACKET_OPEN)){ if (config_parser__match_token(ctx, CPP_TOKEN_BRACKET_OPEN)){
require(config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)); require(config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT));
index = config_parser__get_integer(ctx); Config_Integer value = config_parser__get_int(ctx);
index = value.integer;
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
require(config_parser__match_token(ctx, CPP_TOKEN_BRACKET_CLOSE)); require(config_parser__match_token(ctx, CPP_TOKEN_BRACKET_CLOSE));
} }
Config_LValue *lvalue = push_array(ctx->arena, Config_LValue, 1); Config_LValue *lvalue = push_array(ctx->arena, Config_LValue, 1);
memset(lvalue, 0, sizeof(*lvalue));
lvalue->identifier = identifier; lvalue->identifier = identifier;
lvalue->index = index; lvalue->index = index;
return(lvalue); return(lvalue);
@ -231,6 +244,7 @@ config_parser__rvalue(Config_Parser *ctx){
Config_LValue *l = config_parser__lvalue(ctx); Config_LValue *l = config_parser__lvalue(ctx);
require(l != 0); require(l != 0);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_LValue; rvalue->type = ConfigRValueType_LValue;
rvalue->lvalue = l; rvalue->lvalue = l;
return(rvalue); return(rvalue);
@ -240,6 +254,7 @@ config_parser__rvalue(Config_Parser *ctx){
Config_Compound *compound = config_parser__compound(ctx); Config_Compound *compound = config_parser__compound(ctx);
require(compound != 0); require(compound != 0);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_Compound; rvalue->type = ConfigRValueType_Compound;
rvalue->compound = compound; rvalue->compound = compound;
return(rvalue); return(rvalue);
@ -248,16 +263,23 @@ config_parser__rvalue(Config_Parser *ctx){
bool32 b = config_parser__get_boolean(ctx); bool32 b = config_parser__get_boolean(ctx);
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_Boolean; rvalue->type = ConfigRValueType_Boolean;
rvalue->boolean = b; rvalue->boolean = b;
return(rvalue); return(rvalue);
} }
else if (config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)){ else if (config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)){
int32_t v = config_parser__get_integer(ctx); Config_Integer value = config_parser__get_int(ctx);
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_Integer; rvalue->type = ConfigRValueType_Integer;
rvalue->integer = v; if (value.is_signed){
rvalue->integer = value.integer;
}
else{
rvalue->uinteger = value.uinteger;
}
return(rvalue); return(rvalue);
} }
else if (config_parser__recognize_token(ctx, CPP_TOKEN_STRING_CONSTANT)){ else if (config_parser__recognize_token(ctx, CPP_TOKEN_STRING_CONSTANT)){
@ -268,6 +290,7 @@ config_parser__rvalue(Config_Parser *ctx){
s = substr(s, 1, s.size - 2); s = substr(s, 1, s.size - 2);
string_interpret_escapes(s, space); string_interpret_escapes(s, space);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_String; rvalue->type = ConfigRValueType_String;
rvalue->string = make_string_slowly(space); rvalue->string = make_string_slowly(space);
return(rvalue); return(rvalue);
@ -280,6 +303,7 @@ config_parser__rvalue(Config_Parser *ctx){
s = substr(s, 1, s.size - 2); s = substr(s, 1, s.size - 2);
string_interpret_escapes(s, space); string_interpret_escapes(s, space);
Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1); Config_RValue *rvalue = push_array(ctx->arena, Config_RValue, 1);
memset(rvalue, 0, sizeof(*rvalue));
rvalue->type = ConfigRValueType_Character; rvalue->type = ConfigRValueType_Character;
rvalue->character = space[0]; rvalue->character = space[0];
return(rvalue); return(rvalue);
@ -311,6 +335,7 @@ config_parser__compound(Config_Parser *ctx){
require(config_parser__match_token(ctx, CPP_TOKEN_BRACE_CLOSE)); require(config_parser__match_token(ctx, CPP_TOKEN_BRACE_CLOSE));
Config_Compound *compound = push_array(ctx->arena, Config_Compound, 1); Config_Compound *compound = push_array(ctx->arena, Config_Compound, 1);
memset(compound, 0, sizeof(*compound));
compound->first = first; compound->first = first;
compound->last = last; compound->last = last;
compound->count = count; compound->count = count;
@ -321,14 +346,15 @@ static Config_Compound_Element*
config_parser__element(Config_Parser *ctx){ config_parser__element(Config_Parser *ctx){
Config_Layout layout = {0}; Config_Layout layout = {0};
if (config_parser__match_token(ctx, CPP_TOKEN_DOT)){ if (config_parser__match_token(ctx, CPP_TOKEN_DOT)){
if (config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)){ if (config_parser__recognize_token(ctx, CPP_TOKEN_IDENTIFIER)){
layout.type = ConfigLayoutType_Identifier; layout.type = ConfigLayoutType_Identifier;
layout.identifier = config_parser__get_lexeme(ctx); layout.identifier = config_parser__get_lexeme(ctx);
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
} }
else if (config_parser__recognize_token(ctx, CPP_TOKEN_IDENTIFIER)){ else if (config_parser__recognize_token(ctx, CPP_TOKEN_INTEGER_CONSTANT)){
layout.type = ConfigLayoutType_Integer; layout.type = ConfigLayoutType_Integer;
layout.integer = config_parser__get_integer(ctx); Config_Integer value = config_parser__get_int(ctx);
layout.integer = value.integer;
config_parser__advance_to_next(ctx); config_parser__advance_to_next(ctx);
} }
else{ else{
@ -337,8 +363,9 @@ config_parser__element(Config_Parser *ctx){
require(config_parser__match_token(ctx, CPP_TOKEN_EQ)); require(config_parser__match_token(ctx, CPP_TOKEN_EQ));
} }
Config_RValue *rvalue = config_parser__rvalue(ctx); Config_RValue *rvalue = config_parser__rvalue(ctx);
require(rvalue); require(rvalue != 0);
Config_Compound_Element *element = push_array(ctx->arena, Config_Compound_Element, 1); Config_Compound_Element *element = push_array(ctx->arena, Config_Compound_Element, 1);
memset(element, 0, sizeof(*element));
element->l = layout; element->l = layout;
element->r = rvalue; element->r = rvalue;
return(element); return(element);
@ -347,7 +374,7 @@ config_parser__element(Config_Parser *ctx){
//////////////////////////////// ////////////////////////////////
static Config_Assignment* static Config_Assignment*
config_lookup_assignment(Config *config, char *var_name, int32_t subscript){ config_lookup_assignment(Config *config, String var_name, int32_t subscript){
Config_Assignment *assignment; Config_Assignment *assignment;
for (assignment = config->first; for (assignment = config->first;
assignment != 0; assignment != 0;
@ -361,15 +388,17 @@ config_lookup_assignment(Config *config, char *var_name, int32_t subscript){
} }
static bool32 static bool32
config_var(Config *config, char *var_name, int32_t subscript, Config_RValue_Type type, void *out){ config_var(Config *config, String var_name, int32_t subscript, Config_RValue_Type type, void *out);
Config_Assignment *assignment = config_lookup_assignment(config, var_name, subscript);
static bool32
config_evaluate_rvalue(Config *config, Config_Assignment *assignment, Config_RValue *r,
Config_RValue_Type type, void *out){
bool32 success = false; bool32 success = false;
if (assignment != 0){
Config_RValue *r = assignment->r;
if (r != 0 && !assignment->visited){ if (r != 0 && !assignment->visited){
if (r->type == ConfigRValueType_LValue){ if (r->type == ConfigRValueType_LValue){
assignment->visited = true; assignment->visited = true;
success = config_var(config, var_name, subscript, type, out); Config_LValue *l = r->lvalue;
success = config_var(config, l->identifier, l->index, type, out);
assignment->visited = false; assignment->visited = false;
} }
else if (r->type == type){ else if (r->type == type){
@ -402,40 +431,192 @@ config_var(Config *config, char *var_name, int32_t subscript, Config_RValue_Type
} }
} }
} }
return(success);
}
static bool32
config_var(Config *config, String var_name, int32_t subscript, Config_RValue_Type type, void *var_out){
Config_Assignment *assignment = config_lookup_assignment(config, var_name, subscript);
bool32 success = false;
if (assignment != 0){
success = config_evaluate_rvalue(config, assignment, assignment->r, type, var_out);
} }
return(success); return(success);
} }
static bool32 static bool32
config_bool_var(Config *config, char *var_name, int32_t subscript, bool32 *var_out){ config_bool_var(Config *config, String var_name, int32_t subscript, bool32 *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Boolean, var_out)); return(config_var(config, var_name, subscript, ConfigRValueType_Boolean, var_out));
} }
static bool32
config_bool_var(Config *config, char *var_name, int32_t subscript, bool32 *var_out){
return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_Boolean, var_out));
}
static bool32
config_int_var(Config *config, String var_name, int32_t subscript, int32_t *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out));
}
static bool32 static bool32
config_int_var(Config *config, char *var_name, int32_t subscript, int32_t *var_out){ config_int_var(Config *config, char *var_name, int32_t subscript, int32_t *var_out){
return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_Integer, var_out));
}
static bool32
config_uint_var(Config *config, String var_name, int32_t subscript, uint32_t *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out)); return(config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out));
} }
static bool32 static bool32
config_uint_var(Config *config, char *var_name, int32_t subscript, uint32_t *var_out){ config_uint_var(Config *config, char *var_name, int32_t subscript, uint32_t *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Integer, var_out)); return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_Integer, var_out));
} }
static bool32 static bool32
config_string_var(Config *config, char *var_name, int32_t subscript, String *var_out){ config_string_var(Config *config, String var_name, int32_t subscript, String *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_String, var_out)); return(config_var(config, var_name, subscript, ConfigRValueType_String, var_out));
} }
static bool32 static bool32
config_char_var(Config *config, char *var_name, int32_t subscript, char *var_out){ config_string_var(Config *config, char *var_name, int32_t subscript, String *var_out){
return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_String, var_out));
}
static bool32
config_char_var(Config *config, String var_name, int32_t subscript, char *var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Character, var_out)); return(config_var(config, var_name, subscript, ConfigRValueType_Character, var_out));
} }
static bool32 static bool32
config_compound_var(Config *config, char *var_name, int32_t subscript, Config_Compound **var_out){ config_char_var(Config *config, char *var_name, int32_t subscript, char *var_out){
return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_Character, var_out));
}
static bool32
config_compound_var(Config *config, String var_name, int32_t subscript, Config_Compound **var_out){
return(config_var(config, var_name, subscript, ConfigRValueType_Compound, var_out)); return(config_var(config, var_name, subscript, ConfigRValueType_Compound, var_out));
} }
static bool32
config_compound_var(Config *config, char *var_name, int32_t subscript, Config_Compound **var_out){
return(config_var(config, make_string_slowly(var_name), subscript, ConfigRValueType_Compound, var_out));
}
static bool32
config_compound_member(Config *config, Config_Compound *compound, String var_name, int32_t index,
Config_RValue_Type type, void *var_out){
bool32 success = false;
int32_t implicit_index = 0;
bool32 implicit_index_is_valid = true;
for (Config_Compound_Element *element = compound->first;
element != 0;
element = element->next, implicit_index += 1){
bool32 element_matches_query = false;
switch (element->l.type){
case ConfigLayoutType_Unset:
{
if (implicit_index_is_valid && index == implicit_index){
element_matches_query = true;
}
}break;
case ConfigLayoutType_Identifier:
{
implicit_index_is_valid = false;
if (match(element->l.identifier, var_name)){
element_matches_query = true;
}
}break;
case ConfigLayoutType_Integer:
{
implicit_index_is_valid = false;
if (element->l.integer == index){
element_matches_query = true;
}
}break;
}
if (element_matches_query){
Config_Assignment dummy_assignment = {0};
success = config_evaluate_rvalue(config, &dummy_assignment, element->r, type, var_out);
}
}
return(success);
}
static bool32
config_compound_bool_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, bool32 *var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_Boolean, var_out));
}
static bool32
config_compound_bool_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, bool32 *var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_Boolean, var_out));
}
static bool32
config_compound_int_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, int32_t *var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_Integer, var_out));
}
static bool32
config_compound_int_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, int32_t *var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_Integer, var_out));
}
static bool32
config_compound_uint_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, uint32_t *var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_Integer, var_out));
}
static bool32
config_compound_uint_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, uint32_t *var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_Integer, var_out));
}
static bool32
config_compound_string_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, String *var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_String, var_out));
}
static bool32
config_compound_string_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, String *var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_String, var_out));
}
static bool32
config_compound_char_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, char *var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_Character, var_out));
}
static bool32
config_compound_char_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, char *var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_Character, var_out));
}
static bool32
config_compound_compound_member(Config *config, Config_Compound *compound,
String var_name, int32_t index, Config_Compound **var_out){
return(config_compound_member(config, compound, var_name, index, ConfigRValueType_Compound, var_out));
}
static bool32
config_compound_compound_member(Config *config, Config_Compound *compound,
char *var_name, int32_t index, Config_Compound **var_out){
return(config_compound_member(config, compound, make_string_slowly(var_name), index, ConfigRValueType_Compound, var_out));
}
//////////////////////////////// ////////////////////////////////
@ -757,6 +938,48 @@ change_mapping(Application_Links *app, String mapping){
//////////////////////////////// ////////////////////////////////
static Cpp_Token_Array
text_data_to_token_array(Partition *arena, String data){
bool32 success = false;
int32_t max_count = (1 << 20)/sizeof(Cpp_Token);
Temp_Memory restore_point = begin_temp_memory(arena);
Cpp_Token_Array array = {0};
array.tokens = push_array(arena, Cpp_Token, max_count);
if (array.tokens != 0){
array.max_count = max_count;
Cpp_Keyword_Table kw_table = {0};
Cpp_Keyword_Table pp_table = {0};
if (lexer_keywords_default_init(arena, &kw_table, &pp_table)){
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
Cpp_Lex_Result result = cpp_lex_step(&S, data.str, data.size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
if (result == LexResult_Finished){
success = true;
}
}
}
if (!success){
memset(&array, 0, sizeof(array));
end_temp_memory(restore_point);
}
return(array);
}
static Config*
text_data_to_parsed_data(Partition *arena, String file_name, String data){
Config *parsed = 0;
Temp_Memory restore_point = begin_temp_memory(arena);
Cpp_Token_Array array = text_data_to_token_array(arena, data);
if (array.tokens != 0){
parsed = text_data_and_token_array_to_parse_data(arena, file_name, data, array);
if (parsed == 0){
end_temp_memory(restore_point);
}
}
return(parsed);
}
////////////////////////////////
static void static void
config_init_default(Config_Data *config){ config_init_default(Config_Data *config){
config->default_wrap_width = 672; config->default_wrap_width = 672;
@ -797,29 +1020,13 @@ config_init_default(Config_Data *config){
} }
static void static void
config_parse__data(Partition *scratch, config_parse__data(Partition *scratch, String file_name, String data, Config_Data *config){
char *file_name, String data, Config_Data *config){
config_init_default(config); config_init_default(config);
bool32 success = false; bool32 success = false;
Temp_Memory temp = begin_temp_memory(scratch); Temp_Memory temp = begin_temp_memory(scratch);
Cpp_Token_Array array = {0}; Config *parsed = text_data_to_parsed_data(scratch, file_name, data);
array.count = 0;
array.max_count = (1 << 20)/sizeof(Cpp_Token);
array.tokens = push_array(scratch, Cpp_Token, array.max_count);
if (array.tokens != 0){
Cpp_Keyword_Table kw_table = {0};
Cpp_Keyword_Table pp_table = {0};
lexer_keywords_default_init(scratch, &kw_table, &pp_table);
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
Cpp_Lex_Result result = cpp_lex_step(&S, data.str, data.size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
if (result == LexResult_Finished){
#if 1
Config *parsed = config_parse(scratch, file_name, data, array);
if (parsed != 0){ if (parsed != 0){
success = true; success = true;
@ -852,64 +1059,6 @@ config_parse__data(Partition *scratch,
config_bool_var(parsed, "lalt_lctrl_is_altgr", 0, &config->lalt_lctrl_is_altgr); config_bool_var(parsed, "lalt_lctrl_is_altgr", 0, &config->lalt_lctrl_is_altgr);
} }
#else
success = true;
for (int32_t i = 0; i < array.count; ++i){
Config_Line config_line = read_config_line(array, &i, data.str);
if (config_line.read_success){
Config_Item item = get_config_item(config_line, data.str, array);
config_bool_var(item, "enable_code_wrapping", 0,
&config->enable_code_wrapping);
config_bool_var(item, "automatically_adjust_wrapping", 0,
&config->automatically_adjust_wrapping);
config_bool_var(item, "automatically_indent_text_on_save", 0,
&config->automatically_indent_text_on_save);
config_bool_var(item, "automatically_save_changes_on_build", 0,
&config->automatically_save_changes_on_build);
config_int_var(item, "default_wrap_width", 0,
&config->default_wrap_width);
config_int_var(item, "default_min_base_width", 0,
&config->default_min_base_width);
config_string_var(item, "default_theme_name", 0,
&config->default_theme_name);
config_string_var(item, "default_font_name", 0,
&config->default_font_name);
config_string_var(item, "user_name", 0,
&config->user_name);
config_string_var(item, "default_compiler_bat", 0,
&config->default_compiler_bat);
config_string_var(item, "default_flags_bat", 0,
&config->default_flags_bat);
config_string_var(item, "default_compiler_sh", 0,
&config->default_compiler_sh);
config_string_var(item, "default_flags_sh", 0,
&config->default_flags_sh);
config_string_var(item, "mapping", 0,
&config->current_mapping);
char space[512];
String str = make_fixed_width_string(space);
if (config_string_var(item, "treat_as_code", 0, &str)){
parse_extension_line_to_extension_list(str, &config->code_exts);
}
config_bool_var(item, "automatically_load_project", 0,
&config->automatically_load_project);
config_bool_var(item, "lalt_lctrl_is_altgr", 0,
&config->lalt_lctrl_is_altgr);
}
}
#endif
}
}
end_temp_memory(temp); end_temp_memory(temp);
if (!success){ if (!success){
@ -919,7 +1068,7 @@ config_parse__data(Partition *scratch,
static void static void
config_parse__file_handle(Partition *scratch, config_parse__file_handle(Partition *scratch,
char *file_name, FILE *file, Config_Data *config){ String file_name, FILE *file, Config_Data *config){
Temp_Memory temp = begin_temp_memory(scratch); Temp_Memory temp = begin_temp_memory(scratch);
String data = dump_file_handle(scratch, file); String data = dump_file_handle(scratch, file);
if (data.str != 0){ if (data.str != 0){
@ -934,81 +1083,70 @@ config_parse__file_handle(Partition *scratch,
static void static void
config_parse__file_name(Application_Links *app, Partition *scratch, config_parse__file_name(Application_Links *app, Partition *scratch,
char *file_name, Config_Data *config){ char *file_name, Config_Data *config){
bool32 success = false;
FILE *file = open_file_try_current_path_then_binary_path(app, file_name); FILE *file = open_file_try_current_path_then_binary_path(app, file_name);
if (file != 0){ if (file != 0){
config_parse__file_handle(scratch, file_name, file, config); Temp_Memory temp = begin_temp_memory(scratch);
String data = dump_file_handle(scratch, file);
fclose(file); fclose(file);
if (data.str != 0){
config_parse__data(scratch, make_string_slowly(file_name), data, config);
} }
else{ end_temp_memory(temp);
print_message(app, literal("Did not find config file, using default settings\n")); }
if (!success){
config_init_default(config); config_init_default(config);
} }
} }
static void
init_theme_zero(Theme *theme){
for (int32_t i = 0; i < Stag_COUNT; ++i){
theme->colors[i] = 0;
}
}
static bool32 static bool32
theme_parse__data(Partition *scratch, String data, Theme_Data *theme){ theme_parse__data(Partition *scratch, String file_name, String data, Theme_Data *theme){
bool32 success = false;
Cpp_Token_Array array;
array.count = 0;
array.max_count = (1 << 20)/sizeof(Cpp_Token);
array.tokens = push_array(scratch, Cpp_Token, array.max_count);
Cpp_Keyword_Table kw_table = {0};
Cpp_Keyword_Table pp_table = {0};
lexer_keywords_default_init(scratch, &kw_table, &pp_table);
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
Cpp_Lex_Result result = cpp_lex_step(&S, data.str, data.size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
if (result == LexResult_Finished){
success = true;
theme->name = make_fixed_width_string(theme->space); theme->name = make_fixed_width_string(theme->space);
copy(&theme->name, "unnamed"); copy(&theme->name, "unnamed");
init_theme_zero(&theme->theme); init_theme_zero(&theme->theme);
for (int32_t i = 0; i < array.count; ++i){ bool32 success = false;
Config_Line config_line = read_config_line(array, &i, data.str); Temp_Memory temp = begin_temp_memory(scratch);
if (config_line.read_success){
Config_Item item = get_config_item(config_line, data.str, array);
config_string_var(item, "name", 0, &theme->name);
for (int32_t tag = 0; tag < ArrayCount(style_tag_names); ++tag){ Config *parsed = text_data_to_parsed_data(scratch, file_name, data);
char *name = style_tag_names[tag]; if (parsed != 0){
int_color color = 0; success = true;
if (config_uint_var(item, name, 0, &color)){
int_color *color_slot = &theme->theme.colors[tag]; String theme_name = {0};
*color_slot = color; if (config_string_var(parsed, "name", 0, &theme_name)){
} copy(&theme->name, theme_name);
else{
char var_space[512];
String var_str = make_fixed_width_string(var_space);
if (config_identifier_var(item, name, 0, &var_str)){
for (int32_t eq_tag = 0; eq_tag < ArrayCount(style_tag_names); ++eq_tag){
if (match(var_str, style_tag_names[eq_tag])){
int_color *color_slot = &theme->theme.colors[tag];
*color_slot = theme->theme.colors[eq_tag];
break;
}
}
}
}
}
} }
for (int32_t i = 0; i < Stag_COUNT; ++i){
char *name = style_tag_names[i];
uint32_t color = 0;
if (!config_uint_var(parsed, name, 0, &color)){
color = 0xFFFF00FF;
}
theme->theme.colors[i] = color;
} }
} }
end_temp_memory(temp);
return(success); return(success);
} }
static bool32 static bool32
theme_parse__file_handle(Partition *scratch, FILE *file, Theme_Data *theme){ theme_parse__file_handle(Partition *scratch, String file_name, FILE *file, Theme_Data *theme){
Temp_Memory temp = begin_temp_memory(scratch); Temp_Memory temp = begin_temp_memory(scratch);
String data = dump_file_handle(scratch, file); String data = dump_file_handle(scratch, file);
bool32 success = false; bool32 success = false;
if (data.str != 0){ if (data.str != 0){
success = theme_parse__data(scratch, data, theme); success = theme_parse__data(scratch, file_name, data, theme);
} }
end_temp_memory(temp); end_temp_memory(temp);
return(success); return(success);
@ -1020,10 +1158,13 @@ theme_parse__file_name(Application_Links *app, Partition *scratch,
bool32 success = false; bool32 success = false;
FILE *file = open_file_try_current_path_then_binary_path(app, file_name); FILE *file = open_file_try_current_path_then_binary_path(app, file_name);
if (file != 0){ if (file != 0){
success = theme_parse__file_handle(scratch, file, theme); Temp_Memory temp = begin_temp_memory(scratch);
String data = dump_file_handle(scratch, file);
fclose(file); fclose(file);
success = theme_parse__data(scratch, make_string_slowly(file_name), data, theme);
end_temp_memory(temp);
} }
else{ if (!success){
char space[256]; char space[256];
String str = make_fixed_width_string(space); String str = make_fixed_width_string(space);
append(&str, "Did not find "); append(&str, "Did not find ");
@ -1031,7 +1172,6 @@ theme_parse__file_name(Application_Links *app, Partition *scratch,
append(&str, ", color scheme not loaded"); append(&str, ", color scheme not loaded");
print_message(app, str.str, str.size); print_message(app, str.str, str.size);
} }
return(success); return(success);
} }

View File

@ -12,7 +12,7 @@ struct Config_Parser{
Cpp_Token *token; Cpp_Token *token;
Cpp_Token *end; Cpp_Token *end;
char *file_name; String file_name;
String data; String data;
Partition *arena; Partition *arena;
@ -47,12 +47,21 @@ struct Config_RValue{
Config_LValue *lvalue; Config_LValue *lvalue;
bool32 boolean; bool32 boolean;
int32_t integer; int32_t integer;
uint32_t uinteger;
String string; String string;
char character; char character;
Config_Compound *compound; Config_Compound *compound;
}; };
}; };
struct Config_Integer{
bool32 is_signed;
union{
int32_t integer;
uint32_t uinteger;
};
};
typedef int32_t Config_Layout_Type; typedef int32_t Config_Layout_Type;
enum{ enum{
ConfigLayoutType_Unset = 0, ConfigLayoutType_Unset = 0,

View File

@ -1,7 +1,7 @@
#define command_id(c) (fcoder_metacmd_ID_##c) #define command_id(c) (fcoder_metacmd_ID_##c)
#define command_metadata(c) (&fcoder_metacmd_table[command_id(c)]) #define command_metadata(c) (&fcoder_metacmd_table[command_id(c)])
#define command_metadata_by_id(id) (&fcoder_metacmd_table[id]) #define command_metadata_by_id(id) (&fcoder_metacmd_table[id])
#define command_one_past_last_id 194 #define command_one_past_last_id 193
#if defined(CUSTOM_COMMAND_SIG) #if defined(CUSTOM_COMMAND_SIG)
#define PROC_LINKS(x,y) x #define PROC_LINKS(x,y) x
#else #else
@ -136,7 +136,6 @@ CUSTOM_COMMAND_SIG(query_replace);
CUSTOM_COMMAND_SIG(query_replace_identifier); CUSTOM_COMMAND_SIG(query_replace_identifier);
CUSTOM_COMMAND_SIG(query_replace_selection); CUSTOM_COMMAND_SIG(query_replace_selection);
CUSTOM_COMMAND_SIG(redo); CUSTOM_COMMAND_SIG(redo);
CUSTOM_COMMAND_SIG(reload_current_project);
CUSTOM_COMMAND_SIG(remap_interactive); CUSTOM_COMMAND_SIG(remap_interactive);
CUSTOM_COMMAND_SIG(rename_file_query); CUSTOM_COMMAND_SIG(rename_file_query);
CUSTOM_COMMAND_SIG(rename_parameter); CUSTOM_COMMAND_SIG(rename_parameter);
@ -213,7 +212,7 @@ char *source_name;
int32_t source_name_len; int32_t source_name_len;
int32_t line_number; int32_t line_number;
}; };
static Command_Metadata fcoder_metacmd_table[194] = { static Command_Metadata fcoder_metacmd_table[193] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "C:\\work\\4ed\\code\\4coder_default_framework.cpp", 49, 203 }, { PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "C:\\work\\4ed\\code\\4coder_default_framework.cpp", 49, 203 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 722 }, { PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 722 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 733 }, { PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "C:\\work\\4ed\\code\\4coder_auto_indent.cpp", 43, 733 },
@ -230,7 +229,7 @@ static Command_Metadata fcoder_metacmd_table[194] = {
{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 368 }, { PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 368 },
{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 174 }, { PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 174 },
{ PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 187 }, { PROC_LINKS(click_set_mark, 0), "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 187 },
{ PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 403 }, { PROC_LINKS(close_all_code, 0), "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 373 },
{ PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 205 }, { PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "C:\\work\\4ed\\code\\4coder_build_commands.cpp", 46, 205 },
{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 441 }, { PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 441 },
{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 26 }, { PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 26 },
@ -296,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[194] = {
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "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, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 800 }, { PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), "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, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 800 },
{ PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 747 }, { PROC_LINKS(list_all_substring_locations, 0), "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 747 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "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, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 759 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), "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, "C:\\work\\4ed\\code\\4coder_search.cpp", 38, 759 },
{ PROC_LINKS(load_project, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 426 }, { PROC_LINKS(load_project, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 396 },
{ PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1101 }, { PROC_LINKS(make_directory_query, 0), "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1101 },
{ PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 110 }, { PROC_LINKS(miblo_decrement_basic, 0), "miblo_decrement_basic", 21, "Decrement an integer under the cursor by one.", 45, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 110 },
{ PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 383 }, { PROC_LINKS(miblo_decrement_time_stamp, 0), "miblo_decrement_time_stamp", 26, "Decrement a time stamp under the cursor by one second. (format [m]m:ss or h:mm:ss", 81, "C:\\work\\4ed\\code\\4coder_miblo_numbers.cpp", 45, 383 },
@ -318,8 +317,8 @@ static Command_Metadata fcoder_metacmd_table[194] = {
{ PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_direct.cpp", 43, 116 }, { PROC_LINKS(newline_or_goto_position_same_panel_direct, 0), "newline_or_goto_position_same_panel_direct", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_direct.cpp", 43, 116 },
{ PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 571 }, { PROC_LINKS(newline_or_goto_position_same_panel_sticky, 0), "newline_or_goto_position_same_panel_sticky", 42, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor_same_panel.", 117, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 571 },
{ PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 556 }, { PROC_LINKS(newline_or_goto_position_sticky, 0), "newline_or_goto_position_sticky", 31, "If the buffer in the active view is writable, inserts a character, otherwise performs goto_jump_at_cursor.", 106, "C:\\work\\4ed\\code\\4coder_jump_sticky.cpp", 43, 556 },
{ PROC_LINKS(open_all_code, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 410 }, { PROC_LINKS(open_all_code, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 380 },
{ PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 417 }, { PROC_LINKS(open_all_code_recursive, 0), "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 387 },
{ PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1457 }, { PROC_LINKS(open_color_tweaker, 0), "open_color_tweaker", 18, "Opens the 4coder colors and fonts selector menu.", 48, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1457 },
{ PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1320 }, { PROC_LINKS(open_file_in_quotes, 0), "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1320 },
{ PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Switches to the next active panel and begins an open file dialogue.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1465 }, { PROC_LINKS(open_in_other, 0), "open_in_other", 13, "Switches to the next active panel and begins an open file dialogue.", 67, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1465 },
@ -336,13 +335,12 @@ static Command_Metadata fcoder_metacmd_table[194] = {
{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 84 }, { PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 84 },
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 135 }, { PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "C:\\work\\4ed\\code\\4coder_clipboard.cpp", 41, 135 },
{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 481 }, { PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "C:\\work\\4ed\\code\\4coder_scope_commands.cpp", 46, 481 },
{ PROC_LINKS(project_fkey_command, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 497 }, { PROC_LINKS(project_fkey_command, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 403 },
{ PROC_LINKS(project_go_to_root_directory, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 522 }, { PROC_LINKS(project_go_to_root_directory, 0), "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, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 428 },
{ PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 893 }, { PROC_LINKS(query_replace, 0), "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 893 },
{ PROC_LINKS(query_replace_identifier, 0), "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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 913 }, { PROC_LINKS(query_replace_identifier, 0), "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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 913 },
{ PROC_LINKS(query_replace_selection, 0), "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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 931 }, { PROC_LINKS(query_replace_selection, 0), "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, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 931 },
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1403 }, { PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1403 },
{ PROC_LINKS(reload_current_project, 0), "reload_current_project", 22, "If a project file has already been loaded, reloads the same file. Useful for when the project configuration is changed.", 120, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 465 },
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "C:\\work\\4ed\\code\\4coder_default_framework.cpp", 49, 223 }, { PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "C:\\work\\4ed\\code\\4coder_default_framework.cpp", 49, 223 },
{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1059 }, { PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 1059 },
{ PROC_LINKS(rename_parameter, 0), "rename_parameter", 16, "If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.", 200, "C:\\work\\4ed\\code\\4coder_experiments.cpp", 43, 385 }, { PROC_LINKS(rename_parameter, 0), "rename_parameter", 16, "If the cursor is found to be on the name of a function parameter in the signature of a function definition, all occurences within the scope of the function will be replaced with a new provided string.", 200, "C:\\work\\4ed\\code\\4coder_experiments.cpp", 43, 385 },
@ -380,7 +378,7 @@ static Command_Metadata fcoder_metacmd_table[194] = {
{ PROC_LINKS(set_bindings_default, 0), "set_bindings_default", 20, "Remap keybindings using the 'default' mapping rule.", 51, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 61 }, { PROC_LINKS(set_bindings_default, 0), "set_bindings_default", 20, "Remap keybindings using the 'default' mapping rule.", 51, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 61 },
{ PROC_LINKS(set_bindings_mac_default, 0), "set_bindings_mac_default", 24, "Remap keybindings using the 'mac-default' mapping rule.", 55, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 75 }, { PROC_LINKS(set_bindings_mac_default, 0), "set_bindings_mac_default", 24, "Remap keybindings using the 'mac-default' mapping rule.", 55, "C:\\work\\4ed\\code\\4coder_remapping_commands.cpp", 50, 75 },
{ PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 86 }, { PROC_LINKS(set_mark, 0), "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 86 },
{ PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 569 }, { PROC_LINKS(setup_new_project, 0), "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "C:\\work\\4ed\\code\\4coder_project_commands.cpp", 48, 475 },
{ PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 464 }, { PROC_LINKS(show_filebar, 0), "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 464 },
{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 450 }, { PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "C:\\work\\4ed\\code\\4coder_base_commands.cpp", 45, 450 },
{ PROC_LINKS(snipe_token_or_word, 0), "snipe_token_or_word", 19, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "C:\\work\\4ed\\code\\4coder_seek.cpp", 36, 1259 }, { PROC_LINKS(snipe_token_or_word, 0), "snipe_token_or_word", 19, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "C:\\work\\4ed\\code\\4coder_seek.cpp", 36, 1259 },
@ -537,69 +535,68 @@ static int32_t fcoder_metacmd_ID_query_replace = 124;
static int32_t fcoder_metacmd_ID_query_replace_identifier = 125; static int32_t fcoder_metacmd_ID_query_replace_identifier = 125;
static int32_t fcoder_metacmd_ID_query_replace_selection = 126; static int32_t fcoder_metacmd_ID_query_replace_selection = 126;
static int32_t fcoder_metacmd_ID_redo = 127; static int32_t fcoder_metacmd_ID_redo = 127;
static int32_t fcoder_metacmd_ID_reload_current_project = 128; static int32_t fcoder_metacmd_ID_remap_interactive = 128;
static int32_t fcoder_metacmd_ID_remap_interactive = 129; static int32_t fcoder_metacmd_ID_rename_file_query = 129;
static int32_t fcoder_metacmd_ID_rename_file_query = 130; static int32_t fcoder_metacmd_ID_rename_parameter = 130;
static int32_t fcoder_metacmd_ID_rename_parameter = 131; static int32_t fcoder_metacmd_ID_reopen = 131;
static int32_t fcoder_metacmd_ID_reopen = 132; static int32_t fcoder_metacmd_ID_replace_all_occurrences = 132;
static int32_t fcoder_metacmd_ID_replace_all_occurrences = 133; static int32_t fcoder_metacmd_ID_replace_in_range = 133;
static int32_t fcoder_metacmd_ID_replace_in_range = 134; static int32_t fcoder_metacmd_ID_reverse_search = 134;
static int32_t fcoder_metacmd_ID_reverse_search = 135; static int32_t fcoder_metacmd_ID_reverse_search_identifier = 135;
static int32_t fcoder_metacmd_ID_reverse_search_identifier = 136; static int32_t fcoder_metacmd_ID_save = 136;
static int32_t fcoder_metacmd_ID_save = 137; static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 137;
static int32_t fcoder_metacmd_ID_save_all_dirty_buffers = 138; static int32_t fcoder_metacmd_ID_save_to_query = 138;
static int32_t fcoder_metacmd_ID_save_to_query = 139; static int32_t fcoder_metacmd_ID_scope_absorb_down = 139;
static int32_t fcoder_metacmd_ID_scope_absorb_down = 140; static int32_t fcoder_metacmd_ID_search = 140;
static int32_t fcoder_metacmd_ID_search = 141; static int32_t fcoder_metacmd_ID_search_identifier = 141;
static int32_t fcoder_metacmd_ID_search_identifier = 142; static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 142;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_left = 143; static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 143;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_left = 144; static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 144;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_or_camel_right = 145; static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 145;
static int32_t fcoder_metacmd_ID_seek_alphanumeric_right = 146; static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 146;
static int32_t fcoder_metacmd_ID_seek_beginning_of_line = 147; static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 147;
static int32_t fcoder_metacmd_ID_seek_beginning_of_textual_line = 148; static int32_t fcoder_metacmd_ID_seek_end_of_line = 148;
static int32_t fcoder_metacmd_ID_seek_end_of_line = 149; static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 149;
static int32_t fcoder_metacmd_ID_seek_end_of_textual_line = 150; static int32_t fcoder_metacmd_ID_seek_token_left = 150;
static int32_t fcoder_metacmd_ID_seek_token_left = 151; static int32_t fcoder_metacmd_ID_seek_token_right = 151;
static int32_t fcoder_metacmd_ID_seek_token_right = 152; static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 152;
static int32_t fcoder_metacmd_ID_seek_white_or_token_left = 153; static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 153;
static int32_t fcoder_metacmd_ID_seek_white_or_token_right = 154; static int32_t fcoder_metacmd_ID_seek_whitespace_down = 154;
static int32_t fcoder_metacmd_ID_seek_whitespace_down = 155; static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 155;
static int32_t fcoder_metacmd_ID_seek_whitespace_down_end_line = 156; static int32_t fcoder_metacmd_ID_seek_whitespace_left = 156;
static int32_t fcoder_metacmd_ID_seek_whitespace_left = 157; static int32_t fcoder_metacmd_ID_seek_whitespace_right = 157;
static int32_t fcoder_metacmd_ID_seek_whitespace_right = 158; static int32_t fcoder_metacmd_ID_seek_whitespace_up = 158;
static int32_t fcoder_metacmd_ID_seek_whitespace_up = 159; static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 159;
static int32_t fcoder_metacmd_ID_seek_whitespace_up_end_line = 160; static int32_t fcoder_metacmd_ID_select_all = 160;
static int32_t fcoder_metacmd_ID_select_all = 161; static int32_t fcoder_metacmd_ID_set_bindings_choose = 161;
static int32_t fcoder_metacmd_ID_set_bindings_choose = 162; static int32_t fcoder_metacmd_ID_set_bindings_default = 162;
static int32_t fcoder_metacmd_ID_set_bindings_default = 163; static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 163;
static int32_t fcoder_metacmd_ID_set_bindings_mac_default = 164; static int32_t fcoder_metacmd_ID_set_mark = 164;
static int32_t fcoder_metacmd_ID_set_mark = 165; static int32_t fcoder_metacmd_ID_setup_new_project = 165;
static int32_t fcoder_metacmd_ID_setup_new_project = 166; static int32_t fcoder_metacmd_ID_show_filebar = 166;
static int32_t fcoder_metacmd_ID_show_filebar = 167; static int32_t fcoder_metacmd_ID_show_scrollbar = 167;
static int32_t fcoder_metacmd_ID_show_scrollbar = 168; static int32_t fcoder_metacmd_ID_snipe_token_or_word = 168;
static int32_t fcoder_metacmd_ID_snipe_token_or_word = 169; static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 169;
static int32_t fcoder_metacmd_ID_snipe_token_or_word_right = 170; static int32_t fcoder_metacmd_ID_suppress_mouse = 170;
static int32_t fcoder_metacmd_ID_suppress_mouse = 171; static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 171;
static int32_t fcoder_metacmd_ID_swap_buffers_between_panels = 172; static int32_t fcoder_metacmd_ID_to_lowercase = 172;
static int32_t fcoder_metacmd_ID_to_lowercase = 173; static int32_t fcoder_metacmd_ID_to_uppercase = 173;
static int32_t fcoder_metacmd_ID_to_uppercase = 174; static int32_t fcoder_metacmd_ID_toggle_filebar = 174;
static int32_t fcoder_metacmd_ID_toggle_filebar = 175; static int32_t fcoder_metacmd_ID_toggle_fullscreen = 175;
static int32_t fcoder_metacmd_ID_toggle_fullscreen = 176; static int32_t fcoder_metacmd_ID_toggle_line_wrap = 176;
static int32_t fcoder_metacmd_ID_toggle_line_wrap = 177; static int32_t fcoder_metacmd_ID_toggle_mouse = 177;
static int32_t fcoder_metacmd_ID_toggle_mouse = 178; static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 178;
static int32_t fcoder_metacmd_ID_toggle_show_whitespace = 179; static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 179;
static int32_t fcoder_metacmd_ID_toggle_virtual_whitespace = 180; static int32_t fcoder_metacmd_ID_undo = 180;
static int32_t fcoder_metacmd_ID_undo = 181; static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 181;
static int32_t fcoder_metacmd_ID_view_buffer_other_panel = 182; static int32_t fcoder_metacmd_ID_word_complete = 182;
static int32_t fcoder_metacmd_ID_word_complete = 183; static int32_t fcoder_metacmd_ID_write_and_auto_tab = 183;
static int32_t fcoder_metacmd_ID_write_and_auto_tab = 184; static int32_t fcoder_metacmd_ID_write_block = 184;
static int32_t fcoder_metacmd_ID_write_block = 185; static int32_t fcoder_metacmd_ID_write_character = 185;
static int32_t fcoder_metacmd_ID_write_character = 186; static int32_t fcoder_metacmd_ID_write_explicit_enum_flags = 186;
static int32_t fcoder_metacmd_ID_write_explicit_enum_flags = 187; static int32_t fcoder_metacmd_ID_write_explicit_enum_values = 187;
static int32_t fcoder_metacmd_ID_write_explicit_enum_values = 188; static int32_t fcoder_metacmd_ID_write_hack = 188;
static int32_t fcoder_metacmd_ID_write_hack = 189; static int32_t fcoder_metacmd_ID_write_note = 189;
static int32_t fcoder_metacmd_ID_write_note = 190; static int32_t fcoder_metacmd_ID_write_todo = 190;
static int32_t fcoder_metacmd_ID_write_todo = 191; static int32_t fcoder_metacmd_ID_write_underscore = 191;
static int32_t fcoder_metacmd_ID_write_underscore = 192; static int32_t fcoder_metacmd_ID_write_zero_struct = 192;
static int32_t fcoder_metacmd_ID_write_zero_struct = 193;

View File

@ -12,7 +12,6 @@ bind(context, 'o', MDFR_ALT, open_in_other);
bind(context, 'k', MDFR_CTRL, interactive_kill_buffer); bind(context, 'k', MDFR_CTRL, interactive_kill_buffer);
bind(context, 'i', MDFR_CTRL, interactive_switch_buffer); bind(context, 'i', MDFR_CTRL, interactive_switch_buffer);
bind(context, 'h', MDFR_CTRL, project_go_to_root_directory); bind(context, 'h', MDFR_CTRL, project_go_to_root_directory);
bind(context, 'H', MDFR_CTRL, reload_current_project);
bind(context, 'S', MDFR_CTRL, save_all_dirty_buffers); bind(context, 'S', MDFR_CTRL, save_all_dirty_buffers);
bind(context, 'c', MDFR_ALT, open_color_tweaker); bind(context, 'c', MDFR_ALT, open_color_tweaker);
bind(context, '.', MDFR_ALT, change_to_build_panel); bind(context, '.', MDFR_ALT, change_to_build_panel);
@ -165,7 +164,6 @@ bind(context, 'o', MDFR_CTRL, open_in_other);
bind(context, 'k', MDFR_CMND, interactive_kill_buffer); bind(context, 'k', MDFR_CMND, interactive_kill_buffer);
bind(context, 'i', MDFR_CMND, interactive_switch_buffer); bind(context, 'i', MDFR_CMND, interactive_switch_buffer);
bind(context, 'h', MDFR_CMND, project_go_to_root_directory); bind(context, 'h', MDFR_CMND, project_go_to_root_directory);
bind(context, 'H', MDFR_CMND, reload_current_project);
bind(context, 'S', MDFR_CMND, save_all_dirty_buffers); bind(context, 'S', MDFR_CMND, save_all_dirty_buffers);
bind(context, 'c', MDFR_CTRL, open_color_tweaker); bind(context, 'c', MDFR_CTRL, open_color_tweaker);
bind(context, '.', MDFR_CTRL, change_to_build_panel); bind(context, '.', MDFR_CTRL, change_to_build_panel);
@ -336,7 +334,7 @@ Meta_Sub_Map *sub_maps;
int32_t sub_map_count; int32_t sub_map_count;
LINK_PROCS(void (*fill_keys_proc)(Bind_Helper *context);) LINK_PROCS(void (*fill_keys_proc)(Bind_Helper *context);)
}; };
static Meta_Key_Bind fcoder_binds_for_default_mapid_global[46] = { static Meta_Key_Bind fcoder_binds_for_default_mapid_global[45] = {
{0, 112, 1, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)}, {0, 112, 1, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)},
{0, 95, 1, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)}, {0, 95, 1, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)},
{0, 80, 1, "close_panel", 11, LINK_PROCS(close_panel)}, {0, 80, 1, "close_panel", 11, LINK_PROCS(close_panel)},
@ -348,7 +346,6 @@ static Meta_Key_Bind fcoder_binds_for_default_mapid_global[46] = {
{0, 107, 1, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)}, {0, 107, 1, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)},
{0, 105, 1, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)}, {0, 105, 1, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)},
{0, 104, 1, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)}, {0, 104, 1, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)},
{0, 72, 1, "reload_current_project", 22, LINK_PROCS(reload_current_project)},
{0, 83, 1, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)}, {0, 83, 1, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)},
{0, 99, 2, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)}, {0, 99, 2, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)},
{0, 46, 2, "change_to_build_panel", 21, LINK_PROCS(change_to_build_panel)}, {0, 46, 2, "change_to_build_panel", 21, LINK_PROCS(change_to_build_panel)},
@ -487,11 +484,11 @@ static Meta_Key_Bind fcoder_binds_for_default_default_code_map[32] = {
{0, 73, 1, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, {0, 73, 1, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)},
}; };
static Meta_Sub_Map fcoder_submaps_for_default[3] = { static Meta_Sub_Map fcoder_submaps_for_default[3] = {
{"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_default_mapid_global, 46}, {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_default_mapid_global, 45},
{"mapid_file", 10, "The following bindings apply in general text files and most apply in code files, but some are overriden by other commands specific to code files.", 145, 0, 0, fcoder_binds_for_default_mapid_file, 66}, {"mapid_file", 10, "The following bindings apply in general text files and most apply in code files, but some are overriden by other commands specific to code files.", 145, 0, 0, fcoder_binds_for_default_mapid_file, 66},
{"default_code_map", 16, "The following commands only apply in files where the lexer (syntax highlighting) is turned on.", 94, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 32}, {"default_code_map", 16, "The following commands only apply in files where the lexer (syntax highlighting) is turned on.", 94, "mapid_file", 10, fcoder_binds_for_default_default_code_map, 32},
}; };
static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[46] = { static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[45] = {
{0, 112, 4, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)}, {0, 112, 4, "open_panel_vsplit", 17, LINK_PROCS(open_panel_vsplit)},
{0, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)}, {0, 95, 4, "open_panel_hsplit", 17, LINK_PROCS(open_panel_hsplit)},
{0, 80, 4, "close_panel", 11, LINK_PROCS(close_panel)}, {0, 80, 4, "close_panel", 11, LINK_PROCS(close_panel)},
@ -503,7 +500,6 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_mapid_global[46] = {
{0, 107, 4, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)}, {0, 107, 4, "interactive_kill_buffer", 23, LINK_PROCS(interactive_kill_buffer)},
{0, 105, 4, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)}, {0, 105, 4, "interactive_switch_buffer", 25, LINK_PROCS(interactive_switch_buffer)},
{0, 104, 4, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)}, {0, 104, 4, "project_go_to_root_directory", 28, LINK_PROCS(project_go_to_root_directory)},
{0, 72, 4, "reload_current_project", 22, LINK_PROCS(reload_current_project)},
{0, 83, 4, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)}, {0, 83, 4, "save_all_dirty_buffers", 22, LINK_PROCS(save_all_dirty_buffers)},
{0, 99, 1, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)}, {0, 99, 1, "open_color_tweaker", 18, LINK_PROCS(open_color_tweaker)},
{0, 46, 1, "change_to_build_panel", 21, LINK_PROCS(change_to_build_panel)}, {0, 46, 1, "change_to_build_panel", 21, LINK_PROCS(change_to_build_panel)},
@ -640,7 +636,7 @@ static Meta_Key_Bind fcoder_binds_for_mac_default_default_code_map[32] = {
{0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)}, {0, 73, 4, "list_all_functions_current_buffer", 33, LINK_PROCS(list_all_functions_current_buffer)},
}; };
static Meta_Sub_Map fcoder_submaps_for_mac_default[3] = { static Meta_Sub_Map fcoder_submaps_for_mac_default[3] = {
{"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_mac_default_mapid_global, 46}, {"mapid_global", 12, "The following bindings apply in all situations.", 47, 0, 0, fcoder_binds_for_mac_default_mapid_global, 45},
{"mapid_file", 10, "The following bindings apply in general text files and most apply in code files, but some are overriden by other commands specific to code files.", 145, 0, 0, fcoder_binds_for_mac_default_mapid_file, 64}, {"mapid_file", 10, "The following bindings apply in general text files and most apply in code files, but some are overriden by other commands specific to code files.", 145, 0, 0, fcoder_binds_for_mac_default_mapid_file, 64},
{"default_code_map", 16, "The following commands only apply in files where the lexer (syntax highlighting) is turned on.", 94, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 32}, {"default_code_map", 16, "The following commands only apply in files where the lexer (syntax highlighting) is turned on.", 94, "mapid_file", 10, fcoder_binds_for_mac_default_default_code_map, 32},
}; };

View File

@ -395,13 +395,6 @@ query_user_number(Application_Links *app, Query_Bar *bar){
return(query_user_general(app, bar, true)); return(query_user_general(app, bar, true));
} }
static void
init_theme_zero(Theme *theme){
for (int32_t i = 0; i < Stag_COUNT; ++i){
theme->colors[i] = 0;
}
}
static char static char
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
char result = ' '; char result = ' ';
@ -1120,22 +1113,23 @@ build_string(Partition *part, String s0, String s1, String s2){
return(sr); return(sr);
} }
static void static bool32
lexer_keywords_default_init(Partition *part, Cpp_Keyword_Table *kw_out, Cpp_Keyword_Table *pp_out){ lexer_keywords_default_init(Partition *arena, Cpp_Keyword_Table *kw_out, Cpp_Keyword_Table *pp_out){
bool32 success = false;
umem_4tech kw_size = cpp_get_table_memory_size_default(CPP_TABLE_KEYWORDS); umem_4tech kw_size = cpp_get_table_memory_size_default(CPP_TABLE_KEYWORDS);
umem_4tech pp_size = cpp_get_table_memory_size_default(CPP_TABLE_PREPROCESSOR_DIRECTIVES); umem_4tech pp_size = cpp_get_table_memory_size_default(CPP_TABLE_PREPROCESSOR_DIRECTIVES);
void *kw_mem = push_array(part, char, (i32_4tech)kw_size); void *kw_mem = push_array(arena, char, (i32_4tech)kw_size);
void *pp_mem = push_array(part, char, (i32_4tech)pp_size); void *pp_mem = push_array(arena, char, (i32_4tech)pp_size);
if (kw_mem != 0 && pp_mem != 0){
*kw_out = cpp_make_table_default(CPP_TABLE_KEYWORDS, kw_mem, kw_size); *kw_out = cpp_make_table_default(CPP_TABLE_KEYWORDS, kw_mem, kw_size);
*pp_out = cpp_make_table_default(CPP_TABLE_PREPROCESSOR_DIRECTIVES, pp_mem, pp_size); *pp_out = cpp_make_table_default(CPP_TABLE_PREPROCESSOR_DIRECTIVES, pp_mem, pp_size);
success = true;
}
return(success);
} }
//////////////////////////////// ////////////////////////////////
// TODO(allen): Stop handling files this way! My own API should be able to do this!!?!?!?!!?!?!!!!?
// NOTE(allen): Actually need binary buffers for some stuff to work, but not this parsing thing here.
#include <stdio.h>
static String static String
dump_file_handle(Partition *arena, FILE *file){ dump_file_handle(Partition *arena, FILE *file){
String str = {0}; String str = {0};
@ -1154,25 +1148,26 @@ dump_file_handle(Partition *arena, FILE *file){
return(str); return(str);
} }
static FILE* static File_Handle_Path
open_file_search_up_path(Partition *scratch, String path, String file_name){ open_file_search_up_path(Partition *arena, String path, String file_name){
Temp_Memory temp = begin_temp_memory(scratch); File_Handle_Path result = {0};
int32_t cap = path.size + file_name.size + 2; int32_t cap = path.size + file_name.size + 2;
char *space = push_array(scratch, char, cap); char *space = push_array(arena, char, cap);
push_align(arena, 8);
String name_str = make_string_cap(space, 0, cap); String name_str = make_string_cap(space, 0, cap);
append(&name_str, path); append(&name_str, path);
if (name_str.size == 0 || !char_is_slash(name_str.str[name_str.size - 1])){ if (name_str.size == 0 || !char_is_slash(name_str.str[name_str.size - 1])){
append(&name_str, "/"); append(&name_str, "/");
} }
FILE *file = 0;
for (;;){ for (;;){
int32_t base_size = name_str.size; int32_t base_size = name_str.size;
append(&name_str, file_name); append(&name_str, file_name);
terminate_with_null(&name_str); terminate_with_null(&name_str);
file = fopen(name_str.str, "rb"); result.file = fopen(name_str.str, "rb");
if (file != 0){ if (result.file != 0){
result.path = name_str;
break; break;
} }
@ -1183,8 +1178,7 @@ open_file_search_up_path(Partition *scratch, String path, String file_name){
} }
} }
end_temp_memory(temp); return(result);
return(file);
} }
static FILE* static FILE*
@ -1232,24 +1226,27 @@ open_file(Partition *scratch, String name){
return(file); return(file);
} }
static String static File_Name_Data
dump_file(Partition *arena, String name){ dump_file(Partition *arena, String file_name){
String result = {0}; File_Name_Data result = {0};
FILE *file = open_file(arena, name); FILE *file = open_file(arena, file_name);
if (file != 0){ if (file != 0){
result = dump_file_handle(arena, file); result.file_name = file_name;
result.data = dump_file_handle(arena, file);
fclose(file); fclose(file);
} }
return(result); return(result);
} }
static String static File_Name_Path_Data
dump_file_search_up_path(Partition *arena, String path, String file_name){ dump_file_search_up_path(Partition *arena, String path, String file_name){
String result = {0}; File_Name_Path_Data result = {0};
FILE *file = open_file_search_up_path(arena, path, file_name); File_Handle_Path file = open_file_search_up_path(arena, path, file_name);
if (file != 0){ if (file.file != 0){
result = dump_file_handle(arena, file); result.file_name = file_name;
fclose(file); result.path = file.path;
result.data = dump_file_handle(arena, file.file);
fclose(file.file);
} }
return(result); return(result);
} }

View File

@ -7,6 +7,10 @@
#if !defined(FCODER_HELPER_H) #if !defined(FCODER_HELPER_H)
#define FCODER_HELPER_H #define FCODER_HELPER_H
// TODO(allen): Stop handling files this way! My own API should be able to do this!!?!?!?!!?!?!!!!?
// NOTE(allen): Actually need binary buffers for some stuff to work, but not this parsing thing here.
#include <stdio.h>
struct Bind_Helper{ struct Bind_Helper{
Binding_Unit *cursor, *start, *end; Binding_Unit *cursor, *start, *end;
Binding_Unit *header, *group; Binding_Unit *header, *group;
@ -69,6 +73,24 @@ max_f32_proc(void){
//////////////////////////////// ////////////////////////////////
struct File_Handle_Path{
FILE *file;
String path;
};
struct File_Name_Data{
String file_name;
String data;
};
struct File_Name_Path_Data{
String file_name;
String path;
String data;
};
////////////////////////////////
struct Buffer_Rect{ struct Buffer_Rect{
int32_t char0; int32_t char0;
int32_t line0; int32_t line0;

View File

@ -9,7 +9,7 @@ static Project current_project = {0};
/////////////////////////////// ///////////////////////////////
static CString_Array static CString_Array
get_project_extensions(Project *project){ project_get_extensions(Project *project){
CString_Array array = {0}; CString_Array array = {0};
array.strings = default_extensions; array.strings = default_extensions;
array.count = ArrayCount(default_extensions); array.count = ArrayCount(default_extensions);
@ -74,21 +74,21 @@ close_all_files_with_extension(Application_Links *app, Partition *scratch_part,
} }
static void static void
open_all_files_in_directory_with_extension(Application_Links *app, String dir, open_all_files_in_directory_with_extension__inner(Application_Links *app, String space,
CString_Array extension_array, CString_Array extension_array,
uint32_t flags){ uint32_t flags){
File_List list = get_file_list(app, dir.str, dir.size); File_List list = get_file_list(app, space.str, space.size);
int32_t dir_size = dir.size; int32_t dir_size = space.size;
for (uint32_t i = 0; i < list.count; ++i){ for (uint32_t i = 0; i < list.count; ++i){
File_Info *info = list.infos + i; File_Info *info = list.infos + i;
if (info->folder){ if (info->folder &&
if (((flags&OpenAllFilesFlag_Recursive) != 0) && info->filename[0] != '.'){ ((flags & OpenAllFilesFlag_Recursive) != 0) &&
dir.size = dir_size; info->filename[0] != '.'){
append(&dir, info->filename); space.size = dir_size;
append(&dir, "/"); append(&space, info->filename);
open_all_files_in_directory_with_extension(app, dir, extension_array, flags); append(&space, "/");
} open_all_files_in_directory_with_extension__inner(app, space, extension_array, flags);
} }
else{ else{
bool32 is_match = true; bool32 is_match = true;
@ -105,9 +105,9 @@ open_all_files_in_directory_with_extension(Application_Links *app, String dir,
} }
if (is_match){ if (is_match){
dir.size = dir_size; space.size = dir_size;
append(&dir, info->filename); append(&space, info->filename);
create_buffer(app, dir.str, dir.size, 0); create_buffer(app, space.str, space.size, 0);
} }
} }
} }
@ -116,91 +116,66 @@ open_all_files_in_directory_with_extension(Application_Links *app, String dir,
} }
static void static void
open_all_files_with_extension_in_hot(Application_Links *app, Partition *scratch, open_all_files_in_directory_with_extension(Application_Links *app, Partition *scratch,
CString_Array extensions_array, String dir,
CString_Array extension_array,
uint32_t flags){ uint32_t flags){
Temp_Memory temp = begin_temp_memory(scratch); Temp_Memory temp = begin_temp_memory(scratch);
int32_t max_size = 4096; int32_t size = 32 << 10;
char *memory = push_array(scratch, char, max_size); char *mem = push_array(scratch, char, size);
String dir = make_string_cap(memory, 0, max_size); String space = make_string_cap(mem, 0, size);
dir.size = directory_get_hot(app, dir.str, dir.memory_size); append(&space, dir);
open_all_files_in_directory_with_extension(app, dir, extensions_array, flags); open_all_files_in_directory_with_extension__inner(app, space, extension_array, flags);
end_temp_memory(temp); end_temp_memory(temp);
} }
static void static void
open_all_code_with_project_extensions_in_directory(Application_Links *app, String dir, uint32_t flags){ open_all_files_in_hot_with_extension(Application_Links *app, Partition *scratch,
CString_Array array = get_project_extensions(&current_project); CString_Array extensions_array,
open_all_files_in_directory_with_extension(app, dir, array, flags); uint32_t flags){
Temp_Memory temp = begin_temp_memory(scratch);
int32_t size = 32 << 10;
char *mem = push_array(scratch, char, size);
String space = make_string_cap(mem, 0, size);
space.size = directory_get_hot(app, space.str, space.memory_size);
open_all_files_in_directory_with_extension__inner(app, space, extensions_array, flags);
end_temp_memory(temp);
} }
/////////////////////////////// ///////////////////////////////
static void static bool32
load_project_from_data(Application_Links *app, Partition *scratch, parse_project__data(Partition *scratch, String file_name, String data, String file_dir,
char *config_data, int32_t config_data_size, Project *project){
String project_dir){ bool32 success = false;
Temp_Memory temp = begin_temp_memory(scratch);
char *mem = config_data; Cpp_Token_Array array = text_data_to_token_array(scratch, data);
int32_t size = config_data_size; if (array.tokens != 0){
Config *parsed = text_data_and_token_array_to_parse_data(scratch, file_name, data, array);
Cpp_Token_Array array; if (parsed != 0){
array.count = 0; success = true;
array.max_count = (1 << 20)/sizeof(Cpp_Token); memset(project, 0, sizeof(*project));
array.tokens = push_array(scratch, Cpp_Token, array.max_count);
Cpp_Keyword_Table kw_table = {0};
Cpp_Keyword_Table pp_table = {0};
lexer_keywords_default_init(scratch, &kw_table, &pp_table);
Cpp_Lex_Data S = cpp_lex_data_init(false, kw_table, pp_table);
Cpp_Lex_Result result = cpp_lex_step(&S, mem, size + 1, HAS_NULL_TERM, &array, NO_OUT_LIMIT);
if (result == LexResult_Finished){
// Clear out current project
if (current_project.close_all_code_when_this_project_closes){
close_all_files_with_extension(app, scratch, get_project_extensions(&current_project));
}
memset(&current_project, 0, sizeof(current_project));
current_project.loaded = true;
// Set new project directory // Set new project directory
{ {
current_project.dir = current_project.dir_space; project->dir = project->dir_space;
String str = make_fixed_width_string(current_project.dir_space); String str = make_fixed_width_string(project->dir_space);
copy(&str, project_dir); copy(&str, file_dir);
terminate_with_null(&str); terminate_with_null(&str);
current_project.dir_len = str.size; project->dir_len = str.size;
} }
// Read the settings from project.4coder // Read the settings from project.4coder
for (int32_t i = 0; i < array.count; ++i){ String str = {0};
Config_Line config_line = read_config_line(array, &i, mem); if (config_string_var(parsed, "extensions", 0, &str)){
if (config_line.read_success){ parse_extension_line_to_extension_list(str, &project->extension_list);
Config_Item item = get_config_item(config_line, mem, array);
{
char str_space[512];
String str = make_fixed_width_string(str_space);
if (config_string_var(item, "extensions", 0, &str)){
if (str.size < sizeof(current_project.extension_list.space)){
parse_extension_line_to_extension_list(str, &current_project.extension_list);
print_message(app, str.str, str.size);
print_message(app, "\n", 1);
}
else{
print_message(app, literal("STRING TOO LONG!\n"));
}
}
} }
bool32 open_recursively = false; bool32 open_recursively = false;
if (config_bool_var(item, "open_recursively", 0, &open_recursively)){ if (config_bool_var(parsed, "open_recursively", 0, &open_recursively)){
current_project.open_recursively = open_recursively; project->open_recursively = open_recursively;
} }
{
#if defined(IS_WINDOWS) #if defined(IS_WINDOWS)
# define FKEY_COMMAND "fkey_command_win" # define FKEY_COMMAND "fkey_command_win"
#elif defined(IS_LINUX) #elif defined(IS_LINUX)
@ -211,138 +186,133 @@ load_project_from_data(Application_Links *app, Partition *scratch,
# error no project configuration names for this platform # error no project configuration names for this platform
#endif #endif
int32_t index = 0; for (int32_t i = 1; i <= 16; ++i){
Config_Array_Reader array_reader = {0}; Config_Compound *compound = 0;
if (config_array_var(item, FKEY_COMMAND, &index, &array_reader)){ if (config_compound_var(parsed, FKEY_COMMAND, i, &compound)){
if (index >= 1 && index <= 16){ Fkey_Command *command = &project->fkey_commands[i - 1];
Config_Item array_item = {0}; command->command[0] = 0;
int32_t item_index = 0; command->out[0] = 0;
command->use_build_panel = false;
command->save_dirty_buffers = false;
char space[256]; String cmd = {0};
String msg = make_fixed_width_string(space); if (config_compound_string_member(parsed, compound, "cmd", 0, &cmd)){
append(&msg, FKEY_COMMAND"["); String dst = make_fixed_width_string(command->command);
append_int_to_str(&msg, index); append(&dst, cmd);
append(&msg, "] = {"); terminate_with_null(&dst);
for (config_array_next_item(&array_reader, &array_item);
config_array_good(&array_reader);
config_array_next_item(&array_reader, &array_item)){
if (item_index >= 4){
break;
} }
append(&msg, "["); String out = {0};
append_int_to_str(&msg, item_index); if (config_compound_string_member(parsed, compound, "out", 1, &out)){
append(&msg, "] = "); String dst = make_fixed_width_string(command->out);
append(&dst, out);
bool32 read_string = false; terminate_with_null(&out);
bool32 read_bool = false;
char *dest_str = 0;
int32_t dest_str_size = 0;
bool32 *dest_bool = 0;
switch (item_index){
case 0:
{
dest_str = current_project.fkey_commands[index-1].command;
dest_str_size = sizeof(current_project.fkey_commands[index-1].command);
read_string = true;
}break;
case 1:
{
dest_str = current_project.fkey_commands[index-1].out;
dest_str_size = sizeof(current_project.fkey_commands[index-1].out);
read_string = true;
}break;
case 2:
{
dest_bool = &current_project.fkey_commands[index-1].use_build_panel;
read_bool = true;
}break;
case 3:
{
dest_bool = &current_project.fkey_commands[index-1].save_dirty_buffers;
read_bool = true;
}break;
} }
if (read_string){ bool32 footer_panel = false;
if (config_int_var(array_item, 0, 0, 0)){ if (config_compound_bool_member(parsed, compound, "footer_panel", 2, &footer_panel)){
append(&msg, "NULL, "); command->use_build_panel = footer_panel;
dest_str[0] = 0;
} }
char str_space[512]; bool32 save_dirty_buffers = false;
String str = make_fixed_width_string(str_space); if (config_compound_bool_member(parsed, compound, "save_dirty_files", 3, &footer_panel)){
if (config_string_var(array_item, 0, 0, &str)){ command->save_dirty_buffers = save_dirty_buffers;
if (str.size < dest_str_size){ }
string_interpret_escapes(str, dest_str); }
append(&msg, dest_str); }
append(&msg, ", "); }
}
return(success);
}
static bool32
parse_project__nearest_file(Application_Links *app, Partition *arena, Project *project){
bool32 success = false;
String project_path = {0};
Temp_Memory temp = begin_temp_memory(arena);
int32_t size = 32 << 10;
char *space = push_array(arena, char, size);
if (space != 0){
project_path = make_string_cap(space, 0, size);
project_path.size = directory_get_hot(app, project_path.str, project_path.memory_size);
end_temp_memory(temp);
push_array(arena, char, project_path.size);
project_path.memory_size = project_path.size;
if (project_path.size == 0){
print_message(app, literal("The hot directory is empty, cannot search for a project.\n"));
} }
else{ else{
append(&msg, "STRING TOO LONG!, "); File_Name_Path_Data dump = dump_file_search_up_path(arena, project_path, make_lit_string("project.4coder"));
} if (dump.data.str != 0){
} String project_root = dump.path;
} remove_last_folder(&project_root);
success = parse_project__data(arena, dump.file_name, dump.data, project_root, project);
if (read_bool){
if (config_bool_var(array_item, 0, 0, dest_bool)){
if (*dest_bool){
append(&msg, "true, ");
} }
else{ else{
append(&msg, "false, "); char message_space[512];
String message = make_fixed_width_string(message_space);
append(&message, "Did not find project.4coder. ");
if (current_project.dir != 0){
append(&message, "Continuing with: ");
append(&message, current_project.dir);
}
else{
append(&message, "Continuing without a project");
}
append(&message, '\n');
print_message(app, message.str, message.size);
} }
} }
} }
end_temp_memory(temp);
return(success);
}
item_index++; static void
} set_current_project(Application_Links *app, Partition *scratch, Project *project){
memcpy(&current_project, &project, sizeof(current_project));
append(&msg, "}\n"); String file_dir = make_string(project->dir_space, project->dir_len);
print_message(app, msg.str, msg.size);
}
}
}
}
else if (config_line.error_str.str != 0){
char space[2048];
String str = make_fixed_width_string(space);
copy(&str, "WARNING: bad syntax in 4coder.config at ");
append(&str, config_line.error_str);
append(&str, "\n");
print_message(app, str.str, str.size);
}
}
if (current_project.close_all_files_when_project_opens){
CString_Array extension_array = {0};
close_all_files_with_extension(app, scratch, extension_array);
}
// Open all project files // Open all project files
uint32_t flags = 0; uint32_t flags = 0;
if (current_project.open_recursively){ if (current_project.open_recursively){
flags |= OpenAllFilesFlag_Recursive; flags |= OpenAllFilesFlag_Recursive;
} }
open_all_code_with_project_extensions_in_directory(app, project_dir, flags); CString_Array array = project_get_extensions(&current_project);
open_all_files_in_directory_with_extension(app, scratch, file_dir, array, flags);
// Set window title // Set window title
char space[1024]; char space[1024];
String builder = make_fixed_width_string(space); String builder = make_fixed_width_string(space);
append(&builder, "4coder: "); append(&builder, "4coder: ");
append(&builder, project_dir); append(&builder, file_dir);
terminate_with_null(&builder); terminate_with_null(&builder);
set_window_title(app, builder.str); set_window_title(app, builder.str);
} }
static void
set_current_project_from_data(Application_Links *app, Partition *scratch,
String file_name, String data, String file_dir){
Temp_Memory temp = begin_temp_memory(scratch);
Project project = {0};
if (parse_project__data(scratch, file_name, data, file_dir,
&project)){
set_current_project(app, scratch, &project);
}
end_temp_memory(temp);
}
static void
set_project_from_nearest_project_file(Application_Links *app, Partition *scratch){
Temp_Memory temp = begin_temp_memory(scratch);
Project project = {0};
if (parse_project__nearest_file(app, scratch, &project)){
set_current_project(app, scratch, &project);
}
end_temp_memory(temp); end_temp_memory(temp);
} }
@ -403,22 +373,22 @@ exec_project_fkey_command(Application_Links *app, int32_t command_ind){
CUSTOM_COMMAND_SIG(close_all_code) CUSTOM_COMMAND_SIG(close_all_code)
CUSTOM_DOC("Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.") CUSTOM_DOC("Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.")
{ {
CString_Array extensions = get_project_extensions(&current_project); CString_Array extensions = project_get_extensions(&current_project);
close_all_files_with_extension(app, &global_part, extensions); close_all_files_with_extension(app, &global_part, extensions);
} }
CUSTOM_COMMAND_SIG(open_all_code) CUSTOM_COMMAND_SIG(open_all_code)
CUSTOM_DOC("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.") CUSTOM_DOC("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.")
{ {
CString_Array extensions = get_project_extensions(&current_project); CString_Array extensions = project_get_extensions(&current_project);
open_all_files_with_extension_in_hot(app, &global_part, extensions, 0); open_all_files_in_hot_with_extension(app, &global_part, extensions, 0);
} }
CUSTOM_COMMAND_SIG(open_all_code_recursive) CUSTOM_COMMAND_SIG(open_all_code_recursive)
CUSTOM_DOC("Works as open_all_code but also runs in all subdirectories.") CUSTOM_DOC("Works as open_all_code but also runs in all subdirectories.")
{ {
CString_Array extensions = get_project_extensions(&current_project); CString_Array extensions = project_get_extensions(&current_project);
open_all_files_with_extension_in_hot(app, &global_part, extensions, OpenAllFilesFlag_Recursive); open_all_files_in_hot_with_extension(app, &global_part, extensions, OpenAllFilesFlag_Recursive);
} }
/////////////////////////////// ///////////////////////////////
@ -426,72 +396,8 @@ CUSTOM_DOC("Works as open_all_code but also runs in all subdirectories.")
CUSTOM_COMMAND_SIG(load_project) CUSTOM_COMMAND_SIG(load_project)
CUSTOM_DOC("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.") CUSTOM_DOC("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.")
{ {
Partition *part = &global_part;
Temp_Memory temp = begin_temp_memory(part);
save_all_dirty_buffers(app); save_all_dirty_buffers(app);
char space[512]; set_project_from_nearest_project_file(app, &global_part);
String project_path = make_fixed_width_string(space);
project_path.size = directory_get_hot(app, project_path.str, project_path.memory_size);
if (project_path.size >= project_path.memory_size){
print_message(app, literal("Hot directory longer than hard coded path buffer.\n"));
}
else if (project_path.size == 0){
print_message(app, literal("The hot directory is empty, cannot search for a project.\n"));
}
else{
String data = dump_file_search_up_path(part, project_path, make_lit_string("project.4coder"));
if (data.str != 0){
load_project_from_data(app, part, data.str, data.size, project_path);
}
else{
char message_space[512];
String message = make_fixed_width_string(message_space);
append(&message, "Did not find project.4coder. ");
if (current_project.dir != 0){
append(&message, "Continuing with: ");
append(&message, current_project.dir);
}
else{
append(&message, "Continuing without a project");
}
append(&message, '\n');
print_message(app, message.str, message.size);
}
}
end_temp_memory(temp);
}
CUSTOM_COMMAND_SIG(reload_current_project)
CUSTOM_DOC("If a project file has already been loaded, reloads the same file. Useful for when the project configuration is changed.")
{
Partition *part = &global_part;
if (current_project.loaded){
save_all_dirty_buffers(app);
char space[512];
String project_path = make_fixed_width_string(space);
append(&project_path, make_string(current_project.dir, current_project.dir_len));
if (project_path.size == 0 || !char_is_slash(project_path.str[project_path.size - 1])){
append(&project_path, "/");
}
append(&project_path, "project.4coder");
terminate_with_null(&project_path);
FILE *file = fopen(project_path.str, "rb");
if (file != 0){
Temp_Memory temp = begin_temp_memory(part);
String data = dump_file_handle(part, file);
if (data.str != 0){
load_project_from_data(app, part, data.str, data.size, project_path);
}
end_temp_memory(temp);
fclose(file);
}
else{
print_message(app, literal("project.4coder file not found. Project configuration unchanged."));
}
}
} }
CUSTOM_COMMAND_SIG(project_fkey_command) CUSTOM_COMMAND_SIG(project_fkey_command)

View File

@ -30,9 +30,6 @@ struct Project{
Extension_List extension_list; Extension_List extension_list;
Fkey_Command fkey_commands[16]; Fkey_Command fkey_commands[16];
bool32 close_all_code_when_this_project_closes;
bool32 close_all_files_when_project_opens;
bool32 open_recursively; bool32 open_recursively;
bool32 loaded; bool32 loaded;

View File

@ -186,7 +186,7 @@ generate_style(){
char filename_4coder[] = STYLE_FILE; char filename_4coder[] = STYLE_FILE;
char filename_4ed[] = "4ed_generated_style.h"; char filename_4ed[] = "4ed_generated_style.h";
String out = str_alloc(10 << 20);; String out = str_alloc(10 << 20);
enum_begin(&out, "Style_Tag"); enum_begin(&out, "Style_Tag");
{ {
@ -684,7 +684,6 @@ generate_remapping_code_and_data(){
bind(mappings, 'k', MDFR_CTRL, interactive_kill_buffer); bind(mappings, 'k', MDFR_CTRL, interactive_kill_buffer);
bind(mappings, 'i', MDFR_CTRL, interactive_switch_buffer); bind(mappings, 'i', MDFR_CTRL, interactive_switch_buffer);
bind(mappings, 'h', MDFR_CTRL, project_go_to_root_directory); bind(mappings, 'h', MDFR_CTRL, project_go_to_root_directory);
bind(mappings, 'H', MDFR_CTRL, reload_current_project);
bind(mappings, 'S', MDFR_CTRL, save_all_dirty_buffers); bind(mappings, 'S', MDFR_CTRL, save_all_dirty_buffers);
bind(mappings, 'c', MDFR_ALT, open_color_tweaker); bind(mappings, 'c', MDFR_ALT, open_color_tweaker);
@ -880,7 +879,6 @@ generate_remapping_code_and_data(){
bind(mappings, 'k', MDFR_CMND, interactive_kill_buffer); bind(mappings, 'k', MDFR_CMND, interactive_kill_buffer);
bind(mappings, 'i', MDFR_CMND, interactive_switch_buffer); bind(mappings, 'i', MDFR_CMND, interactive_switch_buffer);
bind(mappings, 'h', MDFR_CMND, project_go_to_root_directory); bind(mappings, 'h', MDFR_CMND, project_go_to_root_directory);
bind(mappings, 'H', MDFR_CMND, reload_current_project);
bind(mappings, 'S', MDFR_CMND, save_all_dirty_buffers); bind(mappings, 'S', MDFR_CMND, save_all_dirty_buffers);
bind(mappings, 'c', MDFR_CTRL, open_color_tweaker); bind(mappings, 'c', MDFR_CTRL, open_color_tweaker);