mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-21 19:25:00 -07:00
part 5: begin shifting autocompletion lister box to being unified lister/ctx-menu replacement
This commit is contained in:
+885
-849
File diff suppressed because it is too large
Load Diff
+56
-53
@@ -511,28 +511,28 @@ typedef enum RD_PaletteCode
|
||||
RD_PaletteCode;
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Auto-Complete Lister Types
|
||||
//~ rjf: Lister Types
|
||||
|
||||
typedef U32 RD_AutoCompListerFlags;
|
||||
typedef U32 RD_ListerFlags;
|
||||
enum
|
||||
{
|
||||
RD_AutoCompListerFlag_Locals = (1<<0),
|
||||
RD_AutoCompListerFlag_Registers = (1<<1),
|
||||
RD_AutoCompListerFlag_ViewRules = (1<<2),
|
||||
RD_AutoCompListerFlag_ViewRuleParams= (1<<3),
|
||||
RD_AutoCompListerFlag_Members = (1<<4),
|
||||
RD_AutoCompListerFlag_Globals = (1<<5),
|
||||
RD_AutoCompListerFlag_ThreadLocals = (1<<6),
|
||||
RD_AutoCompListerFlag_Procedures = (1<<7),
|
||||
RD_AutoCompListerFlag_Types = (1<<8),
|
||||
RD_AutoCompListerFlag_Languages = (1<<9),
|
||||
RD_AutoCompListerFlag_Architectures = (1<<10),
|
||||
RD_AutoCompListerFlag_Tex2DFormats = (1<<11),
|
||||
RD_AutoCompListerFlag_Files = (1<<12),
|
||||
RD_ListerFlag_Locals = (1<<0),
|
||||
RD_ListerFlag_Registers = (1<<1),
|
||||
RD_ListerFlag_ViewRules = (1<<2),
|
||||
RD_ListerFlag_ViewRuleParams= (1<<3),
|
||||
RD_ListerFlag_Members = (1<<4),
|
||||
RD_ListerFlag_Globals = (1<<5),
|
||||
RD_ListerFlag_ThreadLocals = (1<<6),
|
||||
RD_ListerFlag_Procedures = (1<<7),
|
||||
RD_ListerFlag_Types = (1<<8),
|
||||
RD_ListerFlag_Languages = (1<<9),
|
||||
RD_ListerFlag_Architectures = (1<<10),
|
||||
RD_ListerFlag_Tex2DFormats = (1<<11),
|
||||
RD_ListerFlag_Files = (1<<12),
|
||||
};
|
||||
|
||||
typedef struct RD_AutoCompListerItem RD_AutoCompListerItem;
|
||||
struct RD_AutoCompListerItem
|
||||
typedef struct RD_ListerItem RD_ListerItem;
|
||||
struct RD_ListerItem
|
||||
{
|
||||
String8 string;
|
||||
String8 kind_string;
|
||||
@@ -541,36 +541,42 @@ struct RD_AutoCompListerItem
|
||||
B32 is_non_code;
|
||||
};
|
||||
|
||||
typedef struct RD_AutoCompListerItemChunkNode RD_AutoCompListerItemChunkNode;
|
||||
struct RD_AutoCompListerItemChunkNode
|
||||
typedef struct RD_ListerItemChunkNode RD_ListerItemChunkNode;
|
||||
struct RD_ListerItemChunkNode
|
||||
{
|
||||
RD_AutoCompListerItemChunkNode *next;
|
||||
RD_AutoCompListerItem *v;
|
||||
RD_ListerItemChunkNode *next;
|
||||
RD_ListerItem *v;
|
||||
U64 count;
|
||||
U64 cap;
|
||||
};
|
||||
|
||||
typedef struct RD_AutoCompListerItemChunkList RD_AutoCompListerItemChunkList;
|
||||
struct RD_AutoCompListerItemChunkList
|
||||
typedef struct RD_ListerItemChunkList RD_ListerItemChunkList;
|
||||
struct RD_ListerItemChunkList
|
||||
{
|
||||
RD_AutoCompListerItemChunkNode *first;
|
||||
RD_AutoCompListerItemChunkNode *last;
|
||||
RD_ListerItemChunkNode *first;
|
||||
RD_ListerItemChunkNode *last;
|
||||
U64 chunk_count;
|
||||
U64 total_count;
|
||||
};
|
||||
|
||||
typedef struct RD_AutoCompListerItemArray RD_AutoCompListerItemArray;
|
||||
struct RD_AutoCompListerItemArray
|
||||
typedef struct RD_ListerItemArray RD_ListerItemArray;
|
||||
struct RD_ListerItemArray
|
||||
{
|
||||
RD_AutoCompListerItem *v;
|
||||
RD_ListerItem *v;
|
||||
U64 count;
|
||||
};
|
||||
|
||||
typedef struct RD_AutoCompListerParams RD_AutoCompListerParams;
|
||||
struct RD_AutoCompListerParams
|
||||
typedef struct RD_ListerParams RD_ListerParams;
|
||||
struct RD_ListerParams
|
||||
{
|
||||
RD_AutoCompListerFlags flags;
|
||||
UI_Key anchor_key;
|
||||
Vec2F32 anchor_off;
|
||||
RD_ListerFlags flags;
|
||||
String8List strings;
|
||||
String8 input;
|
||||
U64 cursor_off;
|
||||
F32 squish;
|
||||
F32 transparency;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -623,18 +629,15 @@ struct RD_WindowState
|
||||
Arena *drop_completion_arena;
|
||||
String8List drop_completion_paths;
|
||||
|
||||
// rjf: autocomplete lister state
|
||||
U64 autocomp_last_frame_idx;
|
||||
B32 autocomp_input_dirty;
|
||||
UI_Key autocomp_root_key;
|
||||
Arena *autocomp_lister_params_arena;
|
||||
RD_AutoCompListerParams autocomp_lister_params;
|
||||
U64 autocomp_cursor_off;
|
||||
U8 autocomp_lister_input_buffer[1024];
|
||||
U64 autocomp_lister_input_size;
|
||||
F32 autocomp_open_t;
|
||||
F32 autocomp_num_visible_rows_t;
|
||||
S64 autocomp_cursor_num;
|
||||
// rjf: lister state
|
||||
U64 lister_last_frame_idx;
|
||||
B32 lister_input_dirty;
|
||||
Arena *lister_params_arena;
|
||||
RD_ListerParams lister_params;
|
||||
U8 lister_input_buffer[1024];
|
||||
U64 lister_input_size;
|
||||
F32 lister_open_t;
|
||||
F32 lister_num_visible_rows_t;
|
||||
|
||||
// rjf: query view stack
|
||||
U64 query_cmd_gen;
|
||||
@@ -849,7 +852,6 @@ struct RD_State
|
||||
RD_WindowStateSlot *window_state_slots;
|
||||
RD_WindowState *free_window_state;
|
||||
RD_Handle last_focused_window;
|
||||
// TODO(rjf): @cfg must be nil-initialized
|
||||
RD_WindowState *first_window_state;
|
||||
RD_WindowState *last_window_state;
|
||||
|
||||
@@ -1267,17 +1269,18 @@ internal String8 rd_value_string_from_eval(Arena *arena, EV_StringFlags flags, U
|
||||
internal void rd_set_hover_eval(Vec2F32 pos, String8 file_path, TxtPt pt, U64 vaddr, String8 string);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Auto-Complete Lister
|
||||
//~ rjf: Lister
|
||||
|
||||
internal void rd_autocomp_lister_item_chunk_list_push(Arena *arena, RD_AutoCompListerItemChunkList *list, U64 cap, RD_AutoCompListerItem *item);
|
||||
internal RD_AutoCompListerItemArray rd_autocomp_lister_item_array_from_chunk_list(Arena *arena, RD_AutoCompListerItemChunkList *list);
|
||||
internal int rd_autocomp_lister_item_qsort_compare(RD_AutoCompListerItem *a, RD_AutoCompListerItem *b);
|
||||
internal void rd_autocomp_lister_item_array_sort__in_place(RD_AutoCompListerItemArray *array);
|
||||
internal void rd_lister_item_chunk_list_push(Arena *arena, RD_ListerItemChunkList *list, U64 cap, RD_ListerItem *item);
|
||||
internal RD_ListerItemArray rd_lister_item_array_from_chunk_list(Arena *arena, RD_ListerItemChunkList *list);
|
||||
internal int rd_lister_item_qsort_compare(RD_ListerItem *a, RD_ListerItem *b);
|
||||
internal void rd_lister_item_array_sort__in_place(RD_ListerItemArray *array);
|
||||
|
||||
internal String8 rd_autocomp_query_word_from_input_string_off(String8 input, U64 cursor_off);
|
||||
internal String8 rd_autocomp_query_path_from_input_string_off(String8 input, U64 cursor_off);
|
||||
internal RD_AutoCompListerParams rd_view_rule_autocomp_lister_params_from_input_cursor(Arena *arena, String8 string, U64 cursor_off);
|
||||
internal void rd_set_autocomp_lister_query(UI_Key root_key, RD_AutoCompListerParams *params, String8 input, U64 cursor_off);
|
||||
internal String8 rd_lister_query_word_from_input_string_off(String8 input, U64 cursor_off);
|
||||
internal String8 rd_lister_query_path_from_input_string_off(String8 input, U64 cursor_off);
|
||||
internal RD_ListerParams rd_view_rule_lister_params_from_input_cursor(Arena *arena, String8 string, U64 cursor_off);
|
||||
internal void rd_set_lister_query_(RD_ListerParams *params);
|
||||
#define rd_set_lister_query(...) rd_set_lister_query_(&(RD_ListerParams){.flags = 0, __VA_ARGS__})
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Search Strings
|
||||
|
||||
+21
-17
@@ -1704,7 +1704,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
if(autocomplete_hint_string.size != 0)
|
||||
{
|
||||
take_autocomplete = 1;
|
||||
String8 word_query = rd_autocomp_query_word_from_input_string_off(string, edit_state->cursor.column-1);
|
||||
String8 word_query = rd_lister_query_word_from_input_string_off(string, edit_state->cursor.column-1);
|
||||
U64 word_off = (U64)(word_query.str - string.str);
|
||||
String8 new_string = ui_push_string_replace_range(scratch.arena, string, r1s64(word_off+1, word_off+1+word_query.size), autocomplete_hint_string);
|
||||
new_string.size = Min(sizeof(edit_state->input_buffer), new_string.size);
|
||||
@@ -2892,7 +2892,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
String8 cell_inheritance_string = {0};
|
||||
String8 cell_error_string = {0};
|
||||
String8 cell_error_tooltip_string = {0};
|
||||
RD_AutoCompListerFlags cell_autocomp_flags = 0;
|
||||
RD_ListerFlags cell_autocomp_flags = 0;
|
||||
RD_ViewRuleUIFunctionType *cell_ui_hook = 0;
|
||||
MD_Node *cell_ui_params = &md_nil_node;
|
||||
Vec4F32 cell_base_color = ui_top_palette()->text;
|
||||
@@ -2908,11 +2908,11 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
{
|
||||
cell_matches = fuzzy_match_find(scratch.arena, filter, ev_expr_string_from_row(scratch.arena, row, string_flags));
|
||||
}
|
||||
cell_autocomp_flags = (RD_AutoCompListerFlag_Locals|
|
||||
RD_AutoCompListerFlag_Procedures|
|
||||
RD_AutoCompListerFlag_Globals|
|
||||
RD_AutoCompListerFlag_ThreadLocals|
|
||||
RD_AutoCompListerFlag_Types);
|
||||
cell_autocomp_flags = (RD_ListerFlag_Locals|
|
||||
RD_ListerFlag_Procedures|
|
||||
RD_ListerFlag_Globals|
|
||||
RD_ListerFlag_ThreadLocals|
|
||||
RD_ListerFlag_Types);
|
||||
if(row->member != 0 && row->member->inheritance_key_chain.first != 0)
|
||||
{
|
||||
String8List inheritance_chain_type_names = {0};
|
||||
@@ -2964,14 +2964,14 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
{
|
||||
cell_error_tooltip_string = str8_lit("Could not read memory successfully.");
|
||||
}
|
||||
cell_autocomp_flags = (RD_AutoCompListerFlag_Locals|
|
||||
RD_AutoCompListerFlag_Procedures|
|
||||
RD_AutoCompListerFlag_Globals|
|
||||
RD_AutoCompListerFlag_ThreadLocals|
|
||||
RD_AutoCompListerFlag_Types);
|
||||
cell_autocomp_flags = (RD_ListerFlag_Locals|
|
||||
RD_ListerFlag_Procedures|
|
||||
RD_ListerFlag_Globals|
|
||||
RD_ListerFlag_ThreadLocals|
|
||||
RD_ListerFlag_Types);
|
||||
if(cell_type->flags & E_TypeFlag_IsPathText)
|
||||
{
|
||||
cell_autocomp_flags = RD_AutoCompListerFlag_Files;
|
||||
cell_autocomp_flags = RD_ListerFlag_Files;
|
||||
}
|
||||
if(ui_view_rule_info->flags & RD_ViewRuleInfoFlag_CanFillValueCell)
|
||||
{
|
||||
@@ -2997,7 +2997,7 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
case RD_WatchViewColumnKind_ViewRule:
|
||||
{
|
||||
cell_can_edit = 1;
|
||||
cell_autocomp_flags = RD_AutoCompListerFlag_ViewRules;
|
||||
cell_autocomp_flags = RD_ListerFlag_ViewRules;
|
||||
if(cell_pre_edit_string.size == 0)
|
||||
{
|
||||
EV_ViewRuleList *auto_view_rules = ev_auto_view_rules_from_type_key(scratch.arena, row_eval.type_key, 0, 1);
|
||||
@@ -3158,16 +3158,20 @@ rd_watch_view_build(RD_WatchViewState *ewv, RD_WatchViewFlags flags, String8 roo
|
||||
txt_pt_match(cell_edit_state->cursor, cell_edit_state->mark))
|
||||
{
|
||||
String8 input = str8(cell_edit_state->input_buffer, cell_edit_state->input_size);
|
||||
RD_AutoCompListerParams params = {cell_autocomp_flags};
|
||||
RD_ListerParams params = {cell_autocomp_flags};
|
||||
if(col->kind == RD_WatchViewColumnKind_ViewRule)
|
||||
{
|
||||
params = rd_view_rule_autocomp_lister_params_from_input_cursor(scratch.arena, input, cell_edit_state->cursor.column-1);
|
||||
params = rd_view_rule_lister_params_from_input_cursor(scratch.arena, input, cell_edit_state->cursor.column-1);
|
||||
if(params.flags == 0)
|
||||
{
|
||||
params.flags = cell_autocomp_flags;
|
||||
}
|
||||
}
|
||||
rd_set_autocomp_lister_query(sig.box->key, ¶ms, input, cell_edit_state->cursor.column-1);
|
||||
params.anchor_key = sig.box->key;
|
||||
params.anchor_off = v2f32(0, dim_2f32(sig.box->rect).y);
|
||||
params.input = input;
|
||||
params.cursor_off = cell_edit_state->cursor.column-1;
|
||||
rd_set_lister_query_(¶ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2575,7 +2575,7 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
// rjf: any valid op & autocomplete hint? -> perform autocomplete first, then re-compute op
|
||||
if(autocomplete_hint_string.size != 0)
|
||||
{
|
||||
String8 word_query = rd_autocomp_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
String8 word_query = rd_lister_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
U64 word_off = (U64)(word_query.str - edit_string.str);
|
||||
String8 new_string = ui_push_string_replace_range(scratch.arena, edit_string, r1s64(word_off+1, word_off+1+word_query.size), autocomplete_hint_string);
|
||||
new_string.size = Min(edit_buffer_size, new_string.size);
|
||||
@@ -2678,7 +2678,7 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
DR_FancyStringList code_fancy_strings = rd_fancy_string_list_from_code_string(scratch.arena, 1.f, 0, ui_top_palette()->text, edit_string);
|
||||
if(autocomplete_hint_string.size != 0)
|
||||
{
|
||||
String8 query_word = rd_autocomp_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
String8 query_word = rd_lister_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
String8 autocomplete_append_string = str8_skip(autocomplete_hint_string, query_word.size);
|
||||
U64 off = 0;
|
||||
U64 cursor_off = cursor->column-1;
|
||||
|
||||
Reference in New Issue
Block a user