entity view filtering

This commit is contained in:
Ryan Fleury
2024-02-05 12:08:50 -08:00
parent e03e1dd136
commit 9504946376
7 changed files with 171 additions and 82 deletions
+36
View File
@@ -1335,6 +1335,42 @@ df_entity_array_from_list(Arena *arena, DF_EntityList *list)
return result;
}
//- rjf: entity fuzzy list building
internal DF_EntityFuzzyItemArray
df_entity_fuzzy_item_array_from_entity_list_needle(Arena *arena, DF_EntityList *list, String8 needle)
{
Temp scratch = scratch_begin(&arena, 1);
DF_EntityArray array = df_entity_array_from_list(scratch.arena, list);
DF_EntityFuzzyItemArray result = df_entity_fuzzy_item_array_from_entity_array_needle(arena, &array, needle);
return result;
}
internal DF_EntityFuzzyItemArray
df_entity_fuzzy_item_array_from_entity_array_needle(Arena *arena, DF_EntityArray *array, String8 needle)
{
Temp scratch = scratch_begin(&arena, 1);
DF_EntityFuzzyItemArray result = {0};
result.count = array->count;
result.v = push_array(arena, DF_EntityFuzzyItem, result.count);
U64 result_idx = 0;
for(U64 src_idx = 0; src_idx < array->count; src_idx += 1)
{
DF_Entity *entity = array->v[src_idx];
String8 display_string = df_display_string_from_entity(scratch.arena, entity);
FuzzyMatchRangeList matches = fuzzy_match_find(arena, needle, display_string);
if(matches.count >= matches.needle_part_count)
{
result.v[result_idx].entity = entity;
result.v[result_idx].matches = matches;
result_idx += 1;
}
}
result.count = result_idx;
scratch_end(scratch);
return result;
}
//- rjf: entity -> text info
internal TXTI_Handle
+21
View File
@@ -512,6 +512,23 @@ struct DF_EntityRec
S32 pop_count;
};
////////////////////////////////
//~ rjf: Entity Fuzzy Listing Types
typedef struct DF_EntityFuzzyItem DF_EntityFuzzyItem;
struct DF_EntityFuzzyItem
{
DF_Entity *entity;
FuzzyMatchRangeList matches;
};
typedef struct DF_EntityFuzzyItemArray DF_EntityFuzzyItemArray;
struct DF_EntityFuzzyItemArray
{
DF_EntityFuzzyItem *v;
U64 count;
};
////////////////////////////////
//~ rjf: Text Slices (output type from data which can be used to produce readable text)
@@ -1361,6 +1378,10 @@ internal void df_entity_list_push(Arena *arena, DF_EntityList *list, DF_Entity *
internal DF_EntityArray df_entity_array_from_list(Arena *arena, DF_EntityList *list);
#define df_first_entity_from_list(list) ((list)->first != 0 ? (list)->first->entity : &df_g_nil_entity)
//- rjf: entity fuzzy list building
internal DF_EntityFuzzyItemArray df_entity_fuzzy_item_array_from_entity_list_needle(Arena *arena, DF_EntityList *list, String8 needle);
internal DF_EntityFuzzyItemArray df_entity_fuzzy_item_array_from_entity_array_needle(Arena *arena, DF_EntityArray *array, String8 needle);
//- rjf: entity -> text info
internal TXTI_Handle df_txti_handle_from_entity(DF_Entity *entity);