get off cfg node duplicates of mdesk trees; use md trees for params consistently across view rules, tabs, etc.

This commit is contained in:
Ryan Fleury
2024-08-26 14:26:23 -07:00
parent aed18eb71c
commit 1de57557b5
16 changed files with 394 additions and 608 deletions
+69 -103
View File
@@ -355,10 +355,11 @@ df_expand_set_expansion(Arena *arena, DF_ExpandTreeTable *table, DF_ExpandKey pa
//////////////////////////////// ////////////////////////////////
//~ rjf: Config Type Functions //~ rjf: Config Type Functions
#if 0
internal DF_CfgNode * internal DF_CfgNode *
df_cfg_tree_copy(Arena *arena, DF_CfgNode *src_root) df_cfg_tree_copy(Arena *arena, DF_CfgNode *src_root)
{ {
DF_CfgNode *dst_root = &df_g_nil_cfg_node; DF_CfgNode *dst_root = &df_g_nil_cfg_tree;
DF_CfgNode *dst_parent = dst_root; DF_CfgNode *dst_parent = dst_root;
{ {
DF_CfgNodeRec rec = {0}; DF_CfgNodeRec rec = {0};
@@ -412,20 +413,28 @@ df_cfg_node_rec__depth_first_pre(DF_CfgNode *node, DF_CfgNode *root)
} }
return rec; return rec;
} }
#endif
internal DF_CfgTree *
df_cfg_tree_copy(Arena *arena, DF_CfgTree *src)
{
DF_CfgTree *dst = push_array(arena, DF_CfgTree, 1);
dst->source = src->source;
dst->root = md_tree_copy(arena, src->root);
return dst;
}
internal void internal void
df_cfg_table_push_unparsed_string(Arena *arena, DF_CfgTable *table, String8 string, DF_CfgSrc source) df_cfg_table_push_unparsed_string(Arena *arena, DF_CfgTable *table, String8 string, DF_CfgSrc source)
{ {
Temp scratch = scratch_begin(&arena, 1);
if(table->slot_count == 0) if(table->slot_count == 0)
{ {
table->slot_count = 64; table->slot_count = 64;
table->slots = push_array(arena, DF_CfgSlot, table->slot_count); table->slots = push_array(arena, DF_CfgSlot, table->slot_count);
} }
MD_TokenizeResult tokenize = md_tokenize_from_text(scratch.arena, string); MD_TokenizeResult tokenize = md_tokenize_from_text(arena, string);
MD_ParseResult parse = md_parse_from_text_tokens(scratch.arena, str8_lit(""), string, tokenize.tokens); MD_ParseResult parse = md_parse_from_text_tokens(arena, str8_lit(""), string, tokenize.tokens);
MD_Node *md_root = parse.root; for(MD_EachNode(tln, parse.root->first)) if(tln->string.size != 0)
for(MD_EachNode(tln, md_root->first)) if(tln->string.size != 0)
{ {
// rjf: map string -> hash*slot // rjf: map string -> hash*slot
String8 string = str8(tln->string.str, tln->string.size); String8 string = str8(tln->string.str, tln->string.size);
@@ -455,55 +464,12 @@ df_cfg_table_push_unparsed_string(Arena *arena, DF_CfgTable *table, String8 stri
table->insertion_stamp_counter += 1; table->insertion_stamp_counter += 1;
} }
// rjf: deep copy tree into streamlined config structure // rjf: create new node within this value
DF_CfgNode *dst_root = &df_g_nil_cfg_node; DF_CfgTree *tree = push_array(arena, DF_CfgTree, 1);
{ SLLQueuePush_NZ(&df_g_nil_cfg_tree, val->first, val->last, tree, next);
DF_CfgNode *dst_parent = &df_g_nil_cfg_node; tree->source = source;
for(MD_Node *src = tln, *src_next = 0; !md_node_is_nil(src); src = src_next) tree->root = tln;
{
src_next = 0;
// rjf: copy
DF_CfgNode *dst = push_array(arena, DF_CfgNode, 1);
dst->first = dst->last = dst->parent = dst->next = &df_g_nil_cfg_node;
if(dst_parent == &df_g_nil_cfg_node)
{
dst_root = dst;
}
else
{
SLLQueuePush_NZ(&df_g_nil_cfg_node, dst_parent->first, dst_parent->last, dst, next);
dst->parent = dst_parent;
}
{
dst->flags |= !!(src->flags & MD_NodeFlag_Identifier) * DF_CfgNodeFlag_Identifier;
dst->flags |= !!(src->flags & MD_NodeFlag_Numeric) * DF_CfgNodeFlag_Numeric;
dst->flags |= !!(src->flags & MD_NodeFlag_StringLiteral) * DF_CfgNodeFlag_StringLiteral;
dst->string = push_str8_copy(arena, str8(src->string.str, src->string.size));
dst->source = source;
}
// rjf: grab next
if(!md_node_is_nil(src->first))
{
src_next = src->first;
dst_parent = dst;
}
else for(MD_Node *p = src; !md_node_is_nil(p) && p != tln; p = p->parent, dst_parent = dst_parent->parent)
{
if(!md_node_is_nil(p->next))
{
src_next = p->next;
break;
}
}
}
}
// rjf: push tree into value
SLLQueuePush_NZ(&df_g_nil_cfg_node, val->first, val->last, dst_root, next);
} }
scratch_end(scratch);
} }
internal DF_CfgTable internal DF_CfgTable
@@ -566,6 +532,7 @@ df_cfg_val_from_string(DF_CfgTable *table, String8 string)
return result; return result;
} }
#if 0
internal DF_CfgNode * internal DF_CfgNode *
df_cfg_node_child_from_string(DF_CfgNode *node, String8 string, StringMatchFlags flags) df_cfg_node_child_from_string(DF_CfgNode *node, String8 string, StringMatchFlags flags)
{ {
@@ -673,6 +640,7 @@ df_string_from_cfg_node_key(DF_CfgNode *node, String8 key, StringMatchFlags flag
DF_CfgNode *child = df_cfg_node_child_from_string(node, key, flags); DF_CfgNode *child = df_cfg_node_child_from_string(node, key, flags);
return child->first->string; return child->first->string;
} }
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Debug Info Extraction Type Pure Functions //~ rjf: Debug Info Extraction Type Pure Functions
@@ -4591,10 +4559,10 @@ df_filtered_data_members_from_members_cfg_table(Arena *arena, E_MemberArray memb
{ {
// rjf: check if included by 'only's // rjf: check if included by 'only's
B32 is_included = 1; B32 is_included = 1;
for(DF_CfgNode *r = only->first; r != &df_g_nil_cfg_node; r = r->next) for(DF_CfgTree *r = only->first; r != &df_g_nil_cfg_tree; r = r->next)
{ {
is_included = 0; is_included = 0;
for(DF_CfgNode *name_node = r->first; name_node != &df_g_nil_cfg_node; name_node = name_node->next) for(MD_EachNode(name_node, r->root->first))
{ {
String8 name = name_node->string; String8 name = name_node->string;
if(str8_match(members.v[idx].name, name, 0)) if(str8_match(members.v[idx].name, name, 0))
@@ -4607,9 +4575,9 @@ df_filtered_data_members_from_members_cfg_table(Arena *arena, E_MemberArray memb
end_inclusion_check:; end_inclusion_check:;
// rjf: remove if excluded by 'omit's // rjf: remove if excluded by 'omit's
for(DF_CfgNode *r = omit->first; r != &df_g_nil_cfg_node; r = r->next) for(DF_CfgTree *r = omit->first; r != &df_g_nil_cfg_tree; r = r->next)
{ {
for(DF_CfgNode *name_node = r->first; name_node != &df_g_nil_cfg_node; name_node = name_node->next) for(MD_EachNode(name_node, r->root->first))
{ {
String8 name = name_node->string; String8 name = name_node->string;
if(str8_match(members.v[idx].name, name, 0)) if(str8_match(members.v[idx].name, name, 0))
@@ -5173,21 +5141,21 @@ df_eval_viz_row_list_push_new(Arena *arena, DF_EvalView *eval_view, DF_EvalVizWi
// rjf: determine row ui hook to use for this row // rjf: determine row ui hook to use for this row
DF_GfxViewRuleSpec *value_ui_rule_spec = &df_g_nil_gfx_view_rule_spec; DF_GfxViewRuleSpec *value_ui_rule_spec = &df_g_nil_gfx_view_rule_spec;
DF_CfgNode *value_ui_rule_node= &df_g_nil_cfg_node; MD_Node *value_ui_rule_params = &md_nil_node;
for(DF_CfgVal *val = cfg_table->first_val; val != 0 && val != &df_g_nil_cfg_val; val = val->linear_next) for(DF_CfgVal *val = cfg_table->first_val; val != 0 && val != &df_g_nil_cfg_val; val = val->linear_next)
{ {
DF_GfxViewRuleSpec *spec = df_gfx_view_rule_spec_from_string(val->string); DF_GfxViewRuleSpec *spec = df_gfx_view_rule_spec_from_string(val->string);
if(spec->info.flags & DF_GfxViewRuleSpecInfoFlag_RowUI) if(spec->info.flags & DF_GfxViewRuleSpecInfoFlag_RowUI)
{ {
value_ui_rule_spec = spec; value_ui_rule_spec = spec;
value_ui_rule_node = val->last; value_ui_rule_params = val->last->root;
break; break;
} }
} }
// rjf: determine block ui hook to use for this row // rjf: determine block ui hook to use for this row
DF_GfxViewRuleSpec *expand_ui_rule_spec = &df_g_nil_gfx_view_rule_spec; DF_GfxViewRuleSpec *expand_ui_rule_spec = &df_g_nil_gfx_view_rule_spec;
DF_CfgNode *expand_ui_rule_node = &df_g_nil_cfg_node; MD_Node *expand_ui_rule_params = &md_nil_node;
if(block->kind == DF_EvalVizBlockKind_Canvas) if(block->kind == DF_EvalVizBlockKind_Canvas)
{ {
for(DF_CfgVal *val = cfg_table->first_val; val != 0 && val != &df_g_nil_cfg_val; val = val->linear_next) for(DF_CfgVal *val = cfg_table->first_val; val != 0 && val != &df_g_nil_cfg_val; val = val->linear_next)
@@ -5196,7 +5164,7 @@ df_eval_viz_row_list_push_new(Arena *arena, DF_EvalView *eval_view, DF_EvalVizWi
if(spec->info.flags & DF_GfxViewRuleSpecInfoFlag_ViewUI) if(spec->info.flags & DF_GfxViewRuleSpecInfoFlag_ViewUI)
{ {
expand_ui_rule_spec = spec; expand_ui_rule_spec = spec;
expand_ui_rule_node = val->last; expand_ui_rule_params = val->last->root;
break; break;
} }
} }
@@ -5204,10 +5172,10 @@ df_eval_viz_row_list_push_new(Arena *arena, DF_EvalView *eval_view, DF_EvalVizWi
// rjf: fill // rjf: fill
row->cfg_table = cfg_table; row->cfg_table = cfg_table;
row->value_ui_rule_node = value_ui_rule_node;
row->value_ui_rule_spec = value_ui_rule_spec; row->value_ui_rule_spec = value_ui_rule_spec;
row->expand_ui_rule_node = expand_ui_rule_node; row->value_ui_rule_params = value_ui_rule_params;
row->expand_ui_rule_spec = expand_ui_rule_spec; row->expand_ui_rule_spec = expand_ui_rule_spec;
row->expand_ui_rule_params = expand_ui_rule_params;
} }
return row; return row;
@@ -5420,11 +5388,11 @@ df_base_offset_from_eval(E_Eval eval)
} }
internal E_Value internal E_Value
df_value_from_cfg_key(DF_CfgNode *cfg, String8 key) df_value_from_params_key(MD_Node *params, String8 key)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
DF_CfgNode *key_cfg = df_cfg_node_child_from_string(cfg, key, 0); MD_Node *key_node = md_child_from_string(params, key, 0);
String8 expr = df_string_from_cfg_node_children(scratch.arena, key_cfg); String8 expr = md_string_from_children(scratch.arena, key_node);
E_Eval eval = e_eval_from_string(scratch.arena, expr); E_Eval eval = e_eval_from_string(scratch.arena, expr);
E_Eval value_eval = e_value_eval_from_eval(eval); E_Eval value_eval = e_value_eval_from_eval(eval);
scratch_end(scratch); scratch_end(scratch);
@@ -5432,10 +5400,10 @@ df_value_from_cfg_key(DF_CfgNode *cfg, String8 key)
} }
internal Rng1U64 internal Rng1U64
df_range_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) df_range_from_eval_params(E_Eval eval, MD_Node *params)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
U64 size = df_value_from_cfg_key(cfg, str8_lit("size")).u64; U64 size = df_value_from_params_key(params, str8_lit("size")).u64;
if(size == 0 && if(size == 0 &&
(e_type_kind_from_key(eval.type_key) == E_TypeKind_Array || (e_type_kind_from_key(eval.type_key) == E_TypeKind_Array ||
e_type_kind_from_key(e_type_direct_from_key(eval.type_key)) == E_TypeKind_Array)) e_type_kind_from_key(e_type_direct_from_key(eval.type_key)) == E_TypeKind_Array))
@@ -5463,7 +5431,7 @@ df_range_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg)
} }
internal TXT_LangKind internal TXT_LangKind
df_lang_kind_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) df_lang_kind_from_eval_params(E_Eval eval, MD_Node *params)
{ {
TXT_LangKind lang_kind = TXT_LangKind_Null; TXT_LangKind lang_kind = TXT_LangKind_Null;
if(eval.expr->kind == E_ExprKind_LeafFilePath) if(eval.expr->kind == E_ExprKind_LeafFilePath)
@@ -5472,33 +5440,33 @@ df_lang_kind_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg)
} }
else else
{ {
DF_CfgNode *lang_cfg = df_cfg_node_child_from_string(cfg, str8_lit("lang"), 0); MD_Node *lang_node = md_child_from_string(params, str8_lit("lang"), 0);
String8 lang_kind_string = lang_cfg->first->string; String8 lang_kind_string = lang_node->first->string;
lang_kind = txt_lang_kind_from_extension(lang_kind_string); lang_kind = txt_lang_kind_from_extension(lang_kind_string);
} }
return lang_kind; return lang_kind;
} }
internal Vec2S32 internal Vec2S32
df_dim2s32_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) df_dim2s32_from_eval_params(E_Eval eval, MD_Node *params)
{ {
Vec2S32 dim = v2s32(1, 1); Vec2S32 dim = v2s32(1, 1);
{ {
dim.x = df_value_from_cfg_key(cfg, str8_lit("w")).s32; dim.x = df_value_from_params_key(params, str8_lit("w")).s32;
dim.y = df_value_from_cfg_key(cfg, str8_lit("h")).s32; dim.y = df_value_from_params_key(params, str8_lit("h")).s32;
} }
return dim; return dim;
} }
internal R_Tex2DFormat internal R_Tex2DFormat
df_tex2dformat_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) df_tex2dformat_from_eval_params(E_Eval eval, MD_Node *params)
{ {
R_Tex2DFormat result = R_Tex2DFormat_RGBA8; R_Tex2DFormat result = R_Tex2DFormat_RGBA8;
{ {
DF_CfgNode *fmt_child = df_cfg_node_child_from_string(cfg, str8_lit("fmt"), 0); MD_Node *fmt_node = md_child_from_string(params, str8_lit("fmt"), 0);
for(EachNonZeroEnumVal(R_Tex2DFormat, fmt)) for(EachNonZeroEnumVal(R_Tex2DFormat, fmt))
{ {
if(str8_match(r_tex2d_kind_display_string_table[fmt], fmt_child->first->string, StringMatchFlag_CaseInsensitive)) if(str8_match(r_tex2d_kind_display_string_table[fmt], fmt_node->first->string, StringMatchFlag_CaseInsensitive))
{ {
result = fmt; result = fmt;
break; break;
@@ -7780,16 +7748,16 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
if(k_flags & DF_EntityKindFlag_IsSerializedToConfig) if(k_flags & DF_EntityKindFlag_IsSerializedToConfig)
{ {
DF_CfgVal *k_val = df_cfg_val_from_string(table, df_g_entity_kind_name_lower_table[k]); DF_CfgVal *k_val = df_cfg_val_from_string(table, df_g_entity_kind_name_lower_table[k]);
for(DF_CfgNode *k_cfg = k_val->first; for(DF_CfgTree *k_tree = k_val->first;
k_cfg != &df_g_nil_cfg_node; k_tree != &df_g_nil_cfg_tree;
k_cfg = k_cfg->next) k_tree = k_tree->next)
{ {
if(k_cfg->source != src) if(k_tree->source != src)
{ {
continue; continue;
} }
DF_Entity *entity = df_entity_alloc(df_entity_root(), k); DF_Entity *entity = df_entity_alloc(df_entity_root(), k);
df_entity_equip_cfg_src(entity, k_cfg->source); df_entity_equip_cfg_src(entity, k_tree->source);
// rjf: iterate config tree // rjf: iterate config tree
typedef struct Task Task; typedef struct Task Task;
@@ -7797,18 +7765,18 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
{ {
Task *next; Task *next;
DF_Entity *entity; DF_Entity *entity;
DF_CfgNode *n; MD_Node *n;
}; };
Task start_task = {0, entity, k_cfg}; Task start_task = {0, entity, k_tree->root};
Task *first_task = &start_task; Task *first_task = &start_task;
Task *last_task = first_task; Task *last_task = first_task;
for(Task *t = first_task; t != 0; t = t->next) for(Task *t = first_task; t != 0; t = t->next)
{ {
DF_CfgNode *node = t->n; MD_Node *node = t->n;
for(DF_CfgNode *child = node->first; child != &df_g_nil_cfg_node; child = child->next) for(MD_EachNode(child, node->first))
{ {
// rjf: standalone string literals under an entity -> name // rjf: standalone string literals under an entity -> name
if(child->flags & DF_CfgNodeFlag_StringLiteral && child->first == &df_g_nil_cfg_node) if(child->flags & MD_NodeFlag_StringLiteral && child->first == &md_nil_node)
{ {
String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->string); String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->string);
if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath) if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath)
@@ -7819,7 +7787,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
} }
// rjf: standalone string literals under an entity, with a numeric child -> name & text location // rjf: standalone string literals under an entity, with a numeric child -> name & text location
if(child->flags & DF_CfgNodeFlag_StringLiteral && child->first->flags & DF_CfgNodeFlag_Numeric && child->first->first == &df_g_nil_cfg_node) if(child->flags & MD_NodeFlag_StringLiteral && child->first->flags & MD_NodeFlag_Numeric && child->first->first == &md_nil_node)
{ {
String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->string); String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->string);
if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath) if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath)
@@ -7834,7 +7802,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
} }
// rjf: standalone hex literals under an entity -> vaddr // rjf: standalone hex literals under an entity -> vaddr
if(child->flags & DF_CfgNodeFlag_Numeric && child->first == &df_g_nil_cfg_node && str8_match(str8_substr(child->string, r1u64(0, 2)), str8_lit("0x"), 0)) if(child->flags & MD_NodeFlag_Numeric && child->first == &md_nil_node && str8_match(str8_substr(child->string, r1u64(0, 2)), str8_lit("0x"), 0))
{ {
U64 vaddr = 0; U64 vaddr = 0;
try_u64_from_str8_c_rules(child->string, &vaddr); try_u64_from_str8_c_rules(child->string, &vaddr);
@@ -7844,7 +7812,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
// rjf: specifically named entity equipment // rjf: specifically named entity equipment
if((str8_match(child->string, str8_lit("name"), StringMatchFlag_CaseInsensitive) || if((str8_match(child->string, str8_lit("name"), StringMatchFlag_CaseInsensitive) ||
str8_match(child->string, str8_lit("label"), StringMatchFlag_CaseInsensitive)) && str8_match(child->string, str8_lit("label"), StringMatchFlag_CaseInsensitive)) &&
child->first != &df_g_nil_cfg_node) child->first != &md_nil_node)
{ {
String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->first->string); String8 string = df_cfg_raw_from_escaped_string(scratch.arena, child->first->string);
if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath) if(df_g_entity_kind_flags_table[t->entity->kind] & DF_EntityKindFlag_NameIsPath)
@@ -7855,15 +7823,15 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
} }
if((str8_match(child->string, str8_lit("active"), StringMatchFlag_CaseInsensitive) || if((str8_match(child->string, str8_lit("active"), StringMatchFlag_CaseInsensitive) ||
str8_match(child->string, str8_lit("enabled"), StringMatchFlag_CaseInsensitive)) && str8_match(child->string, str8_lit("enabled"), StringMatchFlag_CaseInsensitive)) &&
child->first != &df_g_nil_cfg_node) child->first != &md_nil_node)
{ {
df_entity_equip_disabled(t->entity, !str8_match(child->first->string, str8_lit("1"), 0)); df_entity_equip_disabled(t->entity, !str8_match(child->first->string, str8_lit("1"), 0));
} }
if(str8_match(child->string, str8_lit("disabled"), StringMatchFlag_CaseInsensitive) && child->first != &df_g_nil_cfg_node) if(str8_match(child->string, str8_lit("disabled"), StringMatchFlag_CaseInsensitive) && child->first != &md_nil_node)
{ {
df_entity_equip_disabled(t->entity, str8_match(child->first->string, str8_lit("1"), 0)); df_entity_equip_disabled(t->entity, str8_match(child->first->string, str8_lit("1"), 0));
} }
if(str8_match(child->string, str8_lit("hsva"), StringMatchFlag_CaseInsensitive) && child->first != &df_g_nil_cfg_node) if(str8_match(child->string, str8_lit("hsva"), StringMatchFlag_CaseInsensitive) && child->first != &md_nil_node)
{ {
Vec4F32 hsva = {0}; Vec4F32 hsva = {0};
hsva.x = (F32)f64_from_str8(child->first->string); hsva.x = (F32)f64_from_str8(child->first->string);
@@ -7872,13 +7840,13 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
hsva.w = (F32)f64_from_str8(child->first->next->next->next->string); hsva.w = (F32)f64_from_str8(child->first->next->next->next->string);
df_entity_equip_color_hsva(t->entity, hsva); df_entity_equip_color_hsva(t->entity, hsva);
} }
if(str8_match(child->string, str8_lit("color"), StringMatchFlag_CaseInsensitive) && child->first != &df_g_nil_cfg_node) if(str8_match(child->string, str8_lit("color"), StringMatchFlag_CaseInsensitive) && child->first != &md_nil_node)
{ {
Vec4F32 rgba = rgba_from_hex_string_4f32(child->first->string); Vec4F32 rgba = rgba_from_hex_string_4f32(child->first->string);
Vec4F32 hsva = hsva_from_rgba(rgba); Vec4F32 hsva = hsva_from_rgba(rgba);
df_entity_equip_color_hsva(t->entity, hsva); df_entity_equip_color_hsva(t->entity, hsva);
} }
if(str8_match(child->string, str8_lit("line"), StringMatchFlag_CaseInsensitive) && child->first != &df_g_nil_cfg_node) if(str8_match(child->string, str8_lit("line"), StringMatchFlag_CaseInsensitive) && child->first != &md_nil_node)
{ {
S64 line = 0; S64 line = 0;
try_s64_from_str8_c_rules(child->first->string, &line); try_s64_from_str8_c_rules(child->first->string, &line);
@@ -7887,7 +7855,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
} }
if((str8_match(child->string, str8_lit("vaddr"), StringMatchFlag_CaseInsensitive) || if((str8_match(child->string, str8_lit("vaddr"), StringMatchFlag_CaseInsensitive) ||
str8_match(child->string, str8_lit("addr"), StringMatchFlag_CaseInsensitive)) && str8_match(child->string, str8_lit("addr"), StringMatchFlag_CaseInsensitive)) &&
child->first != &df_g_nil_cfg_node) child->first != &md_nil_node)
{ {
U64 vaddr = 0; U64 vaddr = 0;
try_u64_from_str8_c_rules(child->first->string, &vaddr); try_u64_from_str8_c_rules(child->first->string, &vaddr);
@@ -7898,7 +7866,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
DF_EntityKind sub_entity_kind = DF_EntityKind_Nil; DF_EntityKind sub_entity_kind = DF_EntityKind_Nil;
for(EachEnumVal(DF_EntityKind, k2)) for(EachEnumVal(DF_EntityKind, k2))
{ {
if(child->flags & DF_CfgNodeFlag_Identifier && child->first != &df_g_nil_cfg_node && if(child->flags & MD_NodeFlag_Identifier && child->first != &md_nil_node &&
(str8_match(child->string, df_g_entity_kind_name_lower_table[k2], StringMatchFlag_CaseInsensitive) || (str8_match(child->string, df_g_entity_kind_name_lower_table[k2], StringMatchFlag_CaseInsensitive) ||
(k2 == DF_EntityKind_Executable && str8_match(child->string, str8_lit("exe"), StringMatchFlag_CaseInsensitive)))) (k2 == DF_EntityKind_Executable && str8_match(child->string, str8_lit("exe"), StringMatchFlag_CaseInsensitive))))
{ {
@@ -7919,13 +7887,11 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
//- rjf: apply exception code filters //- rjf: apply exception code filters
DF_CfgVal *filter_tables = df_cfg_val_from_string(table, str8_lit("exception_code_filters")); DF_CfgVal *filter_tables = df_cfg_val_from_string(table, str8_lit("exception_code_filters"));
for(DF_CfgNode *table = filter_tables->first; for(DF_CfgTree *table = filter_tables->first;
table != &df_g_nil_cfg_node; table != &df_g_nil_cfg_tree;
table = table->next) table = table->next)
{ {
for(DF_CfgNode *rule = table->first; for(MD_EachNode(rule, table->root->first))
rule != &df_g_nil_cfg_node;
rule = rule->next)
{ {
String8 name = rule->string; String8 name = rule->string;
String8 val_string = rule->first->string; String8 val_string = rule->first->string;
+32 -12
View File
@@ -171,7 +171,7 @@ struct DF_CtrlFlowInfo
//////////////////////////////// ////////////////////////////////
//~ rjf: View Rule Hook Types //~ rjf: View Rule Hook Types
typedef struct DF_CfgNode DF_CfgNode; typedef struct DF_CfgTree DF_CfgTree;
typedef struct DF_CfgVal DF_CfgVal; typedef struct DF_CfgVal DF_CfgVal;
typedef struct DF_CfgTable DF_CfgTable; typedef struct DF_CfgTable DF_CfgTable;
typedef struct DF_EvalView DF_EvalView; typedef struct DF_EvalView DF_EvalView;
@@ -203,6 +203,7 @@ typedef DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_SIG(DF_CoreViewRuleVizBlockPro
//////////////////////////////// ////////////////////////////////
//~ rjf: Config Types //~ rjf: Config Types
#if 0
typedef U32 DF_CfgNodeFlags; typedef U32 DF_CfgNodeFlags;
enum enum
{ {
@@ -222,7 +223,17 @@ struct DF_CfgNode
String8 string; String8 string;
DF_CfgSrc source; DF_CfgSrc source;
}; };
#endif
typedef struct DF_CfgTree DF_CfgTree;
struct DF_CfgTree
{
DF_CfgTree *next;
DF_CfgSrc source;
MD_Node *root;
};
#if 0
typedef struct DF_CfgNodeRec DF_CfgNodeRec; typedef struct DF_CfgNodeRec DF_CfgNodeRec;
struct DF_CfgNodeRec struct DF_CfgNodeRec
{ {
@@ -230,14 +241,15 @@ struct DF_CfgNodeRec
S32 push_count; S32 push_count;
S32 pop_count; S32 pop_count;
}; };
#endif
typedef struct DF_CfgVal DF_CfgVal; typedef struct DF_CfgVal DF_CfgVal;
struct DF_CfgVal struct DF_CfgVal
{ {
DF_CfgVal *hash_next; DF_CfgVal *hash_next;
DF_CfgVal *linear_next; DF_CfgVal *linear_next;
DF_CfgNode *first; DF_CfgTree *first;
DF_CfgNode *last; DF_CfgTree *last;
U64 insertion_stamp; U64 insertion_stamp;
String8 string; String8 string;
}; };
@@ -793,9 +805,9 @@ struct DF_EvalVizRow
// rjf: view rule attachments // rjf: view rule attachments
DF_CfgTable *cfg_table; DF_CfgTable *cfg_table;
struct DF_GfxViewRuleSpec *expand_ui_rule_spec; struct DF_GfxViewRuleSpec *expand_ui_rule_spec;
struct DF_CfgNode *expand_ui_rule_node; MD_Node *expand_ui_rule_params;
struct DF_GfxViewRuleSpec *value_ui_rule_spec; struct DF_GfxViewRuleSpec *value_ui_rule_spec;
struct DF_CfgNode *value_ui_rule_node; MD_Node *value_ui_rule_params;
}; };
typedef struct DF_EvalVizWindowedRowList DF_EvalVizWindowedRowList; typedef struct DF_EvalVizWindowedRowList DF_EvalVizWindowedRowList;
@@ -1228,8 +1240,11 @@ struct DF_State
read_only global DF_CmdSpec df_g_nil_cmd_spec = {0}; read_only global DF_CmdSpec df_g_nil_cmd_spec = {0};
read_only global DF_CoreViewRuleSpec df_g_nil_core_view_rule_spec = {0}; read_only global DF_CoreViewRuleSpec df_g_nil_core_view_rule_spec = {0};
#if 0
read_only global DF_CfgNode df_g_nil_cfg_node = {&df_g_nil_cfg_node, &df_g_nil_cfg_node, &df_g_nil_cfg_node, &df_g_nil_cfg_node}; read_only global DF_CfgNode df_g_nil_cfg_node = {&df_g_nil_cfg_node, &df_g_nil_cfg_node, &df_g_nil_cfg_node, &df_g_nil_cfg_node};
read_only global DF_CfgVal df_g_nil_cfg_val = {&df_g_nil_cfg_val, &df_g_nil_cfg_val, &df_g_nil_cfg_node, &df_g_nil_cfg_node}; #endif
read_only global DF_CfgTree df_g_nil_cfg_tree = {&df_g_nil_cfg_tree, DF_CfgSrc_User, &md_nil_node};
read_only global DF_CfgVal df_g_nil_cfg_val = {&df_g_nil_cfg_val, &df_g_nil_cfg_val, &df_g_nil_cfg_tree, &df_g_nil_cfg_tree};
read_only global DF_CfgTable df_g_nil_cfg_table = {0, 0, 0, &df_g_nil_cfg_val, &df_g_nil_cfg_val}; read_only global DF_CfgTable df_g_nil_cfg_table = {0, 0, 0, &df_g_nil_cfg_val, &df_g_nil_cfg_val};
read_only global DF_Entity df_g_nil_entity = read_only global DF_Entity df_g_nil_entity =
{ {
@@ -1325,17 +1340,22 @@ internal void df_expand_set_expansion(Arena *arena, DF_ExpandTreeTable *table, D
//////////////////////////////// ////////////////////////////////
//~ rjf: Config Type Pure Functions //~ rjf: Config Type Pure Functions
#if 0
internal DF_CfgNode *df_cfg_tree_copy(Arena *arena, DF_CfgNode *src_root); internal DF_CfgNode *df_cfg_tree_copy(Arena *arena, DF_CfgNode *src_root);
internal DF_CfgNodeRec df_cfg_node_rec__depth_first_pre(DF_CfgNode *node, DF_CfgNode *root); internal DF_CfgNodeRec df_cfg_node_rec__depth_first_pre(DF_CfgNode *node, DF_CfgNode *root);
#endif
internal DF_CfgTree *df_cfg_tree_copy(Arena *arena, DF_CfgTree *src);
internal void df_cfg_table_push_unparsed_string(Arena *arena, DF_CfgTable *table, String8 string, DF_CfgSrc source); internal void df_cfg_table_push_unparsed_string(Arena *arena, DF_CfgTable *table, String8 string, DF_CfgSrc source);
internal DF_CfgTable df_cfg_table_from_inheritance(Arena *arena, DF_CfgTable *src); internal DF_CfgTable df_cfg_table_from_inheritance(Arena *arena, DF_CfgTable *src);
internal DF_CfgTable df_cfg_table_copy(Arena *arena, DF_CfgTable *src); internal DF_CfgTable df_cfg_table_copy(Arena *arena, DF_CfgTable *src);
internal DF_CfgVal *df_cfg_val_from_string(DF_CfgTable *table, String8 string); internal DF_CfgVal *df_cfg_val_from_string(DF_CfgTable *table, String8 string);
#if 0
internal DF_CfgNode *df_cfg_node_child_from_string(DF_CfgNode *node, String8 string, StringMatchFlags flags); internal DF_CfgNode *df_cfg_node_child_from_string(DF_CfgNode *node, String8 string, StringMatchFlags flags);
internal DF_CfgNode *df_first_cfg_node_child_from_flags(DF_CfgNode *node, DF_CfgNodeFlags flags); internal DF_CfgNode *df_first_cfg_node_child_from_flags(DF_CfgNode *node, DF_CfgNodeFlags flags);
internal String8 df_string_from_cfg_node_children(Arena *arena, DF_CfgNode *node); internal String8 df_string_from_cfg_node_children(Arena *arena, DF_CfgNode *node);
internal Vec4F32 df_hsva_from_cfg_node(DF_CfgNode *node); internal Vec4F32 df_hsva_from_cfg_node(DF_CfgNode *node);
internal String8 df_string_from_cfg_node_key(DF_CfgNode *node, String8 key, StringMatchFlags flags); internal String8 df_string_from_cfg_node_key(DF_CfgNode *node, String8 key, StringMatchFlags flags);
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Debug Info Extraction Type Pure Functions //~ rjf: Debug Info Extraction Type Pure Functions
@@ -1650,13 +1670,13 @@ internal String8 df_expr_string_from_viz_row(Arena *arena, DF_EvalVizRow *row);
internal B32 df_viz_row_is_expandable(DF_EvalVizRow *row); internal B32 df_viz_row_is_expandable(DF_EvalVizRow *row);
internal B32 df_viz_row_is_editable(DF_EvalVizRow *row); internal B32 df_viz_row_is_editable(DF_EvalVizRow *row);
//- rjf: eval / view rule config tree info extraction //- rjf: eval / view rule params tree info extraction
internal U64 df_base_offset_from_eval(E_Eval eval); internal U64 df_base_offset_from_eval(E_Eval eval);
internal E_Value df_value_from_cfg_key(DF_CfgNode *cfg, String8 key); internal E_Value df_value_from_params_key(MD_Node *params, String8 key);
internal Rng1U64 df_range_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); internal Rng1U64 df_range_from_eval_params(E_Eval eval, MD_Node *params);
internal TXT_LangKind df_lang_kind_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); internal TXT_LangKind df_lang_kind_from_eval_params(E_Eval eval, MD_Node *params);
internal Vec2S32 df_dim2s32_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); internal Vec2S32 df_dim2s32_from_eval_params(E_Eval eval, MD_Node *params);
internal R_Tex2DFormat df_tex2dformat_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); internal R_Tex2DFormat df_tex2dformat_from_eval_params(E_Eval eval, MD_Node *params);
//- rjf: view rule eval application //- rjf: view rule eval application
internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg); internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg);
+1 -1
View File
@@ -99,7 +99,7 @@ DF_CmdParamSlotTable:
{TextPoint text_point `TxtPt`} {TextPoint text_point `TxtPt`}
{CmdSpec cmd_spec `struct DF_CmdSpec *`} {CmdSpec cmd_spec `struct DF_CmdSpec *`}
{ViewSpec view_spec `struct DF_ViewSpec *`} {ViewSpec view_spec `struct DF_ViewSpec *`}
{CfgNode cfg_node `struct DF_CfgNode *`} {ParamsTree params_tree `MD_Node *`}
{OSEvent os_event `struct OS_Event *`} {OSEvent os_event `struct OS_Event *`}
{VirtualAddr vaddr `U64`} {VirtualAddr vaddr `U64`}
{VirtualOff voff `U64`} {VirtualOff voff `U64`}
+1 -1
View File
@@ -19,7 +19,7 @@ Rng1U64 df_g_cmd_param_slot_range_table[24] =
{OffsetOf(DF_CmdParams, text_point), OffsetOf(DF_CmdParams, text_point) + sizeof(TxtPt)}, {OffsetOf(DF_CmdParams, text_point), OffsetOf(DF_CmdParams, text_point) + sizeof(TxtPt)},
{OffsetOf(DF_CmdParams, cmd_spec), OffsetOf(DF_CmdParams, cmd_spec) + sizeof(struct DF_CmdSpec *)}, {OffsetOf(DF_CmdParams, cmd_spec), OffsetOf(DF_CmdParams, cmd_spec) + sizeof(struct DF_CmdSpec *)},
{OffsetOf(DF_CmdParams, view_spec), OffsetOf(DF_CmdParams, view_spec) + sizeof(struct DF_ViewSpec *)}, {OffsetOf(DF_CmdParams, view_spec), OffsetOf(DF_CmdParams, view_spec) + sizeof(struct DF_ViewSpec *)},
{OffsetOf(DF_CmdParams, cfg_node), OffsetOf(DF_CmdParams, cfg_node) + sizeof(struct DF_CfgNode *)}, {OffsetOf(DF_CmdParams, params_tree), OffsetOf(DF_CmdParams, params_tree) + sizeof(MD_Node *)},
{OffsetOf(DF_CmdParams, os_event), OffsetOf(DF_CmdParams, os_event) + sizeof(struct OS_Event *)}, {OffsetOf(DF_CmdParams, os_event), OffsetOf(DF_CmdParams, os_event) + sizeof(struct OS_Event *)},
{OffsetOf(DF_CmdParams, vaddr), OffsetOf(DF_CmdParams, vaddr) + sizeof(U64)}, {OffsetOf(DF_CmdParams, vaddr), OffsetOf(DF_CmdParams, vaddr) + sizeof(U64)},
{OffsetOf(DF_CmdParams, voff), OffsetOf(DF_CmdParams, voff) + sizeof(U64)}, {OffsetOf(DF_CmdParams, voff), OffsetOf(DF_CmdParams, voff) + sizeof(U64)},
+2 -2
View File
@@ -387,7 +387,7 @@ DF_CmdParamSlot_FilePath,
DF_CmdParamSlot_TextPoint, DF_CmdParamSlot_TextPoint,
DF_CmdParamSlot_CmdSpec, DF_CmdParamSlot_CmdSpec,
DF_CmdParamSlot_ViewSpec, DF_CmdParamSlot_ViewSpec,
DF_CmdParamSlot_CfgNode, DF_CmdParamSlot_ParamsTree,
DF_CmdParamSlot_OSEvent, DF_CmdParamSlot_OSEvent,
DF_CmdParamSlot_VirtualAddr, DF_CmdParamSlot_VirtualAddr,
DF_CmdParamSlot_VirtualOff, DF_CmdParamSlot_VirtualOff,
@@ -417,7 +417,7 @@ String8 file_path;
TxtPt text_point; TxtPt text_point;
struct DF_CmdSpec * cmd_spec; struct DF_CmdSpec * cmd_spec;
struct DF_ViewSpec * view_spec; struct DF_ViewSpec * view_spec;
struct DF_CfgNode * cfg_node; MD_Node * params_tree;
struct OS_Event * os_event; struct OS_Event * os_event;
U64 vaddr; U64 vaddr;
U64 voff; U64 voff;
+147 -154
View File
@@ -578,10 +578,10 @@ df_cmd_params_copy(Arena *arena, DF_CmdParams *src)
dst.entity_list = df_push_handle_list_copy(arena, src->entity_list); dst.entity_list = df_push_handle_list_copy(arena, src->entity_list);
dst.string = push_str8_copy(arena, src->string); dst.string = push_str8_copy(arena, src->string);
dst.file_path = push_str8_copy(arena, src->file_path); dst.file_path = push_str8_copy(arena, src->file_path);
if(src->cfg_node != 0) {dst.cfg_node = df_cfg_tree_copy(arena, src->cfg_node);} if(src->params_tree != 0) {dst.params_tree = md_tree_copy(arena, src->params_tree);}
if(dst.cmd_spec == 0) {dst.cmd_spec = &df_g_nil_cmd_spec;} if(dst.cmd_spec == 0) {dst.cmd_spec = &df_g_nil_cmd_spec;}
if(dst.view_spec == 0) {dst.view_spec = &df_g_nil_view_spec;} if(dst.view_spec == 0) {dst.view_spec = &df_g_nil_view_spec;}
if(dst.cfg_node == 0) {dst.cfg_node = &df_g_nil_cfg_node;} if(dst.params_tree == 0) {dst.params_tree= &md_nil_node;}
return dst; return dst;
} }
@@ -766,6 +766,8 @@ df_gfx_view_rule_spec_from_string(String8 string)
//////////////////////////////// ////////////////////////////////
//~ rjf: View State Functions //~ rjf: View State Functions
//- rjf: allocation/releasing
internal DF_View * internal DF_View *
df_view_alloc(void) df_view_alloc(void)
{ {
@@ -792,8 +794,8 @@ df_view_alloc(void)
view->spec = &df_g_nil_view_spec; view->spec = &df_g_nil_view_spec;
view->project_path_arena = arena_alloc(); view->project_path_arena = arena_alloc();
view->project_path = str8_zero(); view->project_path = str8_zero();
view->cfg_arena = arena_alloc(); view->params_arena = arena_alloc();
view->cfg_root = &df_g_nil_cfg_node; view->params_root = &md_nil_node;
view->query_cursor = view->query_mark = txt_pt(1, 1); view->query_cursor = view->query_mark = txt_pt(1, 1);
view->query_string_size = 0; view->query_string_size = 0;
df_gfx_state->allocated_view_count += 1; df_gfx_state->allocated_view_count += 1;
@@ -820,19 +822,21 @@ df_view_release(DF_View *view)
} }
view->first_arena_ext = view->last_arena_ext = 0; view->first_arena_ext = view->last_arena_ext = 0;
arena_release(view->project_path_arena); arena_release(view->project_path_arena);
arena_release(view->cfg_arena); arena_release(view->params_arena);
arena_release(view->arena); arena_release(view->arena);
view->generation += 1; view->generation += 1;
df_gfx_state->allocated_view_count -= 1; df_gfx_state->allocated_view_count -= 1;
df_gfx_state->free_view_count += 1; df_gfx_state->free_view_count += 1;
} }
//- rjf: equipment
internal void internal void
df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root) df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, MD_Node *params)
{ {
// rjf: fill cfg tree // rjf: fill params tree
arena_clear(view->cfg_arena); arena_clear(view->params_arena);
view->cfg_root = df_cfg_tree_copy(view->cfg_arena, cfg_root); view->params_root = md_tree_copy(view->params_arena, params);
// rjf: fill query buffer // rjf: fill query buffer
view->query_string_size = Min(sizeof(view->query_buffer), query.size); view->query_string_size = Min(sizeof(view->query_buffer), query.size);
@@ -843,7 +847,23 @@ df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8
if(view->spec != spec || spec == &df_g_nil_view_spec) if(view->spec != spec || spec == &df_g_nil_view_spec)
{ {
DF_ViewSetupFunctionType *view_setup = spec->info.setup_hook; DF_ViewSetupFunctionType *view_setup = spec->info.setup_hook;
df_view_clear_user_state(view); {
for(DF_ArenaExt *ext = view->first_arena_ext; ext != 0; ext = ext->next)
{
arena_release(ext->arena);
}
for(DF_View *tchild = view->first_transient, *next = 0; !df_view_is_nil(tchild); tchild = next)
{
next = tchild->order_next;
df_view_release(tchild);
}
view->first_transient = view->last_transient = &df_g_nil_view;
view->first_arena_ext = view->last_arena_ext = 0;
view->transient_view_slots_count = 0;
view->transient_view_slots = 0;
arena_clear(view->arena);
view->user_data = 0;
}
MemoryZeroStruct(&view->scroll_pos); MemoryZeroStruct(&view->scroll_pos);
view->spec = spec; view->spec = spec;
if(spec->info.flags & DF_ViewSpecFlag_ProjectSpecific) if(spec->info.flags & DF_ViewSpecFlag_ProjectSpecific)
@@ -857,7 +877,7 @@ df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8
} }
view->is_filtering = 0; view->is_filtering = 0;
view->is_filtering_t = 0; view->is_filtering_t = 0;
view_setup(window, view, view->cfg_root, str8(view->query_buffer, view->query_string_size)); view_setup(window, view, view->params_root, str8(view->query_buffer, view->query_string_size));
} }
} }
@@ -869,25 +889,7 @@ df_view_equip_loading_info(DF_View *view, B32 is_loading, U64 progress_v, U64 pr
view->loading_progress_v_target = progress_target; view->loading_progress_v_target = progress_target;
} }
internal void //- rjf: user state extensions
df_view_clear_user_state(DF_View *view)
{
for(DF_ArenaExt *ext = view->first_arena_ext; ext != 0; ext = ext->next)
{
arena_release(ext->arena);
}
for(DF_View *tchild = view->first_transient, *next = 0; !df_view_is_nil(tchild); tchild = next)
{
next = tchild->order_next;
df_view_release(tchild);
}
view->first_transient = view->last_transient = &df_g_nil_view;
view->first_arena_ext = view->last_arena_ext = 0;
view->transient_view_slots_count = 0;
view->transient_view_slots = 0;
arena_clear(view->arena);
view->user_data = 0;
}
internal void * internal void *
df_view_get_or_push_user_state(DF_View *view, U64 size) df_view_get_or_push_user_state(DF_View *view, U64 size)
@@ -913,7 +915,7 @@ df_view_push_arena_ext(DF_View *view)
//~ rjf: Expand-Keyed Transient View Functions //~ rjf: Expand-Keyed Transient View Functions
internal DF_View * internal DF_View *
df_transient_view_from_expand_key(DF_View *owner_view, DF_Window *window, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root, DF_ExpandKey key) df_transient_view_from_expand_key(DF_View *owner_view, DF_Window *window, DF_ViewSpec *spec, String8 query, MD_Node *params, DF_ExpandKey key)
{ {
if(owner_view->transient_view_slots_count == 0) if(owner_view->transient_view_slots_count == 0)
{ {
@@ -947,7 +949,7 @@ df_transient_view_from_expand_key(DF_View *owner_view, DF_Window *window, DF_Vie
node->first_frame_index_touched = node->last_frame_index_touched = df_frame_index(); node->first_frame_index_touched = node->last_frame_index_touched = df_frame_index();
view = node->view; view = node->view;
DLLPushBack_NPZ(&df_g_nil_view, owner_view->first_transient, owner_view->last_transient, view, order_next, order_prev); DLLPushBack_NPZ(&df_g_nil_view, owner_view->first_transient, owner_view->last_transient, view, order_next, order_prev);
df_view_equip_spec(window, view, spec, query, cfg_root); df_view_equip_spec(window, view, spec, query, params);
} }
return view; return view;
} }
@@ -1558,87 +1560,87 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
if(df_view_is_nil(watch)) if(df_view_is_nil(watch))
{ {
watch = df_view_alloc(); watch = df_view_alloc();
df_view_equip_spec(ws, watch, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Watch), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, watch, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Watch), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(locals)) if(layout == Layout_Default && df_view_is_nil(locals))
{ {
locals = df_view_alloc(); locals = df_view_alloc();
df_view_equip_spec(ws, locals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Locals), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, locals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Locals), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(regs)) if(layout == Layout_Default && df_view_is_nil(regs))
{ {
regs = df_view_alloc(); regs = df_view_alloc();
df_view_equip_spec(ws, regs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Registers), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, regs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Registers), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(globals)) if(layout == Layout_Default && df_view_is_nil(globals))
{ {
globals = df_view_alloc(); globals = df_view_alloc();
df_view_equip_spec(ws, globals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Globals), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, globals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Globals), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(tlocals)) if(layout == Layout_Default && df_view_is_nil(tlocals))
{ {
tlocals = df_view_alloc(); tlocals = df_view_alloc();
df_view_equip_spec(ws, tlocals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_ThreadLocals), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, tlocals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_ThreadLocals), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(types)) if(df_view_is_nil(types))
{ {
types = df_view_alloc(); types = df_view_alloc();
df_view_equip_spec(ws, types, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Types), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, types, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Types), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(procs)) if(layout == Layout_Default && df_view_is_nil(procs))
{ {
procs = df_view_alloc(); procs = df_view_alloc();
df_view_equip_spec(ws, procs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Procedures), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, procs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Procedures), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(callstack)) if(df_view_is_nil(callstack))
{ {
callstack = df_view_alloc(); callstack = df_view_alloc();
df_view_equip_spec(ws, callstack, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_CallStack), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, callstack, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_CallStack), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(breakpoints)) if(df_view_is_nil(breakpoints))
{ {
breakpoints = df_view_alloc(); breakpoints = df_view_alloc();
df_view_equip_spec(ws, breakpoints, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Breakpoints), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, breakpoints, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Breakpoints), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(watch_pins)) if(layout == Layout_Default && df_view_is_nil(watch_pins))
{ {
watch_pins = df_view_alloc(); watch_pins = df_view_alloc();
df_view_equip_spec(ws, watch_pins, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_WatchPins), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, watch_pins, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_WatchPins), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(output)) if(df_view_is_nil(output))
{ {
output = df_view_alloc(); output = df_view_alloc();
df_view_equip_spec(ws, output, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Output), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, output, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Output), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(targets)) if(df_view_is_nil(targets))
{ {
targets = df_view_alloc(); targets = df_view_alloc();
df_view_equip_spec(ws, targets, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Targets), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, targets, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Targets), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(scheduler)) if(df_view_is_nil(scheduler))
{ {
scheduler = df_view_alloc(); scheduler = df_view_alloc();
df_view_equip_spec(ws, scheduler, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Scheduler), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, scheduler, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Scheduler), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(modules)) if(df_view_is_nil(modules))
{ {
modules = df_view_alloc(); modules = df_view_alloc();
df_view_equip_spec(ws, modules, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Modules), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, modules, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Modules), str8_zero(), &md_nil_node);
} }
if(df_view_is_nil(disasm)) if(df_view_is_nil(disasm))
{ {
disasm = df_view_alloc(); disasm = df_view_alloc();
df_view_equip_spec(ws, disasm, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, disasm, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &md_nil_node);
} }
if(layout == Layout_Default && df_view_is_nil(memory)) if(layout == Layout_Default && df_view_is_nil(memory))
{ {
memory = df_view_alloc(); memory = df_view_alloc();
df_view_equip_spec(ws, memory, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Memory), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, memory, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Memory), str8_zero(), &md_nil_node);
} }
if(code_views.count == 0 && df_view_is_nil(getting_started)) if(code_views.count == 0 && df_view_is_nil(getting_started))
{ {
getting_started = df_view_alloc(); getting_started = df_view_alloc();
df_view_equip_spec(ws, getting_started, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_GettingStarted), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, getting_started, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_GettingStarted), str8_zero(), &md_nil_node);
} }
//- rjf: apply layout //- rjf: apply layout
@@ -2104,7 +2106,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
query = params.string; query = params.string;
} }
df_view_equip_spec(ws, view, spec, query, params.cfg_node); df_view_equip_spec(ws, view, spec, query, params.params_tree);
df_panel_insert_tab_view(panel, panel->last_tab_view, view); df_panel_insert_tab_view(panel, panel->last_tab_view, view);
df_panel_notify_mutation(ws, panel); df_panel_notify_mutation(ws, panel);
} }
@@ -3196,7 +3198,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
DF_View *view = df_view_alloc(); DF_View *view = df_view_alloc();
String8 file_path_query = df_eval_string_from_file_path(scratch.arena, file_path); String8 file_path_query = df_eval_string_from_file_path(scratch.arena, file_path);
df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Code), file_path_query, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Code), file_path_query, &md_nil_node);
df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view); df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view);
dst_view = view; dst_view = view;
} }
@@ -3244,7 +3246,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
if(!df_panel_is_nil(dst_panel) && df_view_is_nil(view_w_disasm)) if(!df_panel_is_nil(dst_panel) && df_view_is_nil(view_w_disasm))
{ {
DF_View *view = df_view_alloc(); DF_View *view = df_view_alloc();
df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &df_g_nil_cfg_node); df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &md_nil_node);
df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view); df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view);
dst_view = view; dst_view = view;
} }
@@ -3438,7 +3440,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
df_push_interact_regs(); df_push_interact_regs();
DF_ViewCmdFunctionType *do_view_cmds_function = view->spec->info.cmd_hook; DF_ViewCmdFunctionType *do_view_cmds_function = view->spec->info.cmd_hook;
do_view_cmds_function(ws, panel, view, view->cfg_root, str8(view->query_buffer, view->query_string_size), cmds); do_view_cmds_function(ws, panel, view, view->params_root, str8(view->query_buffer, view->query_string_size), cmds);
DF_InteractRegs *view_regs = df_pop_interact_regs(); DF_InteractRegs *view_regs = df_pop_interact_regs();
if(panel == ws->focused_panel) if(panel == ws->focused_panel)
{ {
@@ -3664,7 +3666,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
DF_ViewSpec *view_spec = view->spec; DF_ViewSpec *view_spec = view->spec;
DF_ViewUIFunctionType *build_view_ui_function = view_spec->info.ui_hook; DF_ViewUIFunctionType *build_view_ui_function = view_spec->info.ui_hook;
build_view_ui_function(ws, &df_g_nil_panel, view, view->cfg_root, str8(view->query_buffer, view->query_string_size), view_preview_container->rect); build_view_ui_function(ws, &df_g_nil_panel, view, view->params_root, str8(view->query_buffer, view->query_string_size), view_preview_container->rect);
} }
} }
} }
@@ -5960,7 +5962,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
// rjf: construct & push new view // rjf: construct & push new view
DF_View *view = df_view_alloc(); DF_View *view = df_view_alloc();
df_view_equip_spec(ws, view, view_spec, default_query, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, view_spec, default_query, &md_nil_node);
if(cmd_spec->info.query.flags & DF_CmdQueryFlag_SelectOldInput) if(cmd_spec->info.query.flags & DF_CmdQueryFlag_SelectOldInput)
{ {
view->query_mark = txt_pt(1, 1); view->query_mark = txt_pt(1, 1);
@@ -6121,7 +6123,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
DF_ViewSpec *view_spec = view->spec; DF_ViewSpec *view_spec = view->spec;
DF_ViewUIFunctionType *build_view_ui_function = view_spec->info.ui_hook; DF_ViewUIFunctionType *build_view_ui_function = view_spec->info.ui_hook;
build_view_ui_function(ws, &df_g_nil_panel, view, view->cfg_root, str8(view->query_buffer, view->query_string_size), query_container_content_rect); build_view_ui_function(ws, &df_g_nil_panel, view, view->params_root, str8(view->query_buffer, view->query_string_size), query_container_content_rect);
} }
//- rjf: query submission //- rjf: query submission
@@ -7270,7 +7272,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
//- rjf: build empty view //- rjf: build empty view
UI_Parent(view_container_box) if(df_view_is_nil(df_selected_tab_from_panel(panel))) UI_Parent(view_container_box) if(df_view_is_nil(df_selected_tab_from_panel(panel)))
{ {
DF_VIEW_UI_FUNCTION_NAME(Empty)(ws, panel, &df_g_nil_view, &df_g_nil_cfg_node, str8_zero(), content_rect); DF_VIEW_UI_FUNCTION_NAME(Empty)(ws, panel, &df_g_nil_view, &md_nil_node, str8_zero(), content_rect);
} }
//- rjf: build tab view //- rjf: build tab view
@@ -7278,7 +7280,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
DF_View *view = df_selected_tab_from_panel(panel); DF_View *view = df_selected_tab_from_panel(panel);
DF_ViewUIFunctionType *build_view_ui_function = view->spec->info.ui_hook; DF_ViewUIFunctionType *build_view_ui_function = view->spec->info.ui_hook;
build_view_ui_function(ws, panel, view, view->cfg_root, str8(view->query_buffer, view->query_string_size), content_rect); build_view_ui_function(ws, panel, view, view->params_root, str8(view->query_buffer, view->query_string_size), content_rect);
} }
//- rjf: fill with per-view states, after the view has a chance to run //- rjf: fill with per-view states, after the view has a chance to run
@@ -9435,26 +9437,26 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source)
scratch_end(scratch); scratch_end(scratch);
} }
{ {
DF_CfgNodeRec rec = {0}; MD_NodeRec rec = {0};
for(DF_CfgNode *n = view->cfg_root; n != 0 && n != &df_g_nil_cfg_node; n = rec.next) for(MD_Node *n = view->params_root; n != 0 && n != &md_nil_node; n = rec.next)
{ {
rec = df_cfg_node_rec__depth_first_pre(n, view->cfg_root); rec = md_node_rec_depth_first_pre(n, view->params_root);
if(n != view->cfg_root) if(n != view->params_root)
{ {
str8_list_pushf(arena, &strs, "%S", n->string); str8_list_pushf(arena, &strs, "%S", n->string);
if(n->first != &df_g_nil_cfg_node) if(n->first != &md_nil_node)
{ {
str8_list_pushf(arena, &strs, ":{"); str8_list_pushf(arena, &strs, ":{");
} }
for(S32 pop_idx = 0; pop_idx < rec.pop_count; pop_idx += 1) for(S32 pop_idx = 0; pop_idx < rec.pop_count; pop_idx += 1)
{ {
if(pop_idx == rec.pop_count-1 && rec.next == &df_g_nil_cfg_node) if(pop_idx == rec.pop_count-1 && rec.next == &md_nil_node)
{ {
break; break;
} }
str8_list_pushf(arena, &strs, "}"); str8_list_pushf(arena, &strs, "}");
} }
if(rec.pop_count != 0 || n->next != &df_g_nil_cfg_node) if(rec.pop_count != 0 || n->next != &md_nil_node)
{ {
str8_list_pushf(arena, &strs, " "); str8_list_pushf(arena, &strs, " ");
} }
@@ -13398,27 +13400,27 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
{ {
DF_CfgVal *code_font_val = df_cfg_val_from_string(table, str8_lit("code_font")); DF_CfgVal *code_font_val = df_cfg_val_from_string(table, str8_lit("code_font"));
DF_CfgVal *main_font_val = df_cfg_val_from_string(table, str8_lit("main_font")); DF_CfgVal *main_font_val = df_cfg_val_from_string(table, str8_lit("main_font"));
DF_CfgNode *code_font_cfg = code_font_val->last; MD_Node *code_font_node = code_font_val->last->root;
DF_CfgNode *main_font_cfg = main_font_val->last; MD_Node *main_font_node = main_font_val->last->root;
String8 code_font_relative_path = code_font_cfg->first->string; String8 code_font_relative_path = code_font_node->first->string;
String8 main_font_relative_path = main_font_cfg->first->string; String8 main_font_relative_path = main_font_node->first->string;
if(code_font_cfg != &df_g_nil_cfg_node) if(!md_node_is_nil(code_font_node))
{ {
arena_clear(df_gfx_state->cfg_code_font_path_arena); arena_clear(df_gfx_state->cfg_code_font_path_arena);
df_gfx_state->cfg_code_font_path = push_str8_copy(df_gfx_state->cfg_code_font_path_arena, code_font_relative_path); df_gfx_state->cfg_code_font_path = push_str8_copy(df_gfx_state->cfg_code_font_path_arena, code_font_relative_path);
} }
if(main_font_cfg != &df_g_nil_cfg_node) if(!md_node_is_nil(main_font_node))
{ {
arena_clear(df_gfx_state->cfg_main_font_path_arena); arena_clear(df_gfx_state->cfg_main_font_path_arena);
df_gfx_state->cfg_main_font_path = push_str8_copy(df_gfx_state->cfg_main_font_path_arena, main_font_relative_path); df_gfx_state->cfg_main_font_path = push_str8_copy(df_gfx_state->cfg_main_font_path_arena, main_font_relative_path);
} }
String8 code_font_path = path_absolute_dst_from_relative_dst_src(scratch.arena, code_font_relative_path, cfg_folder); String8 code_font_path = path_absolute_dst_from_relative_dst_src(scratch.arena, code_font_relative_path, cfg_folder);
String8 main_font_path = path_absolute_dst_from_relative_dst_src(scratch.arena, main_font_relative_path, cfg_folder); String8 main_font_path = path_absolute_dst_from_relative_dst_src(scratch.arena, main_font_relative_path, cfg_folder);
if(os_file_path_exists(code_font_path) && code_font_cfg != &df_g_nil_cfg_node && code_font_relative_path.size != 0) if(os_file_path_exists(code_font_path) && !md_node_is_nil(code_font_node) && code_font_relative_path.size != 0)
{ {
df_gfx_state->cfg_font_tags[DF_FontSlot_Code] = f_tag_from_path(code_font_path); df_gfx_state->cfg_font_tags[DF_FontSlot_Code] = f_tag_from_path(code_font_path);
} }
if(os_file_path_exists(main_font_path) && main_font_cfg != &df_g_nil_cfg_node && main_font_relative_path.size != 0) if(os_file_path_exists(main_font_path) && !md_node_is_nil(main_font_node) && main_font_relative_path.size != 0)
{ {
df_gfx_state->cfg_font_tags[DF_FontSlot_Main] = f_tag_from_path(main_font_path); df_gfx_state->cfg_font_tags[DF_FontSlot_Main] = f_tag_from_path(main_font_path);
} }
@@ -13434,12 +13436,12 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
//- rjf: build windows & panel layouts //- rjf: build windows & panel layouts
DF_CfgVal *windows = df_cfg_val_from_string(table, str8_lit("window")); DF_CfgVal *windows = df_cfg_val_from_string(table, str8_lit("window"));
for(DF_CfgNode *window_node = windows->first; for(DF_CfgTree *window_tree = windows->first;
window_node != &df_g_nil_cfg_node; window_tree != &df_g_nil_cfg_tree;
window_node = window_node->next) window_tree = window_tree->next)
{ {
// rjf: skip wrong source // rjf: skip wrong source
if(window_node->source != src) if(window_tree->source != src)
{ {
continue; continue;
} }
@@ -13453,35 +13455,35 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
F32 dpi = 0.f; F32 dpi = 0.f;
DF_SettingVal setting_vals[DF_SettingCode_COUNT] = {0}; DF_SettingVal setting_vals[DF_SettingCode_COUNT] = {0};
{ {
for(DF_CfgNode *n = window_node->first; n != &df_g_nil_cfg_node; n = n->next) for(MD_EachNode(n, window_tree->root->first))
{ {
if(n->flags & DF_CfgNodeFlag_Identifier && if(n->flags & MD_NodeFlag_Identifier &&
n->first == &df_g_nil_cfg_node && md_node_is_nil(n->first) &&
str8_match(n->string, str8_lit("split_x"), StringMatchFlag_CaseInsensitive)) str8_match(n->string, str8_lit("split_x"), StringMatchFlag_CaseInsensitive))
{ {
top_level_split_axis = Axis2_X; top_level_split_axis = Axis2_X;
} }
if(n->flags & DF_CfgNodeFlag_Identifier && if(n->flags & MD_NodeFlag_Identifier &&
n->first == &df_g_nil_cfg_node && md_node_is_nil(n->first) &&
str8_match(n->string, str8_lit("split_y"), StringMatchFlag_CaseInsensitive)) str8_match(n->string, str8_lit("split_y"), StringMatchFlag_CaseInsensitive))
{ {
top_level_split_axis = Axis2_Y; top_level_split_axis = Axis2_Y;
} }
if(n->flags & DF_CfgNodeFlag_Identifier && if(n->flags & MD_NodeFlag_Identifier &&
n->first == &df_g_nil_cfg_node && md_node_is_nil(n->first) &&
str8_match(n->string, str8_lit("fullscreen"), StringMatchFlag_CaseInsensitive)) str8_match(n->string, str8_lit("fullscreen"), StringMatchFlag_CaseInsensitive))
{ {
is_fullscreen = 1; is_fullscreen = 1;
} }
if(n->flags & DF_CfgNodeFlag_Identifier && if(n->flags & MD_NodeFlag_Identifier &&
n->first == &df_g_nil_cfg_node && md_node_is_nil(n->first) &&
str8_match(n->string, str8_lit("maximized"), StringMatchFlag_CaseInsensitive)) str8_match(n->string, str8_lit("maximized"), StringMatchFlag_CaseInsensitive))
{ {
is_maximized = 1; is_maximized = 1;
} }
} }
DF_CfgNode *monitor_cfg = df_cfg_node_child_from_string(window_node, str8_lit("monitor"), StringMatchFlag_CaseInsensitive); MD_Node *monitor_node = md_child_from_string(window_tree->root, str8_lit("monitor"), 0);
String8 preferred_monitor_name = monitor_cfg->first->string; String8 preferred_monitor_name = monitor_node->first->string;
for(U64 idx = 0; idx < monitors.count; idx += 1) for(U64 idx = 0; idx < monitors.count; idx += 1)
{ {
String8 monitor_name = os_name_from_monitor(scratch.arena, monitors.v[idx]); String8 monitor_name = os_name_from_monitor(scratch.arena, monitors.v[idx]);
@@ -13492,10 +13494,10 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
} }
} }
Vec2F32 preferred_monitor_size = os_dim_from_monitor(preferred_monitor); Vec2F32 preferred_monitor_size = os_dim_from_monitor(preferred_monitor);
DF_CfgNode *size_cfg = df_cfg_node_child_from_string(window_node, str8_lit("size"), StringMatchFlag_CaseInsensitive); MD_Node *size_node = md_child_from_string(window_tree->root, str8_lit("size"), 0);
{ {
String8 x_string = size_cfg->first->string; String8 x_string = size_node->first->string;
String8 y_string = size_cfg->first->next->string; String8 y_string = size_node->first->next->string;
U64 x_u64 = 0; U64 x_u64 = 0;
U64 y_u64 = 0; U64 y_u64 = 0;
if(!try_u64_from_str8_c_rules(x_string, &x_u64)) if(!try_u64_from_str8_c_rules(x_string, &x_u64))
@@ -13509,16 +13511,16 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
size.x = (F32)x_u64; size.x = (F32)x_u64;
size.y = (F32)y_u64; size.y = (F32)y_u64;
} }
DF_CfgNode *dpi_cfg = df_cfg_node_child_from_string(window_node, str8_lit("dpi"), StringMatchFlag_CaseInsensitive); MD_Node *dpi_node = md_child_from_string(window_tree->root, str8_lit("dpi"), 0);
String8 dpi_cfg_string = df_string_from_cfg_node_children(scratch.arena, dpi_cfg); String8 dpi_string = md_string_from_children(scratch.arena, dpi_node);
dpi = f64_from_str8(dpi_cfg_string); dpi = f64_from_str8(dpi_string);
for(EachEnumVal(DF_SettingCode, code)) for(EachEnumVal(DF_SettingCode, code))
{ {
DF_CfgNode *cfg = df_cfg_node_child_from_string(window_node, df_g_setting_code_lower_string_table[code], StringMatchFlag_CaseInsensitive); MD_Node *code_node = md_child_from_string(window_tree->root, df_g_setting_code_lower_string_table[code], 0);
if(cfg != &df_g_nil_cfg_node) if(!md_node_is_nil(code_node))
{ {
S64 val_s64 = 0; S64 val_s64 = 0;
try_s64_from_str8_c_rules(cfg->first->string, &val_s64); try_s64_from_str8_c_rules(code_node->first->string, &val_s64);
setting_vals[code].set = 1; setting_vals[code].set = 1;
setting_vals[code].s32 = (S32)val_s64; setting_vals[code].s32 = (S32)val_s64;
setting_vals[code].s32 = clamp_1s32(df_g_setting_code_s32_range_table[code], setting_vals[code].s32); setting_vals[code].s32 = clamp_1s32(df_g_setting_code_s32_range_table[code], setting_vals[code].s32);
@@ -13527,7 +13529,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
} }
// rjf: open window // rjf: open window
DF_Window *ws = df_window_open(size, preferred_monitor, window_node->source); DF_Window *ws = df_window_open(size, preferred_monitor, window_tree->source);
if(dpi != 0.f) { ws->last_dpi = dpi; } if(dpi != 0.f) { ws->last_dpi = dpi; }
for(EachEnumVal(DF_SettingCode, code)) for(EachEnumVal(DF_SettingCode, code))
{ {
@@ -13539,12 +13541,12 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
MemoryCopy(ws->setting_vals, setting_vals, sizeof(setting_vals[0])*ArrayCount(setting_vals)); MemoryCopy(ws->setting_vals, setting_vals, sizeof(setting_vals[0])*ArrayCount(setting_vals));
// rjf: build panel tree // rjf: build panel tree
DF_CfgNode *cfg_panels = df_cfg_node_child_from_string(window_node, str8_lit("panels"), StringMatchFlag_CaseInsensitive); MD_Node *panel_tree = md_child_from_string(window_tree->root, str8_lit("panels"), 0);
DF_Panel *panel_parent = ws->root_panel; DF_Panel *panel_parent = ws->root_panel;
panel_parent->split_axis = top_level_split_axis; panel_parent->split_axis = top_level_split_axis;
DF_CfgNodeRec rec = {0}; MD_NodeRec rec = {0};
for(DF_CfgNode *n = cfg_panels, *next = &df_g_nil_cfg_node; for(MD_Node *n = panel_tree, *next = &md_nil_node;
n != &df_g_nil_cfg_node; !md_node_is_nil(n);
n = next) n = next)
{ {
// rjf: assume we're just moving to the next one initially... // rjf: assume we're just moving to the next one initially...
@@ -13552,7 +13554,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
// rjf: grab root panel // rjf: grab root panel
DF_Panel *panel = &df_g_nil_panel; DF_Panel *panel = &df_g_nil_panel;
if(n == cfg_panels) if(n == panel_tree)
{ {
panel = ws->root_panel; panel = ws->root_panel;
panel->pct_of_parent = 1.f; panel->pct_of_parent = 1.f;
@@ -13560,7 +13562,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
// rjf: allocate & insert non-root panels - these will have a numeric string, determining // rjf: allocate & insert non-root panels - these will have a numeric string, determining
// pct of parent // pct of parent
if(n->flags & DF_CfgNodeFlag_Numeric) if(n->flags & MD_NodeFlag_Numeric)
{ {
panel = df_panel_alloc(ws); panel = df_panel_alloc(ws);
df_panel_insert(panel_parent, panel_parent->last, panel); df_panel_insert(panel_parent, panel_parent->last, panel);
@@ -13573,9 +13575,9 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
{ {
// rjf: determine if this panel has panel children // rjf: determine if this panel has panel children
B32 has_panel_children = 0; B32 has_panel_children = 0;
for(DF_CfgNode *child = n->first; child != &df_g_nil_cfg_node; child = child->next) for(MD_EachNode(child, n->first))
{ {
if(child->flags & DF_CfgNodeFlag_Numeric) if(child->flags & MD_NodeFlag_Numeric)
{ {
has_panel_children = 1; has_panel_children = 1;
break; break;
@@ -13583,9 +13585,9 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
} }
// rjf: apply panel options // rjf: apply panel options
for(DF_CfgNode *op = n->first; op != &df_g_nil_cfg_node; op = op->next) for(MD_EachNode(op, n->first))
{ {
if(op->first == &df_g_nil_cfg_node && str8_match(op->string, str8_lit("tabs_on_bottom"), StringMatchFlag_CaseInsensitive)) if(md_node_is_nil(op->first) && str8_match(op->string, str8_lit("tabs_on_bottom"), 0))
{ {
panel->tab_side = Side_Max; panel->tab_side = Side_Max;
} }
@@ -13593,7 +13595,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
// rjf: apply panel views/tabs/commands // rjf: apply panel views/tabs/commands
DF_View *selected_view = &df_g_nil_view; DF_View *selected_view = &df_g_nil_view;
for(DF_CfgNode *op = n->first; op != &df_g_nil_cfg_node; op = op->next) for(MD_EachNode(op, n->first))
{ {
DF_ViewSpec *view_spec = df_view_spec_from_string(op->string); DF_ViewSpec *view_spec = df_view_spec_from_string(op->string);
if(view_spec == &df_g_nil_view_spec || has_panel_children != 0) if(view_spec == &df_g_nil_view_spec || has_panel_children != 0)
@@ -13611,22 +13613,22 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
view = df_view_alloc(); view = df_view_alloc();
// rjf: check if this view is selected // rjf: check if this view is selected
view_is_selected = df_cfg_node_child_from_string(op, str8_lit("selected"), StringMatchFlag_CaseInsensitive) != &df_g_nil_cfg_node; view_is_selected = !md_node_is_nil(md_child_from_string(op, str8_lit("selected"), 0));
// rjf: read project path // rjf: read project path
String8 project_path = str8_lit(""); String8 project_path = str8_lit("");
{ {
DF_CfgNode *project_cfg_node = df_cfg_node_child_from_string(op, str8_lit("project"), StringMatchFlag_CaseInsensitive); MD_Node *project_node = md_child_from_string(op, str8_lit("project"), 0);
if(project_cfg_node != &df_g_nil_cfg_node) if(!md_node_is_nil(project_node))
{ {
project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_cfg_node->first->string, cfg_folder); project_path = path_absolute_dst_from_relative_dst_src(scratch.arena, project_node->first->string, cfg_folder);
} }
} }
// rjf: read view query string // rjf: read view query string
String8 view_query = str8_lit(""); String8 view_query = str8_lit("");
{ {
String8 escaped_query = df_cfg_node_child_from_string(op, str8_lit("query"), StringMatchFlag_CaseInsensitive)->first->string; String8 escaped_query = md_child_from_string(op, str8_lit("query"), 0)->first->string;
view_query = df_cfg_raw_from_escaped_string(scratch.arena, escaped_query); view_query = df_cfg_raw_from_escaped_string(scratch.arena, escaped_query);
} }
@@ -13672,11 +13674,11 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
next = n->first; next = n->first;
panel_parent = panel; panel_parent = panel;
} }
else for(DF_CfgNode *p = n; else for(MD_Node *p = n;
p != &df_g_nil_cfg_node && p != cfg_panels; p != &md_nil_node && p != panel_tree;
p = p->parent, panel_parent = panel_parent->parent) p = p->parent, panel_parent = panel_parent->parent)
{ {
if(p->next != &df_g_nil_cfg_node) if(p->next != &md_nil_node)
{ {
next = p->next; next = p->next;
break; break;
@@ -13726,34 +13728,30 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
df_clear_bindings(); df_clear_bindings();
} }
DF_CfgVal *keybindings = df_cfg_val_from_string(table, str8_lit("keybindings")); DF_CfgVal *keybindings = df_cfg_val_from_string(table, str8_lit("keybindings"));
for(DF_CfgNode *keybinding_set = keybindings->first; for(DF_CfgTree *keybinding_set = keybindings->first;
keybinding_set != &df_g_nil_cfg_node; keybinding_set != &df_g_nil_cfg_tree;
keybinding_set = keybinding_set->next) keybinding_set = keybinding_set->next)
{ {
for(DF_CfgNode *keybind = keybinding_set->first; for(MD_EachNode(keybind, keybinding_set->root->first))
keybind != &df_g_nil_cfg_node;
keybind = keybind->next)
{ {
DF_CmdSpec *cmd_spec = &df_g_nil_cmd_spec; DF_CmdSpec *cmd_spec = &df_g_nil_cmd_spec;
OS_Key key = OS_Key_Null; OS_Key key = OS_Key_Null;
DF_CfgNode *ctrl_cfg = &df_g_nil_cfg_node; MD_Node *ctrl_node = &md_nil_node;
DF_CfgNode *shift_cfg = &df_g_nil_cfg_node; MD_Node *shift_node = &md_nil_node;
DF_CfgNode *alt_cfg = &df_g_nil_cfg_node; MD_Node *alt_node = &md_nil_node;
for(DF_CfgNode *child = keybind->first; for(MD_EachNode(child, keybind->first))
child != &df_g_nil_cfg_node;
child = child->next)
{ {
if(str8_match(child->string, str8_lit("ctrl"), StringMatchFlag_CaseInsensitive)) if(str8_match(child->string, str8_lit("ctrl"), 0))
{ {
ctrl_cfg = child; ctrl_node = child;
} }
else if(str8_match(child->string, str8_lit("shift"), StringMatchFlag_CaseInsensitive)) else if(str8_match(child->string, str8_lit("shift"), 0))
{ {
shift_cfg = child; shift_node = child;
} }
else if(str8_match(child->string, str8_lit("alt"), StringMatchFlag_CaseInsensitive)) else if(str8_match(child->string, str8_lit("alt"), 0))
{ {
alt_cfg = child; alt_node = child;
} }
else else
{ {
@@ -13780,9 +13778,9 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
if(!df_cmd_spec_is_nil(cmd_spec) && key != OS_Key_Null) if(!df_cmd_spec_is_nil(cmd_spec) && key != OS_Key_Null)
{ {
OS_EventFlags flags = 0; OS_EventFlags flags = 0;
if(ctrl_cfg != &df_g_nil_cfg_node) { flags |= OS_EventFlag_Ctrl; } if(!md_node_is_nil(ctrl_node)) { flags |= OS_EventFlag_Ctrl; }
if(shift_cfg != &df_g_nil_cfg_node) { flags |= OS_EventFlag_Shift; } if(!md_node_is_nil(shift_node)) { flags |= OS_EventFlag_Shift; }
if(alt_cfg != &df_g_nil_cfg_node) { flags |= OS_EventFlag_Alt; } if(!md_node_is_nil(alt_node)) { flags |= OS_EventFlag_Alt; }
DF_Binding binding = {key, flags}; DF_Binding binding = {key, flags};
df_bind_spec(cmd_spec, binding); df_bind_spec(cmd_spec, binding);
} }
@@ -13798,7 +13796,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
B32 preset_applied = 0; B32 preset_applied = 0;
if(color_preset != &df_g_nil_cfg_val) if(color_preset != &df_g_nil_cfg_val)
{ {
String8 color_preset_name = color_preset->last->first->string; String8 color_preset_name = color_preset->last->root->first->string;
DF_ThemePreset preset = (DF_ThemePreset)0; DF_ThemePreset preset = (DF_ThemePreset)0;
B32 found_preset = 0; B32 found_preset = 0;
for(DF_ThemePreset p = (DF_ThemePreset)0; p < DF_ThemePreset_COUNT; p = (DF_ThemePreset)(p+1)) for(DF_ThemePreset p = (DF_ThemePreset)0; p < DF_ThemePreset_COUNT; p = (DF_ThemePreset)(p+1))
@@ -13821,13 +13819,11 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
//- rjf: apply individual theme colors //- rjf: apply individual theme colors
B8 theme_color_hit[DF_ThemeColor_COUNT] = {0}; B8 theme_color_hit[DF_ThemeColor_COUNT] = {0};
DF_CfgVal *colors = df_cfg_val_from_string(table, str8_lit("colors")); DF_CfgVal *colors = df_cfg_val_from_string(table, str8_lit("colors"));
for(DF_CfgNode *colors_set = colors->first; for(DF_CfgTree *colors_set = colors->first;
colors_set != &df_g_nil_cfg_node; colors_set != &df_g_nil_cfg_tree;
colors_set = colors_set->next) colors_set = colors_set->next)
{ {
for(DF_CfgNode *color = colors_set->first; for(MD_EachNode(color, colors_set->root->first))
color != &df_g_nil_cfg_node;
color = color->next)
{ {
String8 saved_color_name = color->string; String8 saved_color_name = color->string;
String8List candidate_color_names = {0}; String8List candidate_color_names = {0};
@@ -13854,7 +13850,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
if(color_code != DF_ThemeColor_Null) if(color_code != DF_ThemeColor_Null)
{ {
theme_color_hit[color_code] = 1; theme_color_hit[color_code] = 1;
DF_CfgNode *hex_cfg = color->first; MD_Node *hex_cfg = color->first;
String8 hex_string = hex_cfg->string; String8 hex_string = hex_cfg->string;
U64 hex_val = 0; U64 hex_val = 0;
try_u64_from_str8_c_rules(hex_string, &hex_val); try_u64_from_str8_c_rules(hex_string, &hex_val);
@@ -13924,20 +13920,17 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
{ {
String8 name = df_g_setting_code_lower_string_table[code]; String8 name = df_g_setting_code_lower_string_table[code];
DF_CfgVal *code_cfg_val = df_cfg_val_from_string(table, name); DF_CfgVal *code_cfg_val = df_cfg_val_from_string(table, name);
DF_CfgNode *root_node = code_cfg_val->last; DF_CfgTree *code_tree = code_cfg_val->last;
if(root_node->source == src) if(code_tree->source == src)
{ {
DF_CfgNode *val_node = root_node->first; MD_Node *val_node = code_tree->root->first;
S64 val = 0; S64 val = 0;
if(try_s64_from_str8_c_rules(val_node->string, &val)) if(try_s64_from_str8_c_rules(val_node->string, &val))
{ {
df_gfx_state->cfg_setting_vals[src][code].set = 1; df_gfx_state->cfg_setting_vals[src][code].set = 1;
df_gfx_state->cfg_setting_vals[src][code].s32 = (S32)val; df_gfx_state->cfg_setting_vals[src][code].s32 = (S32)val;
} }
if(val_node != &df_g_nil_cfg_node) setting_codes_hit[code] = !md_node_is_nil(val_node);
{
setting_codes_hit[code] = 1;
}
} }
} }
@@ -13954,7 +13947,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
} }
//- rjf: if config opened 0 windows, we need to do some sensible default //- rjf: if config opened 0 windows, we need to do some sensible default
if(src == DF_CfgSrc_User && windows->first == &df_g_nil_cfg_node) if(src == DF_CfgSrc_User && windows->first == &df_g_nil_cfg_tree)
{ {
OS_Handle preferred_monitor = os_primary_monitor(); OS_Handle preferred_monitor = os_primary_monitor();
Vec2F32 monitor_dim = os_dim_from_monitor(preferred_monitor); Vec2F32 monitor_dim = os_dim_from_monitor(preferred_monitor);
+14 -10
View File
@@ -83,17 +83,17 @@ typedef struct DF_View DF_View;
typedef struct DF_Panel DF_Panel; typedef struct DF_Panel DF_Panel;
typedef struct DF_Window DF_Window; typedef struct DF_Window DF_Window;
#define DF_VIEW_SETUP_FUNCTION_SIG(name) void name(DF_Window *ws, struct DF_View *view, DF_CfgNode *cfg, String8 string) #define DF_VIEW_SETUP_FUNCTION_SIG(name) void name(DF_Window *ws, struct DF_View *view, MD_Node *params, String8 string)
#define DF_VIEW_SETUP_FUNCTION_NAME(name) df_view_setup_##name #define DF_VIEW_SETUP_FUNCTION_NAME(name) df_view_setup_##name
#define DF_VIEW_SETUP_FUNCTION_DEF(name) internal DF_VIEW_SETUP_FUNCTION_SIG(DF_VIEW_SETUP_FUNCTION_NAME(name)) #define DF_VIEW_SETUP_FUNCTION_DEF(name) internal DF_VIEW_SETUP_FUNCTION_SIG(DF_VIEW_SETUP_FUNCTION_NAME(name))
typedef DF_VIEW_SETUP_FUNCTION_SIG(DF_ViewSetupFunctionType); typedef DF_VIEW_SETUP_FUNCTION_SIG(DF_ViewSetupFunctionType);
#define DF_VIEW_CMD_FUNCTION_SIG(name) void name(struct DF_Window *ws, struct DF_Panel *panel, struct DF_View *view, DF_CfgNode *cfg, String8 string, struct DF_CmdList *cmds) #define DF_VIEW_CMD_FUNCTION_SIG(name) void name(struct DF_Window *ws, struct DF_Panel *panel, struct DF_View *view, MD_Node *params, String8 string, struct DF_CmdList *cmds)
#define DF_VIEW_CMD_FUNCTION_NAME(name) df_view_cmds_##name #define DF_VIEW_CMD_FUNCTION_NAME(name) df_view_cmds_##name
#define DF_VIEW_CMD_FUNCTION_DEF(name) internal DF_VIEW_CMD_FUNCTION_SIG(DF_VIEW_CMD_FUNCTION_NAME(name)) #define DF_VIEW_CMD_FUNCTION_DEF(name) internal DF_VIEW_CMD_FUNCTION_SIG(DF_VIEW_CMD_FUNCTION_NAME(name))
typedef DF_VIEW_CMD_FUNCTION_SIG(DF_ViewCmdFunctionType); typedef DF_VIEW_CMD_FUNCTION_SIG(DF_ViewCmdFunctionType);
#define DF_VIEW_UI_FUNCTION_SIG(name) void name(struct DF_Window *ws, struct DF_Panel *panel, struct DF_View *view, DF_CfgNode *cfg, String8 string, Rng2F32 rect) #define DF_VIEW_UI_FUNCTION_SIG(name) void name(struct DF_Window *ws, struct DF_Panel *panel, struct DF_View *view, MD_Node *params, String8 string, Rng2F32 rect)
#define DF_VIEW_UI_FUNCTION_NAME(name) df_view_ui_##name #define DF_VIEW_UI_FUNCTION_NAME(name) df_view_ui_##name
#define DF_VIEW_UI_FUNCTION_DEF(name) internal DF_VIEW_UI_FUNCTION_SIG(DF_VIEW_UI_FUNCTION_NAME(name)) #define DF_VIEW_UI_FUNCTION_DEF(name) internal DF_VIEW_UI_FUNCTION_SIG(DF_VIEW_UI_FUNCTION_NAME(name))
typedef DF_VIEW_UI_FUNCTION_SIG(DF_ViewUIFunctionType); typedef DF_VIEW_UI_FUNCTION_SIG(DF_ViewUIFunctionType);
@@ -231,9 +231,9 @@ struct DF_View
B32 is_filtering; B32 is_filtering;
F32 is_filtering_t; F32 is_filtering_t;
// rjf: configuration tree state // rjf: params tree state
Arena *cfg_arena; Arena *params_arena;
DF_CfgNode *cfg_root; MD_Node *params_root;
// rjf: text query state // rjf: text query state
TxtPt query_cursor; TxtPt query_cursor;
@@ -339,7 +339,7 @@ enum
#define DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_NAME(name) df_gfx_view_rule_line_stringize__##name #define DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_NAME(name) df_gfx_view_rule_line_stringize__##name
#define DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_DEF(name) internal DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_SIG(DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_NAME(name)) #define DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_DEF(name) internal DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_SIG(DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_NAME(name))
#define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_SIG(name) void name(struct DF_Window *ws, DF_ExpandKey key, E_Eval eval, struct DF_CfgNode *cfg) #define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_SIG(name) void name(struct DF_Window *ws, DF_ExpandKey key, E_Eval eval, MD_Node *params)
#define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(name) df_gfx_view_rule_row_ui__##name #define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(name) df_gfx_view_rule_row_ui__##name
#define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(name) DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_SIG(DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(name)) #define DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(name) DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_SIG(DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(name))
@@ -948,11 +948,15 @@ internal DF_GfxViewRuleSpec *df_gfx_view_rule_spec_from_string(String8 string);
//////////////////////////////// ////////////////////////////////
//~ rjf: View State Functions //~ rjf: View State Functions
//- rjf: allocation/releasing
internal DF_View *df_view_alloc(void); internal DF_View *df_view_alloc(void);
internal void df_view_release(DF_View *view); internal void df_view_release(DF_View *view);
internal void df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root);
//- rjf: equipment
internal void df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, MD_Node *params);
internal void df_view_equip_loading_info(DF_View *view, B32 is_loading, U64 progress_v, U64 progress_target); internal void df_view_equip_loading_info(DF_View *view, B32 is_loading, U64 progress_v, U64 progress_target);
internal void df_view_clear_user_state(DF_View *view);
//- rjf: user state extensions
internal void *df_view_get_or_push_user_state(DF_View *view, U64 size); internal void *df_view_get_or_push_user_state(DF_View *view, U64 size);
internal Arena *df_view_push_arena_ext(DF_View *view); internal Arena *df_view_push_arena_ext(DF_View *view);
#define df_view_user_state(view, type) (type *)df_view_get_or_push_user_state((view), sizeof(type)) #define df_view_user_state(view, type) (type *)df_view_get_or_push_user_state((view), sizeof(type))
@@ -960,7 +964,7 @@ internal Arena *df_view_push_arena_ext(DF_View *view);
//////////////////////////////// ////////////////////////////////
//~ rjf: Expand-Keyed Transient View Functions //~ rjf: Expand-Keyed Transient View Functions
internal DF_View *df_transient_view_from_expand_key(DF_View *owner_view, DF_Window *window, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root, DF_ExpandKey key); internal DF_View *df_transient_view_from_expand_key(DF_View *owner_view, DF_Window *window, DF_ViewSpec *spec, String8 query, MD_Node *params, DF_ExpandKey key);
//////////////////////////////// ////////////////////////////////
//~ rjf: View Rule Instance State Functions //~ rjf: View Rule Instance State Functions
+1 -1
View File
@@ -331,7 +331,7 @@ DF_GfxViewRuleTable:
{"rgba" - - x x "" } {"rgba" - - x x "" }
{"text" - - - x "code" } {"text" - - - x "code" }
{"disasm" - - - x "disassembly" } {"disasm" - - - x "disassembly" }
{"bitmap" - - x x "bitmap" } {"bitmap" - - - x "bitmap" }
{"geo" - - x x "geometry" } {"geo" - - x x "geometry" }
} }
+17 -161
View File
@@ -173,6 +173,7 @@ DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(default)
DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array) DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array)
{ {
#if 0
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
E_TypeKey type_key = eval.type_key; E_TypeKey type_key = eval.type_key;
E_TypeKind type_kind = e_type_kind_from_key(type_key); E_TypeKind type_kind = e_type_kind_from_key(type_key);
@@ -203,6 +204,7 @@ DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array)
} }
} }
scratch_end(scratch); scratch_end(scratch);
#endif
return eval; return eval;
} }
@@ -656,23 +658,6 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(rgba)
//////////////////////////////// ////////////////////////////////
//~ rjf: "text" //~ rjf: "text"
internal DF_TxtTopologyInfo
df_vr_txt_topology_info_from_cfg(DF_CfgNode *cfg)
{
Temp scratch = scratch_begin(0, 0);
DF_TxtTopologyInfo result = zero_struct;
{
StringJoin join = {0};
join.sep = str8_lit(" ");
DF_CfgNode *lang_cfg = df_cfg_node_child_from_string(cfg, str8_lit("lang"), 0);
String8 lang_string = {0};
lang_string = lang_cfg->first->string;
result.lang = txt_lang_kind_from_extension(lang_string);
}
scratch_end(scratch);
return result;
}
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(text) DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(text)
{ {
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth); DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
@@ -684,132 +669,9 @@ DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(text)
df_eval_viz_block_end(out, vb); df_eval_viz_block_end(out, vb);
} }
#if 0
DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(text)
{
Temp scratch = scratch_begin(0, 0);
HS_Scope *hs_scope = hs_scope_open();
TXT_Scope *txt_scope = txt_scope_open();
//////////////////////////////
//- rjf: get & initialize state
//
DF_VR_TextState *state = df_view_rule_block_user_state(key, DF_VR_TextState);
if(!state->initialized)
{
state->initialized = 1;
state->cursor = state->mark = txt_pt(1, 1);
}
//////////////////////////////
//- rjf: unpack evaluation / view rule params
//
Rng1U64 range = df_range_from_eval_cfg(eval, cfg);
DF_TxtTopologyInfo top = df_vr_txt_topology_info_from_cfg(cfg);
//////////////////////////////
//- rjf: evaluation info -> text visualization info
//
String8 data = {0};
TXT_TextInfo info = {0};
TXT_LineTokensSlice line_tokens_slice = {0};
U128 text_key = df_key_from_eval_space_range(eval.space, range);
{
U128 text_hash = {0};
info = txt_text_info_from_key_lang(txt_scope, text_key, top.lang, &text_hash);
data = hs_data_from_hash(hs_scope, text_hash);
line_tokens_slice = txt_line_tokens_slice_from_info_data_line_range(scratch.arena, &info, data, r1s64(1, info.lines_count));
}
//////////////////////////////
//- rjf: info -> code slice info
//
DF_CodeSliceParams code_slice_params = {0};
{
code_slice_params.flags = DF_CodeSliceFlag_LineNums;
code_slice_params.line_num_range = r1s64(1, info.lines_count);
code_slice_params.line_text = push_array(scratch.arena, String8, info.lines_count);
code_slice_params.line_ranges = push_array(scratch.arena, Rng1U64, info.lines_count);
code_slice_params.line_tokens = push_array(scratch.arena, TXT_TokenArray, info.lines_count);
code_slice_params.line_bps = push_array(scratch.arena, DF_EntityList, info.lines_count);
code_slice_params.line_ips = push_array(scratch.arena, DF_EntityList, info.lines_count);
code_slice_params.line_pins = push_array(scratch.arena, DF_EntityList, info.lines_count);
code_slice_params.line_vaddrs = push_array(scratch.arena, U64, info.lines_count);
code_slice_params.line_infos = push_array(scratch.arena, DF_LineList, info.lines_count);
for(U64 line_idx = 0; line_idx < info.lines_count; line_idx += 1)
{
code_slice_params.line_text[line_idx] = str8_substr(data, info.lines_ranges[line_idx]);
code_slice_params.line_ranges[line_idx] = info.lines_ranges[line_idx];
code_slice_params.line_tokens[line_idx] = line_tokens_slice.line_tokens[line_idx];
}
code_slice_params.font = df_font_from_slot(DF_FontSlot_Code);
code_slice_params.font_size = ui_top_font_size();
code_slice_params.tab_size = f_column_size_from_tag_size(code_slice_params.font, code_slice_params.font_size)*df_setting_val_from_code(ws, DF_SettingCode_TabWidth).s32;
code_slice_params.line_height_px = ui_top_font_size()*1.5f;
code_slice_params.priority_margin_width_px = 0;
code_slice_params.catchall_margin_width_px = 0;
code_slice_params.line_num_width_px = ui_top_font_size()*5.f;
code_slice_params.line_text_max_width_px = ui_top_font_size()*2.f*info.lines_max_size;
}
//////////////////////////////
//- rjf: build UI
//
if(info.lines_count != 0)
{
//- rjf: build top-level container
UI_Box *container = &ui_g_nil_box;
UI_PrefWidth(ui_px(dim.x, 1.f)) UI_PrefHeight(ui_px(dim.y, 1.f))
{
container = ui_build_box_from_stringf(UI_BoxFlag_AllowOverflow|UI_BoxFlag_Clip, "###text_container");
}
//- rjf: build code slice
UI_WidthFill UI_HeightFill UI_Parent(container)
{
DF_CodeSliceSignal slice_sig = df_code_slice(ws, &code_slice_params, &state->cursor, &state->mark, &state->preferred_column, str8_lit("###slice"));
}
}
txt_scope_close(txt_scope);
hs_scope_close(hs_scope);
scratch_end(scratch);
}
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: "disasm" //~ rjf: "disasm"
internal DF_DisasmTopologyInfo
df_vr_disasm_topology_info_from_cfg(DF_CfgNode *cfg)
{
Temp scratch = scratch_begin(0, 0);
DF_DisasmTopologyInfo result = zero_struct;
{
StringJoin join = {0};
join.sep = str8_lit(" ");
DF_CfgNode *size_cfg = df_cfg_node_child_from_string(cfg, str8_lit("size"), 0);
DF_CfgNode *arch_cfg = df_cfg_node_child_from_string(cfg, str8_lit("arch"), 0);
String8List size_expr_strs = {0};
String8 arch_string = {0};
for(DF_CfgNode *child = size_cfg->first; child != &df_g_nil_cfg_node; child = child->next)
{
str8_list_push(scratch.arena, &size_expr_strs, child->string);
}
arch_string = arch_cfg->first->string;
String8 size_expr = str8_list_join(scratch.arena, &size_expr_strs, &join);
E_Eval size_eval = e_eval_from_string(scratch.arena, size_expr);
E_Eval size_val_eval = e_value_eval_from_eval(size_eval);
if(str8_match(arch_string, str8_lit("x64"), StringMatchFlag_CaseInsensitive))
{
result.arch = Architecture_x64;
}
result.size_cap = size_val_eval.value.u64;
}
scratch_end(scratch);
return result;
}
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(disasm) DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(disasm)
{ {
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth); DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
@@ -941,6 +803,18 @@ DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(graph)
//////////////////////////////// ////////////////////////////////
//~ rjf: "bitmap" //~ rjf: "bitmap"
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(bitmap)
{
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->string = string;
vb->expr = expr;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
vb->cfg_table = cfg_table;
df_eval_viz_block_end(out, vb);
}
#if 0
internal Vec2F32 internal Vec2F32
df_bitmap_view_state__screen_from_canvas_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 cvs) df_bitmap_view_state__screen_from_canvas_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 cvs)
{ {
@@ -1057,27 +931,7 @@ internal UI_BOX_CUSTOM_DRAW(df_vr_bitmap_box_draw)
indicator_color, 3.f, 4.f, 1.f); indicator_color, 3.f, 4.f, 1.f);
} }
} }
#endif
DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(bitmap)
{
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->string = string;
vb->expr = expr;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
vb->cfg_table = cfg_table;
df_eval_viz_block_end(out, vb);
}
DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(bitmap)
{
E_Eval value_eval = e_value_eval_from_eval(eval);
U64 base_vaddr = value_eval.value.u64;
DF_BitmapTopologyInfo topology = df_vr_bitmap_topology_info_from_cfg(cfg);
U64 expected_size = topology.width*topology.height*r_tex2d_format_bytes_per_pixel_table[topology.fmt];
DF_Font(ws, DF_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
ui_labelf("0x%I64x -> Bitmap (%I64u x %I64u)", base_vaddr, topology.width, topology.height);
}
#if 0 #if 0
DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(bitmap) DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(bitmap)
@@ -1202,6 +1056,7 @@ DF_VIEW_UI_FUNCTION_DEF(bitmap)
//////////////////////////////// ////////////////////////////////
//~ rjf: "geo" //~ rjf: "geo"
#if 0
internal DF_GeoTopologyInfo internal DF_GeoTopologyInfo
df_vr_geo_topology_info_from_cfg(DF_CfgNode *cfg) df_vr_geo_topology_info_from_cfg(DF_CfgNode *cfg)
{ {
@@ -1244,6 +1099,7 @@ df_vr_geo_topology_info_from_cfg(DF_CfgNode *cfg)
scratch_end(scratch); scratch_end(scratch);
return result; return result;
} }
#endif
internal UI_BOX_CUSTOM_DRAW(df_vr_geo_box_draw) internal UI_BOX_CUSTOM_DRAW(df_vr_geo_box_draw)
{ {
+4 -24
View File
@@ -17,28 +17,6 @@ struct DF_VR_RGBAState
internal Vec4F32 df_vr_rgba_from_eval(E_Eval eval, DF_Entity *process); internal Vec4F32 df_vr_rgba_from_eval(E_Eval eval, DF_Entity *process);
internal void df_vr_eval_commit_rgba(E_Eval eval, Vec4F32 rgba); internal void df_vr_eval_commit_rgba(E_Eval eval, Vec4F32 rgba);
////////////////////////////////
//~ rjf: "text"
typedef struct DF_TxtTopologyInfo DF_TxtTopologyInfo;
struct DF_TxtTopologyInfo
{
TXT_LangKind lang;
};
typedef struct DF_VR_TextState DF_VR_TextState;
struct DF_VR_TextState
{
B32 initialized;
TxtPt cursor;
TxtPt mark;
S64 preferred_column;
U64 last_open_frame_idx;
F32 loaded_t;
};
internal DF_TxtTopologyInfo df_vr_txt_topology_info_from_cfg(DF_CfgNode *cfg);
//////////////////////////////// ////////////////////////////////
//~ rjf: "disasm" //~ rjf: "disasm"
@@ -60,8 +38,6 @@ struct DF_VR_DisasmState
F32 loaded_t; F32 loaded_t;
}; };
internal DF_DisasmTopologyInfo df_vr_disasm_topology_info_from_cfg(DF_CfgNode *cfg);
//////////////////////////////// ////////////////////////////////
//~ rjf: "bitmap" //~ rjf: "bitmap"
@@ -101,11 +77,13 @@ struct DF_VR_BitmapBoxDrawData
F32 ui_per_bmp_px; F32 ui_per_bmp_px;
}; };
#if 0
internal Vec2F32 df_bitmap_view_state__screen_from_canvas_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 cvs); internal Vec2F32 df_bitmap_view_state__screen_from_canvas_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 cvs);
internal Rng2F32 df_bitmap_view_state__screen_from_canvas_rect(DF_BitmapViewState *bvs, Rng2F32 rect, Rng2F32 cvs); internal Rng2F32 df_bitmap_view_state__screen_from_canvas_rect(DF_BitmapViewState *bvs, Rng2F32 rect, Rng2F32 cvs);
internal Vec2F32 df_bitmap_view_state__canvas_from_screen_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 scr); internal Vec2F32 df_bitmap_view_state__canvas_from_screen_pos(DF_BitmapViewState *bvs, Rng2F32 rect, Vec2F32 scr);
internal Rng2F32 df_bitmap_view_state__canvas_from_screen_rect(DF_BitmapViewState *bvs, Rng2F32 rect, Rng2F32 scr); internal Rng2F32 df_bitmap_view_state__canvas_from_screen_rect(DF_BitmapViewState *bvs, Rng2F32 rect, Rng2F32 scr);
internal DF_BitmapTopologyInfo df_vr_bitmap_topology_info_from_cfg(DF_CfgNode *cfg); internal DF_BitmapTopologyInfo df_vr_bitmap_topology_info_from_cfg(DF_CfgNode *cfg);
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: "geo" //~ rjf: "geo"
@@ -140,6 +118,8 @@ struct DF_VR_GeoBoxDrawData
F32 loaded_t; F32 loaded_t;
}; };
#if 0
internal DF_GeoTopologyInfo df_vr_geo_topology_info_from_cfg(DF_CfgNode *cfg); internal DF_GeoTopologyInfo df_vr_geo_topology_info_from_cfg(DF_CfgNode *cfg);
#endif
#endif // DF_VIEW_RULES_H #endif // DF_VIEW_RULES_H
+39 -129
View File
@@ -2045,12 +2045,12 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
if(row->expand_ui_rule_spec != &df_g_nil_gfx_view_rule_spec && row->expand_ui_rule_spec != 0) if(row->expand_ui_rule_spec != &df_g_nil_gfx_view_rule_spec && row->expand_ui_rule_spec != 0)
{ {
DF_CmdParams p = df_cmd_params_from_view(ws, panel, view); DF_CmdParams p = df_cmd_params_from_view(ws, panel, view);
p.string = e_string_from_expr(scratch.arena, row->expr); p.string = e_string_from_expr(scratch.arena, row->expr);
p.view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name); p.view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name);
p.cfg_node = row->expand_ui_rule_node; p.params_tree = row->expand_ui_rule_params;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_ViewSpec); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_ViewSpec);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_CfgNode); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_ParamsTree);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenTab)); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenTab));
} }
} }
@@ -2709,7 +2709,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
//- rjf: unpack //- rjf: unpack
DF_WatchViewPoint pt = {0, row->parent_key, row->key}; DF_WatchViewPoint pt = {0, row->parent_key, row->key};
DF_ViewSpec *canvas_view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name); DF_ViewSpec *canvas_view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name);
DF_View *canvas_view = df_transient_view_from_expand_key(view, ws, canvas_view_spec, e_string_from_expr(scratch.arena, row->expr), row->expand_ui_rule_node, row->key); DF_View *canvas_view = df_transient_view_from_expand_key(view, ws, canvas_view_spec, e_string_from_expr(scratch.arena, row->expr), row->expand_ui_rule_params, row->key);
Vec2F32 canvas_dim = v2f32(scroll_list_params.dim_px.x - ui_top_font_size()*1.5f, Vec2F32 canvas_dim = v2f32(scroll_list_params.dim_px.x - ui_top_font_size()*1.5f,
(row->skipped_size_in_rows+row->size_in_rows+row->chopped_size_in_rows)*scroll_list_params.row_height_px); (row->skipped_size_in_rows+row->size_in_rows+row->chopped_size_in_rows)*scroll_list_params.row_height_px);
Rng2F32 canvas_rect = r2f32p(rect.x0, Rng2F32 canvas_rect = r2f32p(rect.x0,
@@ -2746,12 +2746,9 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
{ {
DF_ViewSpec *canvas_view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name); DF_ViewSpec *canvas_view_spec = df_view_spec_from_string(row->expand_ui_rule_spec->info.view_spec_name);
DF_CmdParams p = df_cmd_params_from_view(ws, panel, view); DF_CmdParams p = df_cmd_params_from_view(ws, panel, view);
p.string = e_string_from_expr(scratch.arena, row->expr); p.string = e_string_from_expr(scratch.arena, row->expr);
p.view_spec = canvas_view_spec; p.view_spec = canvas_view_spec;
p.cfg_node = row->expand_ui_rule_node; p.params_tree = row->expand_ui_rule_params;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_String);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_ViewSpec);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_CfgNode);
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenTab)); df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_OpenTab));
} }
} }
@@ -2774,7 +2771,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
//- rjf: build //- rjf: build
UI_PermissionFlags(UI_PermissionFlag_Clicks|UI_PermissionFlag_ScrollX) UI_PermissionFlags(UI_PermissionFlag_Clicks|UI_PermissionFlag_ScrollX)
{ {
canvas_view_spec->info.ui_hook(ws, &df_g_nil_panel, canvas_view, canvas_view->cfg_root, str8(canvas_view->query_buffer, canvas_view->query_string_size), canvas_rect); canvas_view_spec->info.ui_hook(ws, &df_g_nil_panel, canvas_view, canvas_view->params_root, str8(canvas_view->query_buffer, canvas_view->query_string_size), canvas_rect);
} }
//- rjf: pop interaction registers //- rjf: pop interaction registers
@@ -2844,7 +2841,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
String8 cell_error_tooltip_string = {0}; String8 cell_error_tooltip_string = {0};
DF_AutoCompListerFlags cell_autocomp_flags = 0; DF_AutoCompListerFlags cell_autocomp_flags = 0;
DF_GfxViewRuleRowUIFunctionType *cell_ui_hook = 0; DF_GfxViewRuleRowUIFunctionType *cell_ui_hook = 0;
DF_CfgNode *cell_ui_node = &df_g_nil_cfg_node; MD_Node *cell_ui_params = &md_nil_node;
Vec4F32 cell_base_color = ui_top_palette()->text; Vec4F32 cell_base_color = ui_top_palette()->text;
DF_IconKind cell_icon = DF_IconKind_Null; DF_IconKind cell_icon = DF_IconKind_Null;
switch(col->kind) switch(col->kind)
@@ -2911,7 +2908,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
if(row->value_ui_rule_spec != &df_g_nil_gfx_view_rule_spec && row->value_ui_rule_spec != 0) if(row->value_ui_rule_spec != &df_g_nil_gfx_view_rule_spec && row->value_ui_rule_spec != 0)
{ {
cell_ui_hook = row->value_ui_rule_spec->info.row_ui; cell_ui_hook = row->value_ui_rule_spec->info.row_ui;
cell_ui_node = row->value_ui_rule_node; cell_ui_params = row->value_ui_rule_params;
} }
cell_can_edit = df_type_key_is_editable(cell_eval.type_key); cell_can_edit = df_type_key_is_editable(cell_eval.type_key);
}break; }break;
@@ -2947,7 +2944,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
if(spec != &df_g_nil_gfx_view_rule_spec && spec->info.flags & DF_GfxViewRuleSpecInfoFlag_RowUI) if(spec != &df_g_nil_gfx_view_rule_spec && spec->info.flags & DF_GfxViewRuleSpecInfoFlag_RowUI)
{ {
cell_ui_hook = spec->info.row_ui; cell_ui_hook = spec->info.row_ui;
cell_ui_node = val->last; cell_ui_params = val->last->root;
} }
} }
} }
@@ -2993,7 +2990,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_Clickable, "###val_%I64x", row_hash); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_Clickable, "###val_%I64x", row_hash);
UI_Parent(box) UI_Parent(box)
{ {
cell_ui_hook(ws, row->key, cell_eval, cell_ui_node); cell_ui_hook(ws, row->key, cell_eval, cell_ui_params);
} }
sig = ui_signal_from_box(box); sig = ui_signal_from_box(box);
} }
@@ -3845,7 +3842,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
if(query_normalized_with_opt_slash_props.flags & FilePropertyFlag_IsFolder) if(query_normalized_with_opt_slash_props.flags & FilePropertyFlag_IsFolder)
{ {
String8 new_path = push_str8f(scratch.arena, "%S%S/", path_query.path, path_query.search); String8 new_path = push_str8f(scratch.arena, "%S%S/", path_query.path, path_query.search);
df_view_equip_spec(ws, view, view->spec, new_path, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, view->spec, new_path, &md_nil_node);
} }
// rjf: is a file -> complete view // rjf: is a file -> complete view
@@ -3875,7 +3872,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
{ {
String8 existing_path = str8_chop_last_slash(path_query.path); String8 existing_path = str8_chop_last_slash(path_query.path);
String8 new_path = push_str8f(scratch.arena, "%S/%S/", existing_path, files[0].filename); String8 new_path = push_str8f(scratch.arena, "%S/%S/", existing_path, files[0].filename);
df_view_equip_spec(ws, view, view->spec, new_path, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, view->spec, new_path, &md_nil_node);
} }
else else
{ {
@@ -4005,7 +4002,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
String8 new_path = str8_chop_last_slash(str8_chop_last_slash(path_query.path)); String8 new_path = str8_chop_last_slash(str8_chop_last_slash(path_query.path));
new_path = path_normalized_from_string(scratch.arena, new_path); new_path = path_normalized_from_string(scratch.arena, new_path);
String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : ""); String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : "");
df_view_equip_spec(ws, view, view->spec, new_cmd, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, view->spec, new_cmd, &md_nil_node);
} }
} }
@@ -4087,7 +4084,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem)
if(file->props.flags & FilePropertyFlag_IsFolder) if(file->props.flags & FilePropertyFlag_IsFolder)
{ {
String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : ""); String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : "");
df_view_equip_spec(ws, view, view->spec, new_cmd, &df_g_nil_cfg_node); df_view_equip_spec(ws, view, view->spec, new_cmd, &md_nil_node);
} }
else else
{ {
@@ -4437,7 +4434,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); F32 row_height_px = floor_f32(ui_top_font_size()*2.5f);
DI_KeyList dbgi_keys_list = df_push_active_dbgi_key_list(scratch.arena); DI_KeyList dbgi_keys_list = df_push_active_dbgi_key_list(scratch.arena);
DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list); DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list);
FZY_Params params = {RDI_SectionKind_Procedures, dbgi_keys}; FZY_Params fuzzy_search_params = {RDI_SectionKind_Procedures, dbgi_keys};
U64 endt_us = os_now_microseconds()+200; U64 endt_us = os_now_microseconds()+200;
//- rjf: grab rdis, make type graphs for each //- rjf: grab rdis, make type graphs for each
@@ -4463,7 +4460,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
//- rjf: query -> raddbg, filtered items //- rjf: query -> raddbg, filtered items
U128 fuzzy_search_key = {(U64)view, df_hash_from_string(str8_struct(&view))}; U128 fuzzy_search_key = {(U64)view, df_hash_from_string(str8_struct(&view))};
B32 items_stale = 0; B32 items_stale = 0;
FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fuzzy_search_key, &params, string, endt_us, &items_stale); FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fuzzy_search_key, &fuzzy_search_params, string, endt_us, &items_stale);
if(items_stale) if(items_stale)
{ {
df_gfx_request_frame(); df_gfx_request_frame();
@@ -6514,8 +6511,6 @@ DF_VIEW_SETUP_FUNCTION_DEF(PendingFile)
{ {
DF_PendingFileViewState *pves = df_view_user_state(view, DF_PendingFileViewState); DF_PendingFileViewState *pves = df_view_user_state(view, DF_PendingFileViewState);
pves->deferred_cmd_arena = df_view_push_arena_ext(view); pves->deferred_cmd_arena = df_view_push_arena_ext(view);
pves->complete_cfg_arena = df_view_push_arena_ext(view);
pves->complete_cfg_root = df_cfg_tree_copy(pves->complete_cfg_arena, cfg);
} }
DF_VIEW_CMD_FUNCTION_DEF(PendingFile) DF_VIEW_CMD_FUNCTION_DEF(PendingFile)
@@ -6569,23 +6564,23 @@ DF_VIEW_CMD_FUNCTION_DEF(PendingFile)
MemoryZeroStruct(&pves->deferred_cmds); MemoryZeroStruct(&pves->deferred_cmds);
} }
//- rjf: if entity is ready, move cfg tree to scratch for new command //- rjf: if entity is ready, move params tree to scratch for new command
DF_CfgNode *cfg_root = &df_g_nil_cfg_node; MD_Node *params_copy = &md_nil_node;
if(file_is_ready) if(file_is_ready)
{ {
cfg_root = df_cfg_tree_copy(scratch.arena, pves->complete_cfg_root); params_copy = md_tree_copy(scratch.arena, params);
} }
//- rjf: if entity is ready, replace this view with the correct one, if any viewer is specified //- rjf: if entity is ready, replace this view with the correct one, if any viewer is specified
if(file_is_ready && viewer_kind != DF_GfxViewKind_Null) if(file_is_ready && viewer_kind != DF_GfxViewKind_Null)
{ {
DF_ViewSpec *view_spec = df_view_spec_from_string(cfg_root->string); DF_ViewSpec *view_spec = df_view_spec_from_string(params_copy->string);
if(view_spec == &df_g_nil_view_spec) if(view_spec == &df_g_nil_view_spec)
{ {
view_spec = df_view_spec_from_gfx_view_kind(viewer_kind); view_spec = df_view_spec_from_gfx_view_kind(viewer_kind);
} }
String8 query = df_eval_string_from_file_path(scratch.arena, file_path); String8 query = df_eval_string_from_file_path(scratch.arena, file_path);
df_view_equip_spec(ws, view, view_spec, query, cfg_root); df_view_equip_spec(ws, view, view_spec, query, params_copy);
df_panel_notify_mutation(ws, panel); df_panel_notify_mutation(ws, panel);
} }
@@ -6610,24 +6605,8 @@ DF_VIEW_UI_FUNCTION_DEF(PendingFile)
DF_VIEW_SETUP_FUNCTION_DEF(Code) DF_VIEW_SETUP_FUNCTION_DEF(Code)
{ {
// rjf: set up state
DF_CodeViewState *cv = df_view_user_state(view, DF_CodeViewState); DF_CodeViewState *cv = df_view_user_state(view, DF_CodeViewState);
df_code_view_init(cv, view); df_code_view_init(cv, view);
// rjf: deserialize cursor
DF_CfgNode *cursor_cfg = df_cfg_node_child_from_string(cfg, str8_lit("cursor"), StringMatchFlag_CaseInsensitive);
if(cursor_cfg != &df_g_nil_cfg_node)
{
TxtPt cursor = txt_pt(1, 1);
cursor.line = s64_from_str8(cursor_cfg->first->string, 10);
cursor.column = s64_from_str8(cursor_cfg->first->first->string, 10);
if(cursor.line == 0) { cursor.line = 1; }
if(cursor.column == 0) { cursor.column = 1; }
cv->center_cursor = 1;
view->cursor = view->mark = cursor;
}
// rjf: default to loading
df_view_equip_loading_info(view, 1, 0, 0); df_view_equip_loading_info(view, 1, 0, 0);
view->loading_t = view->loading_t_target = 1.f; view->loading_t = view->loading_t_target = 1.f;
} }
@@ -6639,9 +6618,9 @@ DF_VIEW_CMD_FUNCTION_DEF(Code)
HS_Scope *hs_scope = hs_scope_open(); HS_Scope *hs_scope = hs_scope_open();
TXT_Scope *txt_scope = txt_scope_open(); TXT_Scope *txt_scope = txt_scope_open();
E_Eval eval = e_eval_from_string(scratch.arena, string); E_Eval eval = e_eval_from_string(scratch.arena, string);
Rng1U64 range = df_range_from_eval_cfg(eval, cfg); Rng1U64 range = df_range_from_eval_params(eval, params);
df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range, 1); df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range, 1);
df_interact_regs()->lang_kind = df_lang_kind_from_eval_cfg(eval, cfg); df_interact_regs()->lang_kind = df_lang_kind_from_eval_params(eval, params);
U128 hash = {0}; U128 hash = {0};
TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash);
String8 data = hs_data_from_hash(hs_scope, hash); String8 data = hs_data_from_hash(hs_scope, hash);
@@ -6712,9 +6691,9 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
// //
String8 path = df_file_path_from_eval_string(scratch.arena, string); String8 path = df_file_path_from_eval_string(scratch.arena, string);
E_Eval eval = e_eval_from_string(scratch.arena, string); E_Eval eval = e_eval_from_string(scratch.arena, string);
Rng1U64 range = df_range_from_eval_cfg(eval, cfg); Rng1U64 range = df_range_from_eval_params(eval, params);
df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range, 1); df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range, 1);
df_interact_regs()->lang_kind = df_lang_kind_from_eval_cfg(eval, cfg); df_interact_regs()->lang_kind = df_lang_kind_from_eval_params(eval, params);
U128 hash = {0}; U128 hash = {0};
TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash);
String8 data = hs_data_from_hash(hs_scope, hash); String8 data = hs_data_from_hash(hs_scope, hash);
@@ -8064,7 +8043,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bitmap_view_canvas_box_draw)
{ {
DF_BitmapViewState *bvs = (DF_BitmapViewState *)user_data; DF_BitmapViewState *bvs = (DF_BitmapViewState *)user_data;
Rng2F32 rect_scrn = box->rect; Rng2F32 rect_scrn = box->rect;
Rng2F32 rect_cvs = df_bitmap_view_state__canvas_from_screen_rect(bvs, rect_scrn, rect_scrn); Rng2F32 rect_cvs = df_bitmap_canvas_from_screen_rect(bvs, rect_scrn, rect_scrn);
F32 grid_cell_size_cvs = box->font_size*10.f; F32 grid_cell_size_cvs = box->font_size*10.f;
F32 grid_line_thickness_px = Max(2.f, box->font_size*0.1f); F32 grid_line_thickness_px = Max(2.f, box->font_size*0.1f);
Vec4F32 grid_line_color = df_rgba_from_theme_color(DF_ThemeColor_TextWeak); Vec4F32 grid_line_color = df_rgba_from_theme_color(DF_ThemeColor_TextWeak);
@@ -8076,7 +8055,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bitmap_view_canvas_box_draw)
{ {
Vec2F32 p_cvs = {0}; Vec2F32 p_cvs = {0};
p_cvs.v[axis] = v; p_cvs.v[axis] = v;
Vec2F32 p_scr = df_bitmap_view_state__screen_from_canvas_pos(bvs, rect_scrn, p_cvs); Vec2F32 p_scr = df_bitmap_screen_from_canvas_pos(bvs, rect_scrn, p_cvs);
Rng2F32 rect = {0}; Rng2F32 rect = {0};
rect.p0.v[axis] = p_scr.v[axis] - grid_line_thickness_px/2; rect.p0.v[axis] = p_scr.v[axis] - grid_line_thickness_px/2;
rect.p1.v[axis] = p_scr.v[axis] + grid_line_thickness_px/2; rect.p1.v[axis] = p_scr.v[axis] + grid_line_thickness_px/2;
@@ -8090,15 +8069,7 @@ internal UI_BOX_CUSTOM_DRAW(df_bitmap_view_canvas_box_draw)
DF_VIEW_SETUP_FUNCTION_DEF(Bitmap) DF_VIEW_SETUP_FUNCTION_DEF(Bitmap)
{ {
DF_BitmapViewState *bvs = df_view_user_state(view, DF_BitmapViewState); DF_BitmapViewState *bvs = df_view_user_state(view, DF_BitmapViewState);
DF_CfgNode *view_center_cfg = df_cfg_node_child_from_string(cfg, str8_lit("view_center"), StringMatchFlag_CaseInsensitive); bvs->zoom = 1.f;
DF_CfgNode *zoom_cfg = df_cfg_node_child_from_string(cfg, str8_lit("zoom"), StringMatchFlag_CaseInsensitive);
bvs->view_center_pos.x = (F32)f64_from_str8(view_center_cfg->first->string);
bvs->view_center_pos.y = (F32)f64_from_str8(view_center_cfg->first->next->string);
bvs->zoom = (F32)f64_from_str8(zoom_cfg->first->string);
if(bvs->zoom == 0)
{
bvs->zoom = 1.f;
}
} }
DF_VIEW_CMD_FUNCTION_DEF(Bitmap) DF_VIEW_CMD_FUNCTION_DEF(Bitmap)
@@ -8116,8 +8087,8 @@ DF_VIEW_UI_FUNCTION_DEF(Bitmap)
//- rjf: evaluate expression //- rjf: evaluate expression
// //
E_Eval eval = e_eval_from_string(scratch.arena, string); E_Eval eval = e_eval_from_string(scratch.arena, string);
Vec2S32 dim = df_dim2s32_from_eval_cfg(eval, cfg); Vec2S32 dim = df_dim2s32_from_eval_params(eval, params);
R_Tex2DFormat fmt = df_tex2dformat_from_eval_cfg(eval, cfg); R_Tex2DFormat fmt = df_tex2dformat_from_eval_params(eval, params);
U64 base_offset = df_base_offset_from_eval(eval); U64 base_offset = df_base_offset_from_eval(eval);
U64 expected_size = dim.x*dim.y*r_tex2d_format_bytes_per_pixel_table[fmt]; U64 expected_size = dim.x*dim.y*r_tex2d_format_bytes_per_pixel_table[fmt];
Rng1U64 offset_range = r1u64(base_offset, base_offset + expected_size); Rng1U64 offset_range = r1u64(base_offset, base_offset + expected_size);
@@ -8167,9 +8138,9 @@ DF_VIEW_UI_FUNCTION_DEF(Bitmap)
F32 new_zoom = bvs->zoom - bvs->zoom*canvas_sig.scroll.y/10.f; F32 new_zoom = bvs->zoom - bvs->zoom*canvas_sig.scroll.y/10.f;
new_zoom = Clamp(1.f/256.f, new_zoom, 256.f); new_zoom = Clamp(1.f/256.f, new_zoom, 256.f);
Vec2F32 mouse_scr_pre = sub_2f32(ui_mouse(), rect.p0); Vec2F32 mouse_scr_pre = sub_2f32(ui_mouse(), rect.p0);
Vec2F32 mouse_cvs = df_bitmap_view_state__canvas_from_screen_pos(bvs, canvas_rect, mouse_scr_pre); Vec2F32 mouse_cvs = df_bitmap_canvas_from_screen_pos(bvs, canvas_rect, mouse_scr_pre);
bvs->zoom = new_zoom; bvs->zoom = new_zoom;
Vec2F32 mouse_scr_pst = df_bitmap_view_state__screen_from_canvas_pos(bvs, canvas_rect, mouse_cvs); Vec2F32 mouse_scr_pst = df_bitmap_screen_from_canvas_pos(bvs, canvas_rect, mouse_cvs);
Vec2F32 drift_scr = sub_2f32(mouse_scr_pst, mouse_scr_pre); Vec2F32 drift_scr = sub_2f32(mouse_scr_pst, mouse_scr_pre);
bvs->view_center_pos = add_2f32(bvs->view_center_pos, scale_2f32(drift_scr, 1.f/new_zoom)); bvs->view_center_pos = add_2f32(bvs->view_center_pos, scale_2f32(drift_scr, 1.f/new_zoom));
} }
@@ -8185,7 +8156,7 @@ DF_VIEW_UI_FUNCTION_DEF(Bitmap)
//- rjf: calculate image coordinates //- rjf: calculate image coordinates
// //
Rng2F32 img_rect_cvs = r2f32p(-topology.dim.x/2, -topology.dim.y/2, +topology.dim.x/2, +topology.dim.y/2); Rng2F32 img_rect_cvs = r2f32p(-topology.dim.x/2, -topology.dim.y/2, +topology.dim.x/2, +topology.dim.y/2);
Rng2F32 img_rect_scr = df_bitmap_view_state__screen_from_canvas_rect(bvs, canvas_rect, img_rect_cvs); Rng2F32 img_rect_scr = df_bitmap_screen_from_canvas_rect(bvs, canvas_rect, img_rect_cvs);
////////////////////////////// //////////////////////////////
//- rjf: image-region canvas interaction //- rjf: image-region canvas interaction
@@ -8194,7 +8165,7 @@ DF_VIEW_UI_FUNCTION_DEF(Bitmap)
if(ui_hovering(canvas_sig) && !ui_dragging(canvas_sig)) if(ui_hovering(canvas_sig) && !ui_dragging(canvas_sig))
{ {
Vec2F32 mouse_scr = sub_2f32(ui_mouse(), rect.p0); Vec2F32 mouse_scr = sub_2f32(ui_mouse(), rect.p0);
Vec2F32 mouse_cvs = df_bitmap_view_state__canvas_from_screen_pos(bvs, canvas_rect, mouse_scr); Vec2F32 mouse_cvs = df_bitmap_canvas_from_screen_pos(bvs, canvas_rect, mouse_scr);
if(contains_2f32(img_rect_cvs, mouse_cvs)) if(contains_2f32(img_rect_cvs, mouse_cvs))
{ {
mouse_bmp = v2s32((S32)(mouse_cvs.x-img_rect_cvs.x0), (S32)(mouse_cvs.y-img_rect_cvs.y0)); mouse_bmp = v2s32((S32)(mouse_cvs.x-img_rect_cvs.x0), (S32)(mouse_cvs.y-img_rect_cvs.y0));
@@ -8397,69 +8368,8 @@ DF_VIEW_UI_FUNCTION_DEF(ExceptionFilters)
//////////////////////////////// ////////////////////////////////
//~ rjf: Settings @view_hook_impl //~ rjf: Settings @view_hook_impl
DF_VIEW_SETUP_FUNCTION_DEF(Settings) {} DF_VIEW_SETUP_FUNCTION_DEF(Settings){}
DF_VIEW_CMD_FUNCTION_DEF(Settings){}
DF_VIEW_CMD_FUNCTION_DEF(Settings)
{
for(DF_CmdNode *n = cmds->first; n != 0; n = n->next)
{
DF_Cmd *cmd = &n->cmd;
// rjf: mismatched window/panel => skip
if(df_window_from_handle(cmd->params.window) != ws ||
df_panel_from_handle(cmd->params.panel) != panel)
{
continue;
}
// rjf: process
DF_CoreCmdKind core_cmd_kind = df_core_cmd_kind_from_string(cmd->spec->info.string);
switch(core_cmd_kind)
{
default:break;
case DF_CoreCmdKind_PickFile:
{
Temp scratch = scratch_begin(0, 0);
String8 path = cmd->params.file_path;
String8 data = os_data_from_file_path(scratch.arena, path);
DF_CfgTable cfg_table = {0};
df_cfg_table_push_unparsed_string(scratch.arena, &cfg_table, data, DF_CfgSrc_User);
DF_CfgVal *colors = df_cfg_val_from_string(&cfg_table, str8_lit("colors"));
for(DF_CfgNode *colors_set = colors->first;
colors_set != &df_g_nil_cfg_node;
colors_set = colors_set->next)
{
for(DF_CfgNode *color = colors_set->first;
color != &df_g_nil_cfg_node;
color = color->next)
{
String8 color_name = color->string;
DF_ThemeColor color_code = DF_ThemeColor_Null;
for(DF_ThemeColor c = DF_ThemeColor_Null; c < DF_ThemeColor_COUNT; c = (DF_ThemeColor)(c+1))
{
if(str8_match(df_g_theme_color_cfg_string_table[c], color_name, StringMatchFlag_CaseInsensitive))
{
color_code = c;
break;
}
}
if(color_code != DF_ThemeColor_Null)
{
DF_CfgNode *hex_cfg = color->first;
String8 hex_string = hex_cfg->string;
U64 hex_val = 0;
try_u64_from_str8_c_rules(hex_string, &hex_val);
Vec4F32 color_rgba = rgba_from_u32((U32)hex_val);
df_gfx_state->cfg_theme_target.colors[color_code] = color_rgba;
}
}
}
scratch_end(scratch);
}break;
}
}
}
DF_VIEW_UI_FUNCTION_DEF(Settings) DF_VIEW_UI_FUNCTION_DEF(Settings)
{ {
ProfBeginFunction(); ProfBeginFunction();
-2
View File
@@ -101,8 +101,6 @@ struct DF_PendingFileViewState
{ {
Arena *deferred_cmd_arena; Arena *deferred_cmd_arena;
DF_CmdList deferred_cmds; DF_CmdList deferred_cmds;
Arena *complete_cfg_arena;
DF_CfgNode *complete_cfg_root;
}; };
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -224,7 +224,7 @@ DF_GfxViewRuleSpecInfo df_g_gfx_view_rule_spec_info_table[15] =
{ str8_lit_comp("rgba"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*1)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(rgba) , str8_lit_comp("") }, { str8_lit_comp("rgba"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*1)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(rgba) , str8_lit_comp("") },
{ str8_lit_comp("text"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*0)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, 0, str8_lit_comp("code") }, { str8_lit_comp("text"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*0)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, 0, str8_lit_comp("code") },
{ str8_lit_comp("disasm"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*0)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, 0, str8_lit_comp("disassembly") }, { str8_lit_comp("disasm"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*0)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, 0, str8_lit_comp("disassembly") },
{ str8_lit_comp("bitmap"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*1)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(bitmap) , str8_lit_comp("bitmap") }, { str8_lit_comp("bitmap"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*0)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, 0, str8_lit_comp("bitmap") },
{ str8_lit_comp("geo"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*1)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(geo) , str8_lit_comp("geometry") }, { str8_lit_comp("geo"), (DF_GfxViewRuleSpecInfoFlag_VizRowProd*0)|(DF_GfxViewRuleSpecInfoFlag_LineStringize*0)|(DF_GfxViewRuleSpecInfoFlag_RowUI*1)|(DF_GfxViewRuleSpecInfoFlag_ViewUI*1), 0, 0, DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_NAME(geo) , str8_lit_comp("geometry") },
}; };
-1
View File
@@ -270,7 +270,6 @@ DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_DEF(omit);
DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_DEF(no_addr); DF_GFX_VIEW_RULE_LINE_STRINGIZE_FUNCTION_DEF(no_addr);
DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(checkbox); DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(checkbox);
DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(rgba); DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(rgba);
DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(bitmap);
DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(geo); DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(geo);
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
extern DF_StringBindingPair df_g_default_binding_table[110]; extern DF_StringBindingPair df_g_default_binding_table[110];
+62 -6
View File
@@ -144,8 +144,8 @@ md_node_flags_from_token_flags(MD_TokenFlags flags)
result |= MD_NodeFlag_Numeric*!!(flags&MD_TokenFlag_Numeric); result |= MD_NodeFlag_Numeric*!!(flags&MD_TokenFlag_Numeric);
result |= MD_NodeFlag_StringLiteral*!!(flags&MD_TokenFlag_StringLiteral); result |= MD_NodeFlag_StringLiteral*!!(flags&MD_TokenFlag_StringLiteral);
result |= MD_NodeFlag_Symbol*!!(flags&MD_TokenFlag_Symbol); result |= MD_NodeFlag_Symbol*!!(flags&MD_TokenFlag_Symbol);
result |= MD_NodeFlag_StringSingleQuote *!!(flags&MD_TokenFlag_StringSingleQuote); result |= MD_NodeFlag_StringSingleQuote *!!(flags&MD_TokenFlag_StringSingleQuote);
result |= MD_NodeFlag_StringDoubleQuote *!!(flags&MD_TokenFlag_StringDoubleQuote); result |= MD_NodeFlag_StringDoubleQuote *!!(flags&MD_TokenFlag_StringDoubleQuote);
result |= MD_NodeFlag_StringTick*!!(flags&MD_TokenFlag_StringTick); result |= MD_NodeFlag_StringTick*!!(flags&MD_TokenFlag_StringTick);
result |= MD_NodeFlag_StringTriplet*!!(flags&MD_TokenFlag_StringTriplet); result |= MD_NodeFlag_StringTriplet*!!(flags&MD_TokenFlag_StringTriplet);
return result; return result;
@@ -166,16 +166,16 @@ md_node_rec_depth_first(MD_Node *node, MD_Node *subtree_root, U64 child_off, U64
{ {
MD_NodeRec rec = {0}; MD_NodeRec rec = {0};
rec.next = &md_nil_node; rec.next = &md_nil_node;
if(!md_node_is_nil(MemberFromOffset(MD_Node *, node, child_off))) if(!md_node_is_nil(*MemberFromOffset(MD_Node **, node, child_off)))
{ {
rec.next = MemberFromOffset(MD_Node *, node, child_off); rec.next = *MemberFromOffset(MD_Node **, node, child_off);
rec.push_count = 1; rec.push_count = 1;
} }
else for(MD_Node *p = node; !md_node_is_nil(p) && p != subtree_root; p = p->parent, rec.pop_count += 1) else for(MD_Node *p = node; !md_node_is_nil(p) && p != subtree_root; p = p->parent, rec.pop_count += 1)
{ {
if(!md_node_is_nil(MemberFromOffset(MD_Node *, p, sib_off))) if(!md_node_is_nil(*MemberFromOffset(MD_Node **, p, sib_off)))
{ {
rec.next = MemberFromOffset(MD_Node *, p, sib_off); rec.next = *MemberFromOffset(MD_Node **, p, sib_off);
break; break;
} }
} }
@@ -354,6 +354,20 @@ md_tag_count_from_node(MD_Node *node)
return result; return result;
} }
internal String8
md_string_from_children(Arena *arena, MD_Node *root)
{
Temp scratch = scratch_begin(&arena, 1);
String8List strs = {0};
for(MD_EachNode(child, root->first))
{
str8_list_push(scratch.arena, &strs, child->string);
}
String8 result = str8_list_join(arena, &strs, 0);
scratch_end(scratch);
return result;
}
//- rjf: tree comparison //- rjf: tree comparison
internal B32 internal B32
@@ -419,6 +433,48 @@ md_node_deep_match(MD_Node *a, MD_Node *b, StringMatchFlags flags)
return result; return result;
} }
//- rjf: tree duplication
internal MD_Node *
md_tree_copy(Arena *arena, MD_Node *src_root)
{
MD_Node *dst_root = &md_nil_node;
MD_Node *dst_parent = dst_root;
{
MD_NodeRec rec = {0};
for(MD_Node *src = src_root; !md_node_is_nil(src); src = rec.next)
{
MD_Node *dst = push_array(arena, MD_Node, 1);
dst->first = dst->last = dst->parent = dst->next = dst->prev = &md_nil_node;
dst->first_tag = dst->last_tag = &md_nil_node;
dst->kind = src->kind;
dst->flags = src->flags;
dst->string = push_str8_copy(arena, src->string);
dst->raw_string = push_str8_copy(arena, src->raw_string);
dst->src_offset = src->src_offset;
dst->parent = dst_parent;
if(dst_parent != &md_nil_node)
{
DLLPushBack_NPZ(&md_nil_node, dst_parent->first, dst_parent->last, dst, next, prev);
}
else
{
dst_root = dst_parent = dst;
}
rec = md_node_rec_depth_first_pre(src, src_root);
if(rec.push_count != 0)
{
dst_parent = dst;
}
else for(U64 idx = 0; idx < rec.pop_count; idx += 1)
{
dst_parent = dst_parent->parent;
}
}
}
return dst_root;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Text -> Tokens Functions //~ rjf: Text -> Tokens Functions
+4
View File
@@ -279,11 +279,15 @@ internal B32 md_node_has_child(MD_Node *node, String8 string, StringMatch
internal B32 md_node_has_tag(MD_Node *node, String8 string, StringMatchFlags flags); internal B32 md_node_has_tag(MD_Node *node, String8 string, StringMatchFlags flags);
internal U64 md_child_count_from_node(MD_Node *node); internal U64 md_child_count_from_node(MD_Node *node);
internal U64 md_tag_count_from_node(MD_Node *node); internal U64 md_tag_count_from_node(MD_Node *node);
internal String8 md_string_from_children(Arena *arena, MD_Node *root);
//- rjf: tree comparison //- rjf: tree comparison
internal B32 md_node_deep_match(MD_Node *a, MD_Node *b, StringMatchFlags flags); internal B32 md_node_deep_match(MD_Node *a, MD_Node *b, StringMatchFlags flags);
internal B32 md_node_match(MD_Node *a, MD_Node *b, StringMatchFlags flags); internal B32 md_node_match(MD_Node *a, MD_Node *b, StringMatchFlags flags);
//- rjf: tree duplication
internal MD_Node *md_tree_copy(Arena *arena, MD_Node *src_root);
//////////////////////////////// ////////////////////////////////
//~ rjf: Text -> Tokens Functions //~ rjf: Text -> Tokens Functions