From cd1a0a4cb5284655d739ec634f89c269513a053d Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 2 Apr 2024 10:42:31 -0700 Subject: [PATCH] tab query serialization/deserialization; only enable for view rule defined view specs --- src/df/gfx/df_gfx.c | 18 +++++++++++++++++- src/df/gfx/df_gfx.h | 7 ++++--- src/df/gfx/df_gfx.mdesk | 2 +- src/df/gfx/generated/df_gfx.meta.c | 8 ++++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 50ac1af7..47f33a30 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -7983,6 +7983,14 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source) { str8_list_push(arena, &strs, str8_lit("selected ")); } + if(view->query_string_size != 0 && view->spec->info.flags & DF_ViewSpecFlag_CanSerializeQuery) + { + Temp scratch = scratch_begin(&arena, 1); + String8 query_raw = str8(view->query_buffer, view->query_string_size); + String8 query_sanitized = df_cfg_escaped_from_raw_string(scratch.arena, query_raw); + str8_list_pushf(arena, &strs, "query:\"%S\" ", query_sanitized); + scratch_end(scratch); + } if(view->spec->info.flags & DF_ViewSpecFlag_CanSerializeEntityPath) { if(view_entity->kind == DF_EntityKind_File) @@ -11817,6 +11825,14 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) // 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; + // rjf: read view query string + String8 view_query = str8_lit(""); + if(view_spec_flags & DF_ViewSpecFlag_CanSerializeQuery) + { + String8 escaped_query = df_cfg_node_child_from_string(op, str8_lit("query"), StringMatchFlag_CaseInsensitive)->first->string; + view_query = df_cfg_raw_from_escaped_string(scratch.arena, escaped_query); + } + // rjf: read entity path DF_Entity *entity = &df_g_nil_entity; if(view_spec_flags & DF_ViewSpecFlag_CanSerializeEntityPath) @@ -11827,7 +11843,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) } // rjf: set up view - df_view_equip_spec(view, view_spec, entity, str8_lit(""), op); + df_view_equip_spec(view, view_spec, entity, view_query, op); } // rjf: insert diff --git a/src/df/gfx/df_gfx.h b/src/df/gfx/df_gfx.h index 6d1e1abe..5c700ca8 100644 --- a/src/df/gfx/df_gfx.h +++ b/src/df/gfx/df_gfx.h @@ -102,9 +102,10 @@ enum DF_ViewSpecFlag_ParameterizedByEntity = (1<<0), DF_ViewSpecFlag_CanSerialize = (1<<1), DF_ViewSpecFlag_CanSerializeEntityPath = (1<<2), - DF_ViewSpecFlag_CanFilter = (1<<3), - DF_ViewSpecFlag_FilterIsCode = (1<<4), - DF_ViewSpecFlag_TypingAutomaticallyFilters = (1<<5), + DF_ViewSpecFlag_CanSerializeQuery = (1<<3), + DF_ViewSpecFlag_CanFilter = (1<<4), + DF_ViewSpecFlag_FilterIsCode = (1<<5), + DF_ViewSpecFlag_TypingAutomaticallyFilters = (1<<6), }; typedef struct DF_ViewSpecInfo DF_ViewSpecInfo; diff --git a/src/df/gfx/df_gfx.mdesk b/src/df/gfx/df_gfx.mdesk index f258e07b..0cdf88b2 100644 --- a/src/df/gfx/df_gfx.mdesk +++ b/src/df/gfx/df_gfx.mdesk @@ -576,7 +576,7 @@ DF_ThemePresetColorTable: @data(DF_ViewSpecInfo) @c_file df_g_gfx_view_rule_tab_view_spec_info_table: { @expand(DF_GfxViewRuleTable a) - ```$(a.tu == "x" -> '{ DF_ViewSpecFlag_CanSerialize, str8_lit_comp("' .. a.string .. '_view_rule"), str8_lit_comp("' .. a.tab_display_string .. '"), DF_NameKind_Null, DF_IconKind_Binoculars, ' .. 'DF_VIEW_SETUP_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_CMD_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_UI_FUNCTION_NAME(' .. a.string .. ') }')```; + ```$(a.tu == "x" -> '{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("' .. a.string .. '_view_rule"), str8_lit_comp("' .. a.tab_display_string .. '"), DF_NameKind_Null, DF_IconKind_Binoculars, ' .. 'DF_VIEW_SETUP_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_CMD_FUNCTION_NAME(' .. a.string .. '), DF_VIEW_UI_FUNCTION_NAME(' .. a.string .. ') }')```; } //- rjf: default view spec info table diff --git a/src/df/gfx/generated/df_gfx.meta.c b/src/df/gfx/generated/df_gfx.meta.c index 78e3cb49..b5bfe355 100644 --- a/src/df/gfx/generated/df_gfx.meta.c +++ b/src/df/gfx/generated/df_gfx.meta.c @@ -733,10 +733,10 @@ DF_GfxViewRuleSpecInfo df_g_gfx_view_rule_spec_info_table[14] = DF_ViewSpecInfo df_g_gfx_view_rule_tab_view_spec_info_table[4] = { -{ DF_ViewSpecFlag_CanSerialize, str8_lit_comp("text_view_rule"), str8_lit_comp("Text"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(text), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(text), DF_VIEW_CMD_FUNCTION_NAME(text), DF_VIEW_UI_FUNCTION_NAME(text) }, -{ DF_ViewSpecFlag_CanSerialize, str8_lit_comp("disasm_view_rule"), str8_lit_comp("Disassembly"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(disasm), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(disasm), DF_VIEW_CMD_FUNCTION_NAME(disasm), DF_VIEW_UI_FUNCTION_NAME(disasm) }, -{ DF_ViewSpecFlag_CanSerialize, str8_lit_comp("bitmap_view_rule"), str8_lit_comp("Bitmap"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(bitmap), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(bitmap), DF_VIEW_CMD_FUNCTION_NAME(bitmap), DF_VIEW_UI_FUNCTION_NAME(bitmap) }, -{ DF_ViewSpecFlag_CanSerialize, str8_lit_comp("geo_view_rule"), str8_lit_comp("Geometry"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(geo), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(geo), DF_VIEW_CMD_FUNCTION_NAME(geo), DF_VIEW_UI_FUNCTION_NAME(geo) }, +{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("text_view_rule"), str8_lit_comp("Text"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(text), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(text), DF_VIEW_CMD_FUNCTION_NAME(text), DF_VIEW_UI_FUNCTION_NAME(text) }, +{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("disasm_view_rule"), str8_lit_comp("Disassembly"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(disasm), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(disasm), DF_VIEW_CMD_FUNCTION_NAME(disasm), DF_VIEW_UI_FUNCTION_NAME(disasm) }, +{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("bitmap_view_rule"), str8_lit_comp("Bitmap"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(bitmap), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(bitmap), DF_VIEW_CMD_FUNCTION_NAME(bitmap), DF_VIEW_UI_FUNCTION_NAME(bitmap) }, +{ DF_ViewSpecFlag_CanSerialize|DF_ViewSpecFlag_CanSerializeQuery, str8_lit_comp("geo_view_rule"), str8_lit_comp("Geometry"), DF_NameKind_Null, DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(geo), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(geo), DF_VIEW_CMD_FUNCTION_NAME(geo), DF_VIEW_UI_FUNCTION_NAME(geo) }, }; DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[30] =