From a7cf64d5e2c80b83565c443f3b5d42c45560576c Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 22 Aug 2024 12:01:53 -0700 Subject: [PATCH] extend watch view column parameterization; further progress on replacing entity views with watch views --- src/df/core/df_core.c | 46 +++++++++++--- src/df/core/df_core.h | 6 +- src/df/gfx/df_gfx.c | 32 +++++++--- src/df/gfx/df_views.c | 127 ++++++++++++++++++++------------------ src/df/gfx/df_views.h | 13 +++- src/eval/eval_interpret.h | 2 +- 6 files changed, 142 insertions(+), 84 deletions(-) diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index e0049efa..f212c89e 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -1419,6 +1419,7 @@ df_eval_from_entity(Arena *arena, DF_Entity *entity) DF_EntityEval *eval = push_array(arena, DF_EntityEval, 1); { DF_Entity *loc = df_entity_child_from_kind(entity, DF_EntityKind_Location); + DF_Entity *cnd = df_entity_child_from_kind(entity, DF_EntityKind_Condition); String8 label_string = push_str8_copy(arena, entity->name); String8 loc_string = {0}; if(loc->flags & DF_EntityFlag_HasTextPoint) @@ -1429,10 +1430,12 @@ df_eval_from_entity(Arena *arena, DF_Entity *entity) { loc_string = push_str8f(arena, "0x%I64x", loc->vaddr); } + String8 cnd_string = push_str8_copy(arena, cnd->name); eval->enabled = !entity->disabled; eval->hit_count = entity->u64; eval->label_off = (U64)((U8 *)label_string.str - (U8 *)eval); eval->location_off = (U64)((U8 *)loc_string.str - (U8 *)eval); + eval->condition_off= (U64)((U8 *)cnd_string.str - (U8 *)eval); } return eval; } @@ -3740,12 +3743,17 @@ df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range) U64 pos_min = arena_pos(scratch.arena); DF_EntityEval *eval = df_eval_from_entity(scratch.arena, entity); U64 pos_opl = arena_pos(scratch.arena); - U64 off_min = 0; - U64 off_opl = pos_opl - pos_min; - if(off_min <= range.min && range.max <= off_opl) + Rng1U64 legal_range = r1u64(0, pos_opl-pos_min); + if(contains_1u64(legal_range, range.min)) { result = 1; - MemoryCopy(out, (U8 *)eval + range.min, dim_1u64(range)); + U64 range_dim = dim_1u64(range); + U64 bytes_to_read = Min(range_dim, (legal_range.max - range.min)); + MemoryCopy(out, ((U8 *)eval) + range.min, bytes_to_read); + if(bytes_to_read < range_dim) + { + MemoryZero((U8 *)out + bytes_to_read, range_dim - bytes_to_read); + } } scratch_end(scratch); }break; @@ -3765,6 +3773,24 @@ df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range) return result; } +internal B32 +df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range) +{ + B32 result = 0; + DF_Entity *entity = (DF_Entity *)space; + switch(entity->kind) + { + default: + { + }break; + case DF_EntityKind_Process: + { + result = ctrl_process_write(entity->ctrl_machine_id, entity->ctrl_handle, range, in); + }break; + } + return result; +} + internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg) { @@ -4743,7 +4769,7 @@ df_append_viz_blocks_for_parent__rec(Arena *arena, DF_EvalView *eval_view, DF_Ex } internal DF_EvalVizBlockList -df_eval_viz_block_list_from_eval_view_expr_keys(Arena *arena, DF_EvalView *eval_view, String8 expr, DF_ExpandKey parent_key, DF_ExpandKey key) +df_eval_viz_block_list_from_eval_view_expr_keys(Arena *arena, DF_EvalView *eval_view, DF_CfgTable *cfg_table, String8 expr, DF_ExpandKey parent_key, DF_ExpandKey key) { ProfBeginFunction(); DF_EvalVizBlockList blocks = {0}; @@ -4784,13 +4810,14 @@ df_eval_viz_block_list_from_eval_view_expr_keys(Arena *arena, DF_EvalView *eval_ } } String8 view_rule_string = df_eval_view_rule_from_key(eval_view, key); - DF_CfgTable *view_rule_table = push_array(arena, DF_CfgTable, 1); + DF_CfgTable *cfg_table_inherited = push_array(arena, DF_CfgTable, 1); + *cfg_table_inherited = df_cfg_table_from_inheritance(arena, cfg_table); for(String8Node *n = default_view_rules.first; n != 0; n = n->next) { - df_cfg_table_push_unparsed_string(arena, view_rule_table, n->string, DF_CfgSrc_User); + df_cfg_table_push_unparsed_string(arena, cfg_table_inherited, n->string, DF_CfgSrc_User); } - df_cfg_table_push_unparsed_string(arena, view_rule_table, view_rule_string, DF_CfgSrc_User); - df_append_viz_blocks_for_parent__rec(arena, eval_view, parent_key, key, expr, parse.expr, view_rule_table, 0, &blocks); + df_cfg_table_push_unparsed_string(arena, cfg_table_inherited, view_rule_string, DF_CfgSrc_User); + df_append_viz_blocks_for_parent__rec(arena, eval_view, parent_key, key, expr, parse.expr, cfg_table_inherited, 0, &blocks); } ProfEnd(); return blocks; @@ -8464,7 +8491,6 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt) E_InterpretCtx *interpret_ctx = push_array(arena, E_InterpretCtx, 1); { E_InterpretCtx *ctx = interpret_ctx; - ctx->space_read_user_data = process; ctx->space_read = df_eval_space_read; ctx->primary_space = eval_modules_primary->space; ctx->reg_arch = eval_modules_primary->arch; diff --git a/src/df/core/df_core.h b/src/df/core/df_core.h index 1289cc4b..8a4ef19d 100644 --- a/src/df/core/df_core.h +++ b/src/df/core/df_core.h @@ -410,6 +410,7 @@ struct DF_EntityEval U64 hit_count; U64 label_off; U64 location_off; + U64 condition_off; }; //////////////////////////////// @@ -1572,7 +1573,8 @@ internal CTRL_Event df_ctrl_last_stop_event(void); //////////////////////////////// //~ rjf: Evaluation Context -internal B32 df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 vaddr_range); +internal B32 df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range); +internal B32 df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range); internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg); //////////////////////////////// @@ -1619,7 +1621,7 @@ internal DF_EvalVizBlock *df_eval_viz_block_begin(Arena *arena, DF_EvalVizBlockK internal DF_EvalVizBlock *df_eval_viz_block_split_and_continue(Arena *arena, DF_EvalVizBlockList *list, DF_EvalVizBlock *split_block, U64 split_idx); internal void df_eval_viz_block_end(DF_EvalVizBlockList *list, DF_EvalVizBlock *block); internal void df_append_viz_blocks_for_parent__rec(Arena *arena, DF_EvalView *view, DF_ExpandKey parent_key, DF_ExpandKey key, String8 string, E_Expr *expr, DF_CfgTable *cfg_table, S32 depth, DF_EvalVizBlockList *list_out); -internal DF_EvalVizBlockList df_eval_viz_block_list_from_eval_view_expr_keys(Arena *arena, DF_EvalView *eval_view, String8 expr, DF_ExpandKey parent_key, DF_ExpandKey key); +internal DF_EvalVizBlockList df_eval_viz_block_list_from_eval_view_expr_keys(Arena *arena, DF_EvalView *eval_view, DF_CfgTable *cfg_table, String8 expr, DF_ExpandKey parent_key, DF_ExpandKey key); internal void df_eval_viz_block_list_concat__in_place(DF_EvalVizBlockList *dst, DF_EvalVizBlockList *to_push); //- rjf: viz block list <-> table coordinates diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 7659c41c..23bc565e 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -6120,6 +6120,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) U64 thread_unwind_rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, df_base_interact_regs()->unwind_count); String8 expr = ws->hover_eval_string; E_Eval eval = e_eval_from_string(scratch.arena, expr); + DF_CfgTable top_level_cfg_table = {0}; //- rjf: build if good if(!e_type_key_match(eval.type_key, e_type_key_zero()) && !ui_any_ctx_menu_is_open()) @@ -6133,7 +6134,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_EvalView *eval_view = df_eval_view_from_key(eval_view_key); DF_ExpandKey parent_key = df_expand_key_make(5381, 1); DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), 1); - DF_EvalVizBlockList viz_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, expr, parent_key, key); + DF_EvalVizBlockList viz_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, expr, parent_key, key); U32 default_radix = (eval.space == E_Space_Regs ? 16 : 10); DF_EvalVizWindowedRowList viz_rows = df_eval_viz_windowed_row_list_from_viz_block_list(scratch.arena, eval_view, r1s64(0, 50), &viz_blocks); @@ -6181,7 +6182,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) String8 row_expr_string = df_expr_string_from_viz_row(scratch.arena, row); String8 row_display_value = df_value_string_from_eval(scratch.arena, DF_EvalVizStringFlag_ReadOnlyDisplayRules, default_radix, ui_top_font(), ui_top_font_size(), 500.f, row_eval, row->member, row->cfg_table); expr_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_expr_string).x + ui_top_font_size()*5.f; - value_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_display_value).x + ui_top_font_size()*2.5f; + value_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, 0, row_display_value).x + ui_top_font_size()*5.f; F32 total_dim_px = (expr_column_width_px + value_column_width_px); width_px = Min(80.f*ui_top_font_size(), total_dim_px*1.5f); } @@ -8382,12 +8383,12 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 // rjf: special case: push strings for textual string content B32 did_content = 0; - if(!did_content && ptee_has_string && !has_array && (flags & DF_EvalVizStringFlag_ReadOnlyDisplayRules)) + if(!did_content && ptee_has_string && !has_array) { did_content = 1; U64 string_memory_addr = value_eval.value.u64; U64 element_size = e_type_byte_size_from_key(direct_type_key); - U64 string_buffer_size = 256; + U64 string_buffer_size = 1024; U8 *string_buffer = push_array(arena, U8, string_buffer_size); for(U64 try_size = string_buffer_size; try_size >= 16; try_size /= 2) { @@ -8414,13 +8415,14 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 } // rjf: special case: push strings for symbols + B32 did_string = 0; if(!did_content && symbol_name.size != 0 && ((type_kind == E_TypeKind_Ptr && direct_type_kind == E_TypeKind_Void) || (type_kind == E_TypeKind_Ptr && direct_type_kind == E_TypeKind_Function) || - (type_kind == E_TypeKind_Function)) && - (flags & DF_EvalVizStringFlag_ReadOnlyDisplayRules)) + (type_kind == E_TypeKind_Function))) { did_content = 1; + did_string = 1; str8_list_push(arena, out, symbol_name); space_taken += f_dim_from_tag_size_string(font, font_size, 0, 0, symbol_name).x; } @@ -8457,7 +8459,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 // rjf: push pointer value B32 did_ptr_value = 0; - if(!no_addr || !did_content) + if((!no_addr || !did_content) && (!(flags & DF_EvalVizStringFlag_ReadOnlyDisplayRules) || !did_string)) { did_ptr_value = 1; if(did_content) @@ -8494,11 +8496,11 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 // rjf: special case: push strings for textual string content B32 did_content = 0; - if(!did_content && array_is_string && !has_array && (flags & DF_EvalVizStringFlag_ReadOnlyDisplayRules)) + if(!did_content && array_is_string && !has_array) { U64 element_size = e_type_byte_size_from_key(direct_type_key); did_content = 1; - U64 string_buffer_size = 256; + U64 string_buffer_size = 1024; U8 *string_buffer = push_array(arena, U8, string_buffer_size); switch(eval.mode) { @@ -8536,7 +8538,7 @@ df_append_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags flags, U32 } // rjf: descend in all other cases - if(!did_content) + if(!did_content && (flags & DF_EvalVizStringFlag_ReadOnlyDisplayRules)) { did_content = 1; @@ -12320,6 +12322,16 @@ df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_s { color = df_rgba_from_theme_color(DF_ThemeColor_CodeType); } + else + { + DF_Entity *module = df_entity_from_handle(df_interact_regs()->module); + DI_Key dbgi_key = df_dbgi_key_from_module(module); + U64 symbol_voff = df_voff_from_dbgi_key_symbol_name(&dbgi_key, token_string); + if(symbol_voff != 0) + { + color = df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol); + } + } D_FancyString fancy_string = { ui_top_font(), diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index c406599c..6158d18b 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1292,7 +1292,7 @@ df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint p //- rjf: watch view column state mutation internal DF_WatchViewColumn * -df_watch_view_column_alloc(DF_WatchViewState *wv, DF_WatchViewColumnKind kind, F32 pct, String8 string) +df_watch_view_column_alloc_(DF_WatchViewState *wv, DF_WatchViewColumnKind kind, F32 pct, DF_WatchViewColumnParams *params) { if(!wv->free_column) { @@ -1305,8 +1305,10 @@ df_watch_view_column_alloc(DF_WatchViewState *wv, DF_WatchViewColumnKind kind, F wv->column_count += 1; col->kind = kind; col->pct = pct; - col->string_size = Min(sizeof(col->string_buffer), string.size); - MemoryCopy(col->string_buffer, string.str, col->string_size); + col->string_size = Min(sizeof(col->string_buffer), params->string.size); + MemoryCopy(col->string_buffer, params->string.str, col->string_size); + col->is_non_code = params->is_non_code; + col->dequote_string = params->dequote_string; return col; } @@ -1426,6 +1428,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS }; U64 frame_rows_count = 0; FrameRow *frame_rows = 0; + DF_CfgTable top_level_cfg_table = {0}; DF_EvalVizBlockList blocks = {0}; UI_ScrollListRowBlockArray row_blocks = {0}; Vec2S64 cursor_tbl = {0}; @@ -1475,7 +1478,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, expr_string); if(matches.count == matches.needle_part_count) { - DF_EvalVizBlockList watch_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, expr_string, parent_key, key); + DF_EvalVizBlockList watch_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, expr_string, parent_key, key); df_eval_viz_block_list_concat__in_place(&blocks, &watch_blocks);} } }break; @@ -1486,6 +1489,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS case DF_WatchViewFillKind_Breakpoints: { mutable_entity_kind = DF_EntityKind_Breakpoint; + df_cfg_table_push_unparsed_string(scratch.arena, &top_level_cfg_table, str8_lit("no_addr"), DF_CfgSrc_User); DF_EntityList bps = df_query_cached_entity_list_with_kind(mutable_entity_kind); for(DF_EntityNode *n = bps.first; n != 0; n = n->next) { @@ -1502,10 +1506,11 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { E_MemberList bp_members = {0}; { - e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Enabled"), .off = 0, .type_key = e_type_key_basic(E_TypeKind_S64)); + e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Enabled"), .off = 0, .type_key = e_type_key_basic(E_TypeKind_S64)); e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Hit Count"),.off = 0+8, .type_key = e_type_key_basic(E_TypeKind_U64)); e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Label"), .off = 0+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Location"), .off = 0+8+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); + e_member_list_push_new(scratch.arena, &bp_members, .name = str8_lit("Condition"),.off = 0+8+8+8+8,.type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); } E_MemberArray bp_members_array = e_member_array_from_list(scratch.arena, &bp_members); E_TypeKey bp_type = e_type_key_cons(.arch = architecture_from_context(), .kind = E_TypeKind_Struct, .name = str8_lit("Breakpoint"), .members = bp_members_array.v, .count = bp_members_array.count); @@ -1513,8 +1518,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS bp_expr->type_key = bp_type; bp_expr->mode = E_Mode_Offset; bp_expr->space = (U64)bp; - DF_CfgTable cfg_table = {0}; - df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, bp_expr, &cfg_table, 0, &blocks); + df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, bp_expr, &top_level_cfg_table, 0, &blocks); } } }break; @@ -1549,8 +1553,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS wp_expr->type_key = wp_type; wp_expr->mode = E_Mode_Offset; wp_expr->space = (U64)wp; - DF_CfgTable cfg_table = {0}; - df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, wp_expr, &cfg_table, 0, &blocks); + df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, wp_expr, &top_level_cfg_table, 0, &blocks); } } }break; @@ -1647,7 +1650,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { DF_ExpandKey parent_key = df_expand_key_make(5381, 0); DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), num); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, root_expr_string, parent_key, key); + DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, root_expr_string, parent_key, key); df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); } } @@ -1659,7 +1662,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { DF_ExpandKey parent_key = df_expand_key_make(5381, 0); DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), num); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, root_expr_string, parent_key, key); + DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, root_expr_string, parent_key, key); df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); } } @@ -1681,7 +1684,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { DF_ExpandKey parent_key = df_expand_key_make(5381, 0); DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), idx+1); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, root_expr_string, parent_key, key); + DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, root_expr_string, parent_key, key); df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); } } @@ -1786,7 +1789,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS } //- rjf: build blocks for all table items, split by sorted sub-expansions - DF_CfgTable *cfg_table = push_array(scratch.arena, DF_CfgTable, 1); + DF_CfgTable *cfg_table = &top_level_cfg_table; DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(scratch.arena, DF_EvalVizBlockKind_DebugInfoTable, parent_key, root_key, 0); { last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, items.count); @@ -1985,8 +1988,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS evt->flags & UI_EventFlag_Paste || (evt->kind == UI_EventKind_Press && evt->slot == UI_EventActionSlot_Edit)) && selection_tbl.min.x == selection_tbl.max.x && - (selection_tbl.min.y != 0 || selection_tbl.min.y != 0) && - (selection_tbl.min.x != 0 || modifiable)) + (selection_tbl.min.y != 0 || selection_tbl.min.y != 0)) { Vec2S64 selection_dim = dim_2s64(selection_tbl); ewv->text_editing = 1; @@ -2798,6 +2800,13 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS DF_WatchViewTextEditState *cell_edit_state = df_watch_view_text_edit_state_from_pt(ewv, cell_pt); B32 cell_selected = (row_selected && selection_tbl.min.x <= cell_pt.x && cell_pt.x <= selection_tbl.max.x); String8 cell_pre_edit_string = df_string_from_eval_viz_row_column(scratch.arena, eval_view, row, col, 0, default_radix, ui_top_font(), ui_top_font_size(), row_string_max_size_px); + if(col->dequote_string && + cell_pre_edit_string.size >= 2 && + cell_pre_edit_string.str[0] == '"' && + cell_pre_edit_string.str[cell_pre_edit_string.size-1] == '"') + { + cell_pre_edit_string = str8_skip(str8_chop(cell_pre_edit_string, 1), 1); + } //- rjf: unpack column-kind-specific info E_Eval cell_eval = row_eval; @@ -2875,16 +2884,12 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { cell_ui_hook = row->value_ui_rule_spec->info.row_ui; } - if(cell_eval.space >= E_Space_FIXED_COUNT) - { - cell_base_color = df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol); - } + cell_can_edit = df_type_key_is_editable(cell_eval.type_key); }break; case DF_WatchViewColumnKind_Type: { cell_can_edit = 0; E_TypeKey key = cell_eval.type_key; - cell_base_color = df_rgba_from_theme_color(DF_ThemeColor_CodeType); }break; case DF_WatchViewColumnKind_ViewRule: { @@ -2922,7 +2927,8 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS UI_Palette(palette) UI_TableCell UI_FocusHot(cell_selected ? UI_FocusKind_On : UI_FocusKind_Off) UI_FocusActive((cell_selected && ewv->text_editing) ? UI_FocusKind_On : UI_FocusKind_Off) - DF_Font(ws, DF_FontSlot_Code) UI_FlagsAdd(cell_flags | (row->depth > 0 ? UI_BoxFlag_DrawTextWeak : 0)) + DF_Font(ws, col->is_non_code ? DF_FontSlot_Main : DF_FontSlot_Code) + UI_FlagsAdd(cell_flags | (row->depth > 0 ? UI_BoxFlag_DrawTextWeak : 0)) { // rjf: cell has errors? -> build error box if(cell_error_string.size != 0) DF_Font(ws, DF_FontSlot_Main) @@ -2961,7 +2967,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS else { sig = df_line_editf(ws, - (DF_LineEditFlag_CodeContents| + (DF_LineEditFlag_CodeContents*(!col->is_non_code)| DF_LineEditFlag_NoBackground| DF_LineEditFlag_DisableEdit*(!cell_can_edit)| DF_LineEditFlag_Expander*!!(x == 0 && row_is_expandable && col->kind == DF_WatchViewColumnKind_Expr)| @@ -5934,9 +5940,9 @@ DF_VIEW_SETUP_FUNCTION_DEF(CallStack) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_CallStack); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_FrameSelection, 0.05f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.7f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Module, 0.25f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_FrameSelection, 0.05f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.7f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Module, 0.25f, .is_non_code = 1); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(CallStack) {return str8_zero();} DF_VIEW_CMD_FUNCTION_DEF(CallStack){} @@ -6872,10 +6878,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(Watch) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Watch); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Watch) {return str8_zero();} DF_VIEW_CMD_FUNCTION_DEF(Watch) @@ -6898,10 +6904,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(Locals) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Locals); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Locals) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Locals) {} @@ -6920,10 +6926,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(Registers) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Registers); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Registers) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Registers) {} @@ -6942,10 +6948,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(Globals) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Globals); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Globals) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Globals) {} @@ -6964,10 +6970,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(ThreadLocals) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_ThreadLocals); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(ThreadLocals) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(ThreadLocals) {} @@ -6986,10 +6992,10 @@ DF_VIEW_SETUP_FUNCTION_DEF(Types) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Types); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Types) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Types) {} @@ -7008,9 +7014,9 @@ DF_VIEW_SETUP_FUNCTION_DEF(Procedures) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Procedures); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.2f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.6f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.2f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.2f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.6f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.2f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Procedures) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Procedures) {} @@ -7980,10 +7986,11 @@ DF_VIEW_SETUP_FUNCTION_DEF(Breakpoints) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Breakpoints); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.25f, str8_lit("Label")); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.45f, str8_lit("Location")); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.10f, str8_lit("Enabled")); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.20f, str8_lit("Hit Count")); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.25f, .string = str8_lit("Label"), .dequote_string = 1, .is_non_code = 1); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.35f, .string = str8_lit("Location"), .dequote_string = 1, .is_non_code = 1); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.20f, .string = str8_lit("Condition"), .dequote_string = 1); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.10f, .string = str8_lit("Enabled")); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Member, 0.10f, .string = str8_lit("Hit Count")); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Breakpoints) {return str8_zero();} DF_VIEW_CMD_FUNCTION_DEF(Breakpoints) @@ -7995,7 +8002,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints) { ProfBeginFunction(); DF_WatchViewState *ewv = df_view_user_state(view, DF_WatchViewState); - df_watch_view_build(ws, panel, view, ewv, 1*(view->query_string_size == 0), 10, rect); + df_watch_view_build(ws, panel, view, ewv, 0, 10, rect); ProfEnd(); } @@ -8181,8 +8188,8 @@ DF_VIEW_SETUP_FUNCTION_DEF(WatchPins) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_WatchPins); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.5f, str8_zero()); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.5f, str8_zero()); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.5f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.5f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(WatchPins) {return str8_zero();} DF_VIEW_CMD_FUNCTION_DEF(WatchPins) @@ -8194,7 +8201,7 @@ DF_VIEW_UI_FUNCTION_DEF(WatchPins) { ProfBeginFunction(); DF_WatchViewState *ewv = df_view_user_state(view, DF_WatchViewState); - df_watch_view_build(ws, panel, view, ewv, 1*(view->query_string_size == 0), 10, rect); + df_watch_view_build(ws, panel, view, ewv, 0, 10, rect); ProfEnd(); } diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index 6398e86a..229d3788 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -283,6 +283,14 @@ typedef enum DF_WatchViewColumnKind } DF_WatchViewColumnKind; +typedef struct DF_WatchViewColumnParams DF_WatchViewColumnParams; +struct DF_WatchViewColumnParams +{ + String8 string; + B32 is_non_code; + B32 dequote_string; +}; + typedef struct DF_WatchViewColumn DF_WatchViewColumn; struct DF_WatchViewColumn { @@ -292,6 +300,8 @@ struct DF_WatchViewColumn F32 pct; U8 string_buffer[1024]; U64 string_size; + B32 is_non_code; + B32 dequote_string; }; typedef enum DF_WatchViewFillKind @@ -555,7 +565,8 @@ internal String8 df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *e internal DF_WatchViewTextEditState *df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint pt); //- rjf: watch view column state mutation -internal DF_WatchViewColumn *df_watch_view_column_alloc(DF_WatchViewState *wv, DF_WatchViewColumnKind kind, F32 pct, String8 string); +internal DF_WatchViewColumn *df_watch_view_column_alloc_(DF_WatchViewState *wv, DF_WatchViewColumnKind kind, F32 pct, DF_WatchViewColumnParams *params); +#define df_watch_view_column_alloc(wv, kind, pct, ...) df_watch_view_column_alloc_((wv), (kind), (pct), &(DF_WatchViewColumnParams){.string = str8_zero(), __VA_ARGS__}) internal void df_watch_view_column_release(DF_WatchViewState *wv, DF_WatchViewColumn *col); //- rjf: watch view main hooks diff --git a/src/eval/eval_interpret.h b/src/eval/eval_interpret.h index b718692a..caf1d194 100644 --- a/src/eval/eval_interpret.h +++ b/src/eval/eval_interpret.h @@ -66,4 +66,4 @@ internal B32 e_space_read(E_Space space, void *out, Rng1U64 range); internal E_Interpretation e_interpret(String8 bytecode); -#endif //EVAL_INTERPRET_H +#endif // EVAL_INTERPRET_H