mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-16 00:52:23 -07:00
begin prepping watch window ui for reintroduction of fancy rows; extend target/thread evaluations with .environment & .call_stack sketch; more convergence progress
This commit is contained in:
@@ -1597,6 +1597,7 @@ d_init(void)
|
||||
d_state->arena = arena;
|
||||
d_state->cmds_arena = arena_alloc();
|
||||
d_state->output_log_key = hs_hash_from_data(str8_lit("output_log_key"));
|
||||
hs_submit_data(d_state->output_log_key, 0, str8_zero());
|
||||
d_state->ctrl_entity_store = ctrl_entity_store_alloc();
|
||||
d_state->ctrl_stop_arena = arena_alloc();
|
||||
d_state->view_rule_spec_table_size = 1024;
|
||||
|
||||
@@ -969,6 +969,14 @@ e_irtree_const_u(Arena *arena, U64 v)
|
||||
return n;
|
||||
}
|
||||
|
||||
internal E_IRNode *
|
||||
e_irtree_leaf_u128(Arena *arena, U128 u128)
|
||||
{
|
||||
E_IRNode *n = e_push_irnode(arena, RDI_EvalOp_ConstU128);
|
||||
n->value.u128 = u128;
|
||||
return n;
|
||||
}
|
||||
|
||||
internal E_IRNode *
|
||||
e_irtree_unary_op(Arena *arena, RDI_EvalOp op, RDI_EvalTypeGroup group, E_IRNode *c)
|
||||
{
|
||||
|
||||
@@ -398,6 +398,7 @@ internal void e_irnode_push_child(E_IRNode *parent, E_IRNode *child);
|
||||
|
||||
//- rjf: ir subtree building helpers
|
||||
internal E_IRNode *e_irtree_const_u(Arena *arena, U64 v);
|
||||
internal E_IRNode *e_irtree_leaf_u128(Arena *arena, U128 u128);
|
||||
internal E_IRNode *e_irtree_unary_op(Arena *arena, RDI_EvalOp op, RDI_EvalTypeGroup group, E_IRNode *c);
|
||||
internal E_IRNode *e_irtree_binary_op(Arena *arena, RDI_EvalOp op, RDI_EvalTypeGroup group, E_IRNode *l, E_IRNode *r);
|
||||
internal E_IRNode *e_irtree_binary_op_u(Arena *arena, RDI_EvalOp op, E_IRNode *l, E_IRNode *r);
|
||||
|
||||
@@ -108,7 +108,10 @@ hs_submit_data(U128 key, Arena **data_arena, String8 data)
|
||||
node = push_array(stripe->arena, HS_Node, 1);
|
||||
}
|
||||
node->hash = hash;
|
||||
node->arena = *data_arena;
|
||||
if(data_arena != 0)
|
||||
{
|
||||
node->arena = *data_arena;
|
||||
}
|
||||
node->data = data;
|
||||
node->scope_ref_count = 0;
|
||||
node->key_ref_count = 1;
|
||||
@@ -117,9 +120,15 @@ hs_submit_data(U128 key, Arena **data_arena, String8 data)
|
||||
else
|
||||
{
|
||||
existing_node->key_ref_count += 1;
|
||||
arena_release(*data_arena);
|
||||
if(data_arena != 0)
|
||||
{
|
||||
arena_release(*data_arena);
|
||||
}
|
||||
}
|
||||
if(data_arena != 0)
|
||||
{
|
||||
*data_arena = 0;
|
||||
}
|
||||
*data_arena = 0;
|
||||
}
|
||||
|
||||
//- rjf: commit this hash to key cache
|
||||
@@ -330,7 +339,10 @@ hs_evictor_thread__entry_point(void *p)
|
||||
{
|
||||
DLLRemove(slot->first, slot->last, n);
|
||||
SLLStackPush(hs_shared->stripes_free_nodes[stripe_idx], n);
|
||||
arena_release(n->arena);
|
||||
if(n->arena != 0)
|
||||
{
|
||||
arena_release(n->arena);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+335
-21
@@ -4350,6 +4350,7 @@ rd_window_frame(void)
|
||||
{
|
||||
UI_PrefHeight(ui_px(line_edit_height_px, 1.f))
|
||||
{
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
UI_Signal sig = rd_line_edit(RD_LineEditFlag_Border|RD_LineEditFlag_CodeContents,
|
||||
0,
|
||||
0,
|
||||
@@ -4361,6 +4362,7 @@ rd_window_frame(void)
|
||||
0,
|
||||
str8(lister->input_buffer, lister->input_string_size),
|
||||
str8_lit("###lister_text_input"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5042,11 +5044,13 @@ rd_window_frame(void)
|
||||
//- rjf: name editor
|
||||
if(ctrl_entity->kind == CTRL_EntityKind_Thread) RD_Font(RD_FontSlot_Code) UI_TextPadding(ui_top_font_size()*1.5f)
|
||||
{
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
UI_Signal sig = rd_line_editf(RD_LineEditFlag_Border|RD_LineEditFlag_CodeContents, 0, 0, &ws->ctx_menu_input_cursor, &ws->ctx_menu_input_mark, ws->ctx_menu_input_buffer, ws->ctx_menu_input_buffer_size, &ws->ctx_menu_input_string_size, 0, ctrl_entity->string, "Name###ctrl_entity_string_edit_%p", ctrl_entity);
|
||||
if(ui_committed(sig))
|
||||
{
|
||||
rd_cmd(RD_CmdKind_SetEntityName, .ctrl_entity = ctrl_entity->handle, .string = str8(ws->ctx_menu_input_buffer, ws->ctx_menu_input_string_size));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// rjf: copy full path
|
||||
@@ -8730,7 +8734,7 @@ EV_VIEW_RULE_EXPR_EXPAND_NUM_FROM_ID_FUNCTION_DEF(scheduler_process)
|
||||
}
|
||||
#endif
|
||||
|
||||
//- rjf: debug info tables
|
||||
//- rjf: watch expressions
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(watches)
|
||||
{
|
||||
@@ -8817,6 +8821,8 @@ E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(watches)
|
||||
return num;
|
||||
}
|
||||
|
||||
//- rjf: local variables
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(locals)
|
||||
{
|
||||
E_LookupInfo result = {0};
|
||||
@@ -8857,6 +8863,8 @@ E_LOOKUP_RANGE_FUNCTION_DEF(locals)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: registers
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(registers)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
@@ -8905,6 +8913,8 @@ E_LOOKUP_RANGE_FUNCTION_DEF(registers)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: top-level configurations
|
||||
|
||||
typedef struct RD_TopLevelCfgLookupAccel RD_TopLevelCfgLookupAccel;
|
||||
struct RD_TopLevelCfgLookupAccel
|
||||
{
|
||||
@@ -9045,6 +9055,251 @@ E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(top_level_cfg)
|
||||
return num;
|
||||
}
|
||||
|
||||
//- rjf: threads / callstacks
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(thread)
|
||||
{
|
||||
E_LookupInfo result = E_LOOKUP_INFO_FUNCTION_NAME(default)(arena, lhs, filter);
|
||||
result.named_expr_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(thread)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_LookupAccess result = E_LOOKUP_ACCESS_FUNCTION_NAME(default)(arena, kind, lhs, rhs, user_data);
|
||||
if(kind == E_ExprKind_MemberAccess && rhs->kind == E_ExprKind_LeafMember && str8_match(rhs->string, str8_lit("call_stack"), 0))
|
||||
{
|
||||
E_Eval eval = e_eval_from_expr(scratch.arena, lhs);
|
||||
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
|
||||
result.irtree_and_type.root = e_irtree_leaf_u128(arena, u128_make(entity->handle.machine_id, entity->handle.dmn_handle.u64[0]));
|
||||
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("call_stack"));
|
||||
result.irtree_and_type.mode = E_Mode_Offset;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_RANGE_FUNCTION_DEF(thread)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_LOOKUP_RANGE_FUNCTION_NAME(default)(arena, lhs, idx_range, exprs, exprs_strings, user_data);
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(scratch.arena, lhs);
|
||||
E_Type *lhs_type = e_type_from_key__cached(lhs_irtree.type_key);
|
||||
Rng1U64 extras_idx_range = r1u64(lhs_type->count, max_U64);
|
||||
Rng1U64 extras_read_range = intersect_1u64(extras_idx_range, idx_range);
|
||||
U64 extras_count = dim_1u64(extras_read_range);
|
||||
for(U64 extras_idx = 0; extras_idx < extras_count; extras_idx += 1)
|
||||
{
|
||||
U64 out_idx = extras_idx_range.min - idx_range.min + extras_idx;
|
||||
exprs[out_idx] = e_expr_ref_member_access(arena, lhs, str8_lit("call_stack"));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
typedef struct RD_CallStackLookupAccel RD_CallStackLookupAccel;
|
||||
struct RD_CallStackLookupAccel
|
||||
{
|
||||
Arch arch;
|
||||
CTRL_CallStack call_stack;
|
||||
};
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(call_stack)
|
||||
{
|
||||
E_LookupInfo result = {0};
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
RD_CallStackLookupAccel *accel = push_array(arena, RD_CallStackLookupAccel, 1);
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
|
||||
E_Interpretation interp = e_interpret(bytecode);
|
||||
U128 u128 = interp.value.u128;
|
||||
CTRL_Handle handle = {0};
|
||||
MemoryCopyStruct(&handle, &u128);
|
||||
CTRL_Entity *entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, handle);
|
||||
if(entity->kind == CTRL_EntityKind_Thread)
|
||||
{
|
||||
CTRL_Entity *process = ctrl_process_from_entity(entity);
|
||||
CTRL_Unwind base_unwind = d_query_cached_unwind_from_thread(entity);
|
||||
accel->arch = entity->arch;
|
||||
accel->call_stack = ctrl_call_stack_from_unwind(arena, rd_state->frame_di_scope, process, &base_unwind);
|
||||
result.idxed_expr_count = accel->call_stack.total_frame_count;
|
||||
}
|
||||
result.user_data = accel;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(call_stack)
|
||||
{
|
||||
E_LookupAccess result = {{&e_irnode_nil}};
|
||||
if(kind == E_ExprKind_ArrayIndex)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_IRTreeAndType rhs_irtree = e_irtree_and_type_from_expr(scratch.arena, rhs);
|
||||
E_OpList rhs_oplist = e_oplist_from_irtree(scratch.arena, rhs_irtree.root);
|
||||
String8 rhs_bytecode = e_bytecode_from_oplist(scratch.arena, &rhs_oplist);
|
||||
E_Interpretation rhs_interp = e_interpret(rhs_bytecode);
|
||||
E_Value rhs_value = rhs_interp.value;
|
||||
RD_CallStackLookupAccel *accel = (RD_CallStackLookupAccel *)user_data;
|
||||
CTRL_CallStack *call_stack = &accel->call_stack;
|
||||
if(0 <= rhs_value.u64 && rhs_value.u64 < call_stack->total_frame_count)
|
||||
{
|
||||
U64 frame_idx = 0;
|
||||
#if 0
|
||||
for(U64 base_idx = 0; base_idx < call_stack->concrete_frame_count; base_idx += 1, frame_idx += 1)
|
||||
{
|
||||
CTRL_CallStackFrame *base_frame = call_stack->frames + base_idx;
|
||||
for(CTRL_CallStackInlineFrame *inline_frame = base_frame->first_inline_frame; inline_frame != 0; inline_frame = inline_frame->next, frame_idx += 1)
|
||||
{
|
||||
if(frame_idx == rhs_value.u64)
|
||||
{
|
||||
result.irtree_and_type.root = e_irtree_const_u(arena, );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: targets / environment
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(target)
|
||||
{
|
||||
E_LookupInfo result = E_LOOKUP_INFO_FUNCTION_NAME(default)(arena, lhs, filter);
|
||||
result.named_expr_count += 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(target)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_LookupAccess result = E_LOOKUP_ACCESS_FUNCTION_NAME(default)(arena, kind, lhs, rhs, user_data);
|
||||
if(kind == E_ExprKind_MemberAccess && rhs->kind == E_ExprKind_LeafMember && str8_match(rhs->string, str8_lit("environment"), 0))
|
||||
{
|
||||
E_Eval eval = e_eval_from_expr(scratch.arena, lhs);
|
||||
RD_Cfg *cfg = rd_cfg_from_eval_space(eval.space);
|
||||
result.irtree_and_type.root = e_irtree_const_u(arena, cfg->id);
|
||||
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("environment"));
|
||||
result.irtree_and_type.mode = E_Mode_Offset;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_RANGE_FUNCTION_DEF(target)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_LOOKUP_RANGE_FUNCTION_NAME(default)(arena, lhs, idx_range, exprs, exprs_strings, user_data);
|
||||
E_IRTreeAndType lhs_irtree = e_irtree_and_type_from_expr(scratch.arena, lhs);
|
||||
E_Type *lhs_type = e_type_from_key__cached(lhs_irtree.type_key);
|
||||
Rng1U64 extras_idx_range = r1u64(lhs_type->count, max_U64);
|
||||
Rng1U64 extras_read_range = intersect_1u64(extras_idx_range, idx_range);
|
||||
U64 extras_count = dim_1u64(extras_read_range);
|
||||
for(U64 extras_idx = 0; extras_idx < extras_count; extras_idx += 1)
|
||||
{
|
||||
U64 out_idx = extras_idx_range.min - idx_range.min + extras_idx;
|
||||
exprs[out_idx] = e_expr_ref_member_access(arena, lhs, str8_lit("environment"));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(environment)
|
||||
{
|
||||
E_LookupInfo result = {0};
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
|
||||
E_Interpretation interpret = e_interpret(bytecode);
|
||||
RD_CfgID id = interpret.value.u64;
|
||||
RD_Cfg *target = rd_cfg_from_id(id);
|
||||
RD_Cfg *env = rd_cfg_child_from_string(target, str8_lit("environment"));
|
||||
RD_CfgList env_strings = {0};
|
||||
for(RD_Cfg *child = env->first; child != &rd_nil_cfg; child = child->next)
|
||||
{
|
||||
rd_cfg_list_push(scratch.arena, &env_strings, child);
|
||||
}
|
||||
RD_CfgArray *accel = push_array(arena, RD_CfgArray, 1);
|
||||
*accel = rd_cfg_array_from_list(arena, &env_strings);
|
||||
result.user_data = accel;
|
||||
result.idxed_expr_count = accel->count + 1;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(environment)
|
||||
{
|
||||
E_LookupAccess result = {{&e_irnode_nil}};
|
||||
if(kind == E_ExprKind_ArrayIndex)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
RD_CfgArray *accel = (RD_CfgArray *)user_data;
|
||||
E_IRTreeAndType rhs_irtree = e_irtree_and_type_from_expr(scratch.arena, rhs);
|
||||
E_OpList rhs_oplist = e_oplist_from_irtree(scratch.arena, rhs_irtree.root);
|
||||
String8 rhs_bytecode = e_bytecode_from_oplist(scratch.arena, &rhs_oplist);
|
||||
E_Interpretation rhs_interp = e_interpret(rhs_bytecode);
|
||||
E_Value rhs_value = rhs_interp.value;
|
||||
U64 rhs_index = rhs_value.u64;
|
||||
if(contains_1u64(r1u64(0, accel->count), rhs_index))
|
||||
{
|
||||
RD_Cfg *env_string = accel->v[rhs_index];
|
||||
E_TypeKey type_key = e_type_key_cons_ptr(arch_from_context(), e_type_key_basic(E_TypeKind_U8), 1, E_TypeFlag_IsCodeText);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, rd_eval_space_from_cfg(env_string), e_irtree_const_u(arena, 0));
|
||||
result.irtree_and_type.type_key = type_key;
|
||||
result.irtree_and_type.mode = E_Mode_Offset;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_ID_FROM_NUM_FUNCTION_DEF(environment)
|
||||
{
|
||||
U64 id = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
if(1 <= num && num <= cfgs->count)
|
||||
{
|
||||
U64 idx = (num-1);
|
||||
id = cfgs->v[idx]->id;
|
||||
}
|
||||
else if(num == cfgs->count+1)
|
||||
{
|
||||
id = max_U64;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
E_LOOKUP_NUM_FROM_ID_FUNCTION_DEF(environment)
|
||||
{
|
||||
U64 num = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
if(id != 0 && id != max_U64)
|
||||
{
|
||||
for EachIndex(idx, cfgs->count)
|
||||
{
|
||||
if(cfgs->v[idx]->id == id)
|
||||
{
|
||||
num = idx+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == max_U64)
|
||||
{
|
||||
num = cfgs->count + 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
//- rjf: control entities
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(ctrl_entities)
|
||||
{
|
||||
E_LookupInfo result = {0};
|
||||
@@ -9113,6 +9368,8 @@ E_LOOKUP_ACCESS_FUNCTION_DEF(ctrl_entities)
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: debug info tables
|
||||
|
||||
typedef struct RD_DebugInfoTableLookupAccel RD_DebugInfoTableLookupAccel;
|
||||
struct RD_DebugInfoTableLookupAccel
|
||||
{
|
||||
@@ -12932,17 +13189,37 @@ rd_frame(void)
|
||||
}
|
||||
|
||||
//- rjf: add macros for evallable config trees
|
||||
String8 evallable_cfg_names[] =
|
||||
struct
|
||||
{
|
||||
str8_lit("breakpoint"),
|
||||
str8_lit("watch_pin"),
|
||||
str8_lit("target"),
|
||||
str8_lit("file_path_map"),
|
||||
str8_lit("auto_view_rule"),
|
||||
String8 name;
|
||||
E_LookupInfoFunctionType *info;
|
||||
E_LookupAccessFunctionType *access;
|
||||
E_LookupRangeFunctionType *range;
|
||||
E_LookupIDFromNumFunctionType *id_from_num;
|
||||
E_LookupNumFromIDFunctionType *num_from_id;
|
||||
}
|
||||
evallable_cfg_table[] =
|
||||
{
|
||||
{ str8_lit("breakpoint") },
|
||||
{ str8_lit("watch_pin") },
|
||||
{ str8_lit("target"), .info = E_LOOKUP_INFO_FUNCTION_NAME(target), .access = E_LOOKUP_ACCESS_FUNCTION_NAME(target), .range = E_LOOKUP_RANGE_FUNCTION_NAME(target) },
|
||||
{ str8_lit("file_path_map") },
|
||||
{ str8_lit("auto_view_rule") },
|
||||
};
|
||||
for EachElement(idx, evallable_cfg_names)
|
||||
for EachElement(idx, evallable_cfg_table)
|
||||
{
|
||||
String8 name = evallable_cfg_names[idx];
|
||||
String8 name = evallable_cfg_table[idx].name;
|
||||
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name);
|
||||
if(evallable_cfg_table[idx].info != 0)
|
||||
{
|
||||
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, name,
|
||||
.info = evallable_cfg_table[idx].info,
|
||||
.access = evallable_cfg_table[idx].access,
|
||||
.range = evallable_cfg_table[idx].range,
|
||||
.id_from_num = evallable_cfg_table[idx].id_from_num,
|
||||
.num_from_id = evallable_cfg_table[idx].num_from_id);
|
||||
e_auto_hook_map_insert_new(scratch.arena, ctx->auto_hook_map, .type_key = type_key, .tag_expr_string = name);
|
||||
}
|
||||
RD_CfgList cfgs = rd_cfg_top_level_list_from_string(scratch.arena, name);
|
||||
for(RD_CfgNode *n = cfgs.first; n != 0; n = n->next)
|
||||
{
|
||||
@@ -12953,7 +13230,7 @@ rd_frame(void)
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
|
||||
expr->space = space;
|
||||
expr->mode = E_Mode_Offset;
|
||||
expr->type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name);
|
||||
expr->type_key = type_key;
|
||||
e_string2expr_map_insert(scratch.arena, ctx->macro_map, push_str8f(scratch.arena, "$%I64u", cfg->id), expr);
|
||||
if(exe.size != 0)
|
||||
{
|
||||
@@ -12967,19 +13244,38 @@ rd_frame(void)
|
||||
}
|
||||
|
||||
//- rjf: add macros for evallable control entities
|
||||
String8 evallable_ctrl_names[] =
|
||||
struct
|
||||
{
|
||||
str8_lit("machine"),
|
||||
str8_lit("process"),
|
||||
str8_lit("thread"),
|
||||
str8_lit("module"),
|
||||
String8 name;
|
||||
E_LookupInfoFunctionType *info;
|
||||
E_LookupAccessFunctionType *access;
|
||||
E_LookupRangeFunctionType *range;
|
||||
E_LookupIDFromNumFunctionType *id_from_num;
|
||||
E_LookupNumFromIDFunctionType *num_from_id;
|
||||
}
|
||||
evallable_ctrl_table[] =
|
||||
{
|
||||
{ str8_lit("machine") },
|
||||
{ str8_lit("process") },
|
||||
{ str8_lit("thread"), .info = E_LOOKUP_INFO_FUNCTION_NAME(thread), .access = E_LOOKUP_ACCESS_FUNCTION_NAME(thread), .range = E_LOOKUP_RANGE_FUNCTION_NAME(thread) },
|
||||
{ str8_lit("module") },
|
||||
};
|
||||
for EachElement(idx, evallable_ctrl_names)
|
||||
for EachElement(idx, evallable_ctrl_table)
|
||||
{
|
||||
String8 name = evallable_ctrl_names[idx];
|
||||
String8 name = evallable_ctrl_table[idx].name;
|
||||
CTRL_EntityKind kind = ctrl_entity_kind_from_string(name);
|
||||
CTRL_EntityList list = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, kind);
|
||||
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name);
|
||||
if(evallable_ctrl_table[idx].info != 0)
|
||||
{
|
||||
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, name,
|
||||
.info = evallable_ctrl_table[idx].info,
|
||||
.access = evallable_ctrl_table[idx].access,
|
||||
.range = evallable_ctrl_table[idx].range,
|
||||
.id_from_num = evallable_ctrl_table[idx].id_from_num,
|
||||
.num_from_id = evallable_ctrl_table[idx].num_from_id);
|
||||
e_auto_hook_map_insert_new(scratch.arena, ctx->auto_hook_map, .type_key = type_key, .tag_expr_string = name);
|
||||
}
|
||||
for(CTRL_EntityNode *n = list.first; n != 0; n = n->next)
|
||||
{
|
||||
CTRL_Entity *entity = n->v;
|
||||
@@ -13008,6 +13304,12 @@ rd_frame(void)
|
||||
e_auto_hook_map_insert_new(scratch.arena, ctx->auto_hook_map, .type_key = type_key, .tag_expr_string = name);
|
||||
}
|
||||
|
||||
//- rjf: add macro for 'call_stack' -> 'current_thread.callstack'
|
||||
{
|
||||
E_Expr *expr = e_parse_expr_from_text(scratch.arena, str8_lit("current_thread.call_stack"));
|
||||
e_string2expr_map_insert(scratch.arena, ctx->macro_map, str8_lit("call_stack"), expr);
|
||||
}
|
||||
|
||||
//- rjf: add macro for watches group
|
||||
{
|
||||
String8 collection_name = str8_lit("watches");
|
||||
@@ -13021,6 +13323,18 @@ rd_frame(void)
|
||||
.num_from_id = E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(watches));
|
||||
}
|
||||
|
||||
//- rjf: add lookup rules for queries
|
||||
{
|
||||
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, str8_lit("environment"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(environment),
|
||||
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(environment),
|
||||
.id_from_num = E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(environment),
|
||||
.num_from_id = E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(environment));
|
||||
e_lookup_rule_map_insert_new(scratch.arena, ctx->lookup_rule_map, str8_lit("call_stack"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(call_stack),
|
||||
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(call_stack));
|
||||
}
|
||||
|
||||
//- rjf: add macro for collections with specific lookup rules (but no unique id rules)
|
||||
{
|
||||
struct
|
||||
@@ -13070,9 +13384,9 @@ rd_frame(void)
|
||||
}
|
||||
|
||||
//- rjf: add macros for all config collections
|
||||
for EachElement(cfg_name_idx, evallable_cfg_names)
|
||||
for EachElement(cfg_name_idx, evallable_cfg_table)
|
||||
{
|
||||
String8 cfg_name = evallable_cfg_names[cfg_name_idx];
|
||||
String8 cfg_name = evallable_cfg_table[cfg_name_idx].name;
|
||||
String8 collection_name = rd_plural_from_code_name(cfg_name);
|
||||
E_TypeKey collection_type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = collection_name);
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
|
||||
@@ -13086,9 +13400,9 @@ rd_frame(void)
|
||||
}
|
||||
|
||||
//- rjf: add macros for all ctrl entity collections
|
||||
for EachElement(ctrl_name_idx, evallable_ctrl_names)
|
||||
for EachElement(ctrl_name_idx, evallable_ctrl_table)
|
||||
{
|
||||
String8 kind_name = evallable_ctrl_names[ctrl_name_idx];
|
||||
String8 kind_name = evallable_ctrl_table[ctrl_name_idx].name;
|
||||
String8 collection_name = rd_plural_from_code_name(kind_name);
|
||||
E_TypeKey collection_type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = collection_name);
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
|
||||
|
||||
+28
-18
@@ -957,8 +957,17 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
|
||||
// rjf: fill row's cells
|
||||
{
|
||||
#if 0
|
||||
// rjf: singular cell for cfgs
|
||||
if(info.group_cfg != &rd_nil_cfg)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Button, .pct = 1.f);
|
||||
}
|
||||
#endif
|
||||
if(0){}
|
||||
|
||||
// rjf: singular cell for view ui
|
||||
if(info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
else if(info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_ViewUI, .pct = 1.f);
|
||||
}
|
||||
@@ -2660,17 +2669,24 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
|
||||
// rjf: build cell line edit
|
||||
else
|
||||
{
|
||||
sig = rd_line_editf((RD_LineEditFlag_CodeContents|
|
||||
RD_LineEditFlag_NoBackground|
|
||||
RD_LineEditFlag_KeyboardClickable|
|
||||
RD_LineEditFlag_Expander*!!(cell_x == 0 && row_is_expandable && cell == row_info.cells.first)|
|
||||
RD_LineEditFlag_ExpanderPlaceholder*(cell_x == 0 && row_depth==0 && cell == row_info.cells.first)|
|
||||
RD_LineEditFlag_ExpanderSpace*(cell_x == 0 && row_depth!=0 && cell == row_info.cells.first)),
|
||||
cell_x == 0 ? row_depth : 0,
|
||||
0,
|
||||
&cell_edit_state->cursor, &cell_edit_state->mark, cell_edit_state->input_buffer, sizeof(cell_edit_state->input_buffer), &cell_edit_state->input_size, &next_row_expanded,
|
||||
cell_info.string,
|
||||
"%S###%I64x_row_%I64x", str8_zero(), cell_x, row_hash);
|
||||
RD_LineEditParams line_edit_params = {0};
|
||||
{
|
||||
line_edit_params.flags = (RD_LineEditFlag_CodeContents|
|
||||
RD_LineEditFlag_NoBackground|
|
||||
RD_LineEditFlag_KeyboardClickable|
|
||||
RD_LineEditFlag_Expander*!!(cell_x == 0 && row_is_expandable && cell == row_info.cells.first)|
|
||||
RD_LineEditFlag_ExpanderPlaceholder*(cell_x == 0 && row_depth==0 && cell == row_info.cells.first)|
|
||||
RD_LineEditFlag_ExpanderSpace*(cell_x == 0 && row_depth!=0 && cell == row_info.cells.first));
|
||||
line_edit_params.depth = (cell_x == 0 ? row_depth : 0);
|
||||
line_edit_params.cursor = &cell_edit_state->cursor;
|
||||
line_edit_params.mark = &cell_edit_state->mark;
|
||||
line_edit_params.edit_buffer = cell_edit_state->input_buffer;
|
||||
line_edit_params.edit_buffer_size = sizeof(cell_edit_state->input_buffer);
|
||||
line_edit_params.edit_string_size_out = &cell_edit_state->input_size;
|
||||
line_edit_params.expanded_out = &next_row_expanded;
|
||||
line_edit_params.pre_edit_value = cell_info.string;
|
||||
}
|
||||
sig = rd_line_editf(&line_edit_params, "%S###%I64x_row_%I64x", str8_zero(), cell_x, row_hash);
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
if(ui_is_focus_active() &&
|
||||
selection_tbl.min.x == selection_tbl.max.x && selection_tbl.min.y == selection_tbl.max.y &&
|
||||
@@ -2718,12 +2734,6 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
|
||||
|
||||
|
||||
#if 0 // TODO(rjf): @cfg
|
||||
// rjf: can edit? -> begin editing
|
||||
else if(cell_can_edit)
|
||||
{
|
||||
rd_cmd(RD_CmdKind_Edit);
|
||||
}
|
||||
|
||||
// rjf: cannot edit, has addr info? -> go to address
|
||||
else if(row_kind == RD_WatchViewRowKind_Normal &&
|
||||
(col->kind == RD_WatchViewColumnKind_Value ||
|
||||
|
||||
@@ -43,10 +43,11 @@ struct RD_CodeViewBuildResult
|
||||
|
||||
typedef enum RD_WatchCellKind
|
||||
{
|
||||
RD_WatchCellKind_Expr, // strings to represent expression itself
|
||||
RD_WatchCellKind_Tag, // strings to represent attached tags at row-granularity
|
||||
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
|
||||
RD_WatchCellKind_ViewUI,
|
||||
RD_WatchCellKind_Expr, // strings to represent expression itself
|
||||
RD_WatchCellKind_Tag, // strings to represent attached tags at row-granularity
|
||||
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
|
||||
RD_WatchCellKind_ViewUI, // an arbitrary user interface, supplied by a hook
|
||||
RD_WatchCellKind_Button, // a fancy button dedicated to the entire row's evaluation, used for listers/etc.
|
||||
}
|
||||
RD_WatchCellKind;
|
||||
|
||||
|
||||
+69
-69
@@ -2424,7 +2424,7 @@ rd_code_label(F32 alpha, B32 indirection_size_change, Vec4F32 base_color, String
|
||||
//~ rjf: UI Widgets: Line Edit
|
||||
|
||||
internal UI_Signal
|
||||
rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size, U64 *edit_string_size_out, B32 *expanded_out, String8 pre_edit_value, String8 string)
|
||||
rd_line_edit(RD_LineEditParams *params, String8 string)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
|
||||
@@ -2450,36 +2450,36 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
ui_set_next_hover_cursor(OS_Cursor_IBar);
|
||||
}
|
||||
UI_Box *box = ui_build_box_from_key(UI_BoxFlag_MouseClickable|
|
||||
(!!(flags & RD_LineEditFlag_KeyboardClickable)*UI_BoxFlag_KeyboardClickable)|
|
||||
(!!(params->flags & RD_LineEditFlag_KeyboardClickable)*UI_BoxFlag_KeyboardClickable)|
|
||||
UI_BoxFlag_ClickToFocus|
|
||||
UI_BoxFlag_DrawHotEffects|
|
||||
(!(flags & RD_LineEditFlag_NoBackground)*UI_BoxFlag_DrawBackground)|
|
||||
(!!(flags & RD_LineEditFlag_Border)*UI_BoxFlag_DrawBorder)|
|
||||
(!(params->flags & RD_LineEditFlag_NoBackground)*UI_BoxFlag_DrawBackground)|
|
||||
(!!(params->flags & RD_LineEditFlag_Border)*UI_BoxFlag_DrawBorder)|
|
||||
((is_auto_focus_hot || is_auto_focus_active)*UI_BoxFlag_KeyboardClickable)|
|
||||
(is_focus_active || is_focus_active_disabled)*(UI_BoxFlag_Clip),
|
||||
key);
|
||||
|
||||
//- rjf: build indent
|
||||
UI_Parent(box) for(S32 idx = 0; idx < depth; idx += 1)
|
||||
UI_Parent(box) for(S32 idx = 0; idx < params->depth; idx += 1)
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_DrawSideLeft);
|
||||
ui_spacer(ui_em(1.f, 1.f));
|
||||
}
|
||||
|
||||
//- rjf: build expander
|
||||
if(flags & RD_LineEditFlag_Expander) UI_PrefWidth(ui_px(expander_size_px, 1.f)) UI_Parent(box)
|
||||
if(params->flags & RD_LineEditFlag_Expander) UI_PrefWidth(ui_px(expander_size_px, 1.f)) UI_Parent(box)
|
||||
UI_Flags(UI_BoxFlag_DrawSideLeft)
|
||||
UI_Focus(UI_FocusKind_Off)
|
||||
{
|
||||
UI_Signal expander_sig = ui_expanderf(*expanded_out, "expander");
|
||||
UI_Signal expander_sig = ui_expanderf(params->expanded_out[0], "expander");
|
||||
if(ui_pressed(expander_sig))
|
||||
{
|
||||
*expanded_out ^= 1;
|
||||
params->expanded_out[0] ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: build expander placeholder
|
||||
else if(flags & RD_LineEditFlag_ExpanderPlaceholder) UI_Parent(box) UI_PrefWidth(ui_px(expander_size_px, 1.f)) UI_Focus(UI_FocusKind_Off)
|
||||
else if(params->flags & RD_LineEditFlag_ExpanderPlaceholder) UI_Parent(box) UI_PrefWidth(ui_px(expander_size_px, 1.f)) UI_Focus(UI_FocusKind_Off)
|
||||
{
|
||||
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
|
||||
UI_Flags(UI_BoxFlag_DrawSideLeft)
|
||||
@@ -2489,7 +2489,7 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
}
|
||||
|
||||
//- rjf: build expander space
|
||||
else if(flags & RD_LineEditFlag_ExpanderSpace) UI_Parent(box) UI_Focus(UI_FocusKind_Off)
|
||||
else if(params->flags & RD_LineEditFlag_ExpanderSpace) UI_Parent(box) UI_Focus(UI_FocusKind_Off)
|
||||
{
|
||||
UI_Flags(UI_BoxFlag_DrawSideLeft) ui_spacer(ui_px(expander_size_px, 1.f));
|
||||
}
|
||||
@@ -2498,7 +2498,7 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
UI_Box *scrollable_box = &ui_nil_box;
|
||||
UI_Parent(box) UI_PrefWidth(ui_children_sum(0))
|
||||
{
|
||||
scrollable_box = ui_build_box_from_stringf(is_focus_active*(UI_BoxFlag_AllowOverflowX), "scroll_box_%p", edit_buffer);
|
||||
scrollable_box = ui_build_box_from_stringf(is_focus_active*(UI_BoxFlag_AllowOverflowX), "scroll_box_%p", params->edit_buffer);
|
||||
}
|
||||
|
||||
//- rjf: do non-textual edits (delete, copy, cut)
|
||||
@@ -2509,12 +2509,12 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
{
|
||||
if(evt->flags & UI_EventFlag_Copy)
|
||||
{
|
||||
os_set_clipboard_text(pre_edit_value);
|
||||
os_set_clipboard_text(params->pre_edit_value);
|
||||
}
|
||||
if(evt->flags & UI_EventFlag_Delete)
|
||||
{
|
||||
commit = 1;
|
||||
edit_string_size_out[0] = 0;
|
||||
params->edit_string_size_out[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2549,14 +2549,14 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
}
|
||||
if(start_editing_via_sig || start_editing_via_typing)
|
||||
{
|
||||
String8 edit_string = pre_edit_value;
|
||||
edit_string.size = Min(edit_buffer_size, pre_edit_value.size);
|
||||
MemoryCopy(edit_buffer, edit_string.str, edit_string.size);
|
||||
edit_string_size_out[0] = edit_string.size;
|
||||
String8 edit_string = params->pre_edit_value;
|
||||
edit_string.size = Min(params->edit_buffer_size, params->pre_edit_value.size);
|
||||
MemoryCopy(params->edit_buffer, edit_string.str, edit_string.size);
|
||||
params->edit_string_size_out[0] = edit_string.size;
|
||||
ui_set_auto_focus_active_key(key);
|
||||
ui_kill_action();
|
||||
*cursor = txt_pt(1, edit_string.size+1);
|
||||
*mark = txt_pt(1, 1);
|
||||
params->cursor[0] = txt_pt(1, edit_string.size+1);
|
||||
params->mark[0] = txt_pt(1, 1);
|
||||
focus_started = 1;
|
||||
}
|
||||
}
|
||||
@@ -2580,13 +2580,13 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
|
||||
//- rjf: take navigation actions for editing
|
||||
B32 changes_made = 0;
|
||||
if(!(flags & RD_LineEditFlag_DisableEdit) && (is_focus_active || focus_started))
|
||||
if(!(params->flags & RD_LineEditFlag_DisableEdit) && (is_focus_active || focus_started))
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
rd_state->text_edit_mode = 1;
|
||||
for(UI_Event *evt = 0; ui_next_event(&evt);)
|
||||
{
|
||||
String8 edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
String8 edit_string = str8(params->edit_buffer, params->edit_string_size_out[0]);
|
||||
|
||||
// rjf: do not consume anything that doesn't fit a single-line's operations
|
||||
if((evt->kind != UI_EventKind_Edit && evt->kind != UI_EventKind_Navigate && evt->kind != UI_EventKind_Text) || evt->delta_2s32.y != 0)
|
||||
@@ -2595,20 +2595,20 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
}
|
||||
|
||||
// rjf: map this action to an op
|
||||
UI_TxtOp op = ui_single_line_txt_op_from_event(scratch.arena, evt, edit_string, *cursor, *mark);
|
||||
UI_TxtOp op = ui_single_line_txt_op_from_event(scratch.arena, evt, edit_string, params->cursor[0], params->mark[0]);
|
||||
|
||||
// rjf: any valid op & autocomplete hint? -> perform autocomplete first, then re-compute op
|
||||
if(autocomplete_hint_string.size != 0)
|
||||
{
|
||||
String8 word_query = rd_lister_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
String8 word_query = rd_lister_query_word_from_input_string_off(edit_string, params->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);
|
||||
MemoryCopy(edit_buffer, new_string.str, new_string.size);
|
||||
edit_string_size_out[0] = new_string.size;
|
||||
*cursor = *mark = txt_pt(1, word_off+1+autocomplete_hint_string.size);
|
||||
edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
op = ui_single_line_txt_op_from_event(scratch.arena, evt, edit_string, *cursor, *mark);
|
||||
new_string.size = Min(params->edit_buffer_size, new_string.size);
|
||||
MemoryCopy(params->edit_buffer, new_string.str, new_string.size);
|
||||
params->edit_string_size_out[0] = new_string.size;
|
||||
params->cursor[0] = params->mark[0] = txt_pt(1, word_off+1+autocomplete_hint_string.size);
|
||||
edit_string = str8(params->edit_buffer, params->edit_string_size_out[0]);
|
||||
op = ui_single_line_txt_op_from_event(scratch.arena, evt, edit_string, params->cursor[0], params->mark[0]);
|
||||
MemoryZeroStruct(&autocomplete_hint_string);
|
||||
}
|
||||
|
||||
@@ -2616,9 +2616,9 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
if(!txt_pt_match(op.range.min, op.range.max) || op.replace.size != 0)
|
||||
{
|
||||
String8 new_string = ui_push_string_replace_range(scratch.arena, edit_string, r1s64(op.range.min.column, op.range.max.column), op.replace);
|
||||
new_string.size = Min(edit_buffer_size, new_string.size);
|
||||
MemoryCopy(edit_buffer, new_string.str, new_string.size);
|
||||
edit_string_size_out[0] = new_string.size;
|
||||
new_string.size = Min(params->edit_buffer_size, new_string.size);
|
||||
MemoryCopy(params->edit_buffer, new_string.str, new_string.size);
|
||||
params->edit_string_size_out[0] = new_string.size;
|
||||
}
|
||||
|
||||
// rjf: perform copy
|
||||
@@ -2628,8 +2628,8 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
}
|
||||
|
||||
// rjf: commit op's changed cursor & mark to caller-provided state
|
||||
*cursor = op.cursor;
|
||||
*mark = op.mark;
|
||||
params->cursor[0] = op.cursor;
|
||||
params->mark[0] = op.mark;
|
||||
|
||||
// rjf: consume event
|
||||
{
|
||||
@@ -2645,68 +2645,68 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
F32 cursor_off = 0;
|
||||
UI_Parent(scrollable_box)
|
||||
{
|
||||
if(!is_focus_active && !is_focus_active_disabled && flags & RD_LineEditFlag_CodeContents)
|
||||
if(!is_focus_active && !is_focus_active_disabled && params->flags & RD_LineEditFlag_CodeContents)
|
||||
{
|
||||
String8 display_string = ui_display_part_from_key_string(string);
|
||||
if(!(flags & RD_LineEditFlag_PreferDisplayString) && pre_edit_value.size != 0)
|
||||
if(!(params->flags & RD_LineEditFlag_PreferDisplayString) && params->pre_edit_value.size != 0)
|
||||
{
|
||||
display_string = pre_edit_value;
|
||||
display_string = params->pre_edit_value;
|
||||
UI_Box *box = rd_code_label(1.f, 1, ui_top_palette()->text, display_string);
|
||||
if(matches != 0)
|
||||
if(params->fuzzy_matches != 0)
|
||||
{
|
||||
ui_box_equip_fuzzy_match_ranges(box, matches);
|
||||
ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches);
|
||||
}
|
||||
}
|
||||
else if(flags & RD_LineEditFlag_DisplayStringIsCode)
|
||||
else if(params->flags & RD_LineEditFlag_DisplayStringIsCode)
|
||||
{
|
||||
UI_Box *box = rd_code_label(1.f, 1, ui_top_palette()->text, display_string);
|
||||
if(matches != 0)
|
||||
if(params->fuzzy_matches != 0)
|
||||
{
|
||||
ui_box_equip_fuzzy_match_ranges(box, matches);
|
||||
ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_DrawTextWeak);
|
||||
UI_Box *box = ui_label(display_string).box;
|
||||
if(matches != 0)
|
||||
if(params->fuzzy_matches != 0)
|
||||
{
|
||||
ui_box_equip_fuzzy_match_ranges(box, matches);
|
||||
ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!is_focus_active && !is_focus_active_disabled && !(flags & RD_LineEditFlag_CodeContents))
|
||||
else if(!is_focus_active && !is_focus_active_disabled && !(params->flags & RD_LineEditFlag_CodeContents))
|
||||
{
|
||||
String8 display_string = ui_display_part_from_key_string(string);
|
||||
if(!(flags & RD_LineEditFlag_PreferDisplayString) && pre_edit_value.size != 0)
|
||||
if(!(params->flags & RD_LineEditFlag_PreferDisplayString) && params->pre_edit_value.size != 0)
|
||||
{
|
||||
display_string = pre_edit_value;
|
||||
display_string = params->pre_edit_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_DrawTextWeak);
|
||||
}
|
||||
UI_Box *box = ui_label(display_string).box;
|
||||
if(matches != 0)
|
||||
if(params->fuzzy_matches != 0)
|
||||
{
|
||||
ui_box_equip_fuzzy_match_ranges(box, matches);
|
||||
ui_box_equip_fuzzy_match_ranges(box, params->fuzzy_matches);
|
||||
}
|
||||
}
|
||||
else if((is_focus_active || is_focus_active_disabled) && flags & RD_LineEditFlag_CodeContents)
|
||||
else if((is_focus_active || is_focus_active_disabled) && params->flags & RD_LineEditFlag_CodeContents)
|
||||
{
|
||||
String8 edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
String8 edit_string = str8(params->edit_buffer, params->edit_string_size_out[0]);
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
F32 total_text_width = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_editstr_width = total_text_width - !!(flags & (RD_LineEditFlag_Expander|RD_LineEditFlag_ExpanderSpace|RD_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
F32 total_editstr_width = total_text_width - !!(params->flags & (RD_LineEditFlag_Expander|RD_LineEditFlag_ExpanderSpace|RD_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f));
|
||||
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
|
||||
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_lister_query_word_from_input_string_off(edit_string, cursor->column-1);
|
||||
String8 query_word = rd_lister_query_word_from_input_string_off(edit_string, params->cursor->column-1);
|
||||
String8 autocomplete_append_string = str8_skip(autocomplete_hint_string, query_word.size);
|
||||
U64 off = 0;
|
||||
U64 cursor_off = cursor->column-1;
|
||||
U64 cursor_off = params->cursor->column-1;
|
||||
DR_FancyStringNode *prev_n = 0;
|
||||
for(DR_FancyStringNode *n = code_fancy_strings.first; n != 0; n = n->next)
|
||||
{
|
||||
@@ -2768,28 +2768,28 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
ui_box_equip_display_fancy_strings(editstr_box, &code_fancy_strings);
|
||||
UI_LineEditDrawData *draw_data = push_array(ui_build_arena(), UI_LineEditDrawData, 1);
|
||||
draw_data->edited_string = push_str8_copy(ui_build_arena(), edit_string);
|
||||
draw_data->cursor = *cursor;
|
||||
draw_data->mark = *mark;
|
||||
draw_data->cursor = params->cursor[0];
|
||||
draw_data->mark = params->mark[0];
|
||||
ui_box_equip_custom_draw(editstr_box, ui_line_edit_draw, draw_data);
|
||||
mouse_pt = txt_pt(1, 1+ui_box_char_pos_from_xy(editstr_box, ui_mouse()));
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, params->cursor->column-1)).x;
|
||||
scratch_end(scratch);
|
||||
}
|
||||
else if((is_focus_active || is_focus_active_disabled) && !(flags & RD_LineEditFlag_CodeContents))
|
||||
else if((is_focus_active || is_focus_active_disabled) && !(params->flags & RD_LineEditFlag_CodeContents))
|
||||
{
|
||||
String8 edit_string = str8(edit_buffer, edit_string_size_out[0]);
|
||||
String8 edit_string = str8(params->edit_buffer, params->edit_string_size_out[0]);
|
||||
F32 total_text_width = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), edit_string).x;
|
||||
F32 total_editstr_width = total_text_width - !!(flags & (RD_LineEditFlag_Expander|RD_LineEditFlag_ExpanderSpace|RD_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
F32 total_editstr_width = total_text_width - !!(params->flags & (RD_LineEditFlag_Expander|RD_LineEditFlag_ExpanderSpace|RD_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
|
||||
ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f));
|
||||
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
|
||||
UI_LineEditDrawData *draw_data = push_array(ui_build_arena(), UI_LineEditDrawData, 1);
|
||||
draw_data->edited_string = push_str8_copy(ui_build_arena(), edit_string);
|
||||
draw_data->cursor = *cursor;
|
||||
draw_data->mark = *mark;
|
||||
draw_data->cursor = params->cursor[0];
|
||||
draw_data->mark = params->mark[0];
|
||||
ui_box_equip_display_string(editstr_box, edit_string);
|
||||
ui_box_equip_custom_draw(editstr_box, ui_line_edit_draw, draw_data);
|
||||
mouse_pt = txt_pt(1, 1+ui_box_char_pos_from_xy(editstr_box, ui_mouse()));
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, cursor->column-1)).x;
|
||||
cursor_off = fnt_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), str8_prefix(edit_string, params->cursor->column-1)).x;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2798,18 +2798,18 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
{
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
*mark = mouse_pt;
|
||||
params->mark[0] = mouse_pt;
|
||||
}
|
||||
*cursor = mouse_pt;
|
||||
params->cursor[0] = mouse_pt;
|
||||
}
|
||||
if(!is_focus_active && is_focus_active_disabled && ui_pressed(sig))
|
||||
{
|
||||
*cursor = *mark = mouse_pt;
|
||||
params->cursor[0] = params->mark[0] = mouse_pt;
|
||||
}
|
||||
|
||||
//- rjf: focus cursor
|
||||
{
|
||||
F32 visible_dim_px = dim_2f32(box->rect).x - expander_size_px - ui_top_font_size()*depth;
|
||||
F32 visible_dim_px = dim_2f32(box->rect).x - expander_size_px - ui_top_font_size()*params->depth;
|
||||
if(visible_dim_px > 0)
|
||||
{
|
||||
Rng1F32 cursor_range_px = r1f32(cursor_off-ui_top_font_size()*2.f, cursor_off+ui_top_font_size()*2.f);
|
||||
@@ -2838,14 +2838,14 @@ rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, Tx
|
||||
}
|
||||
|
||||
internal UI_Signal
|
||||
rd_line_editf(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size, U64 *edit_string_size_out, B32 *expanded_out, String8 pre_edit_value, char *fmt, ...)
|
||||
rd_line_editf(RD_LineEditParams *params, char *fmt, ...)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 string = push_str8fv(scratch.arena, fmt, args);
|
||||
va_end(args);
|
||||
UI_Signal sig = rd_line_edit(flags, depth, matches, cursor, mark, edit_buffer, edit_buffer_size, edit_string_size_out, expanded_out, pre_edit_value, string);
|
||||
UI_Signal sig = rd_line_edit(params, string);
|
||||
scratch_end(scratch);
|
||||
return sig;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,22 @@ enum
|
||||
RD_LineEditFlag_DisplayStringIsCode = (1<<9),
|
||||
};
|
||||
|
||||
typedef struct RD_LineEditParams RD_LineEditParams;
|
||||
struct RD_LineEditParams
|
||||
{
|
||||
RD_LineEditFlags flags;
|
||||
S32 depth;
|
||||
FuzzyMatchRangeList *fuzzy_matches;
|
||||
TxtPt *cursor;
|
||||
TxtPt *mark;
|
||||
U8 *edit_buffer;
|
||||
U64 edit_buffer_size;
|
||||
U64 *edit_string_size_out;
|
||||
B32 *expanded_out;
|
||||
String8 pre_edit_value;
|
||||
DR_FancyStringList fancy_strings;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Code Slice Types
|
||||
|
||||
@@ -114,7 +130,7 @@ internal UI_Box *rd_code_label(F32 alpha, B32 indirection_size_change, Vec4F32 b
|
||||
////////////////////////////////
|
||||
//~ rjf: UI Widgets: Line Edit
|
||||
|
||||
internal UI_Signal rd_line_edit(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size, U64 *edit_string_size_out, B32 *expanded_out, String8 pre_edit_value, String8 string);
|
||||
internal UI_Signal rd_line_editf(RD_LineEditFlags flags, S32 depth, FuzzyMatchRangeList *matches, TxtPt *cursor, TxtPt *mark, U8 *edit_buffer, U64 edit_buffer_size, U64 *edit_string_size_out, B32 *expanded_out, String8 pre_edit_value, char *fmt, ...);
|
||||
internal UI_Signal rd_line_edit(RD_LineEditParams *params, String8 string);
|
||||
internal UI_Signal rd_line_editf(RD_LineEditParams *params, char *fmt, ...);
|
||||
|
||||
#endif // RADDBG_WIDGETS_H
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include "rdi_make/rdi_make_local.h"
|
||||
#include "coff/coff.h"
|
||||
#include "codeview/codeview.h"
|
||||
#include "codeview/codeview_stringize.h"
|
||||
#include "codeview/codeview_parse.h"
|
||||
#include "codeview/codeview_enum.h"
|
||||
#include "msf/msf.h"
|
||||
#include "msf/msf_parse.h"
|
||||
#include "pdb/pdb.h"
|
||||
@@ -40,7 +41,8 @@
|
||||
#include "rdi_make/rdi_make_local.c"
|
||||
#include "coff/coff.c"
|
||||
#include "codeview/codeview.c"
|
||||
#include "codeview/codeview_stringize.c"
|
||||
#include "codeview/codeview_parse.c"
|
||||
#include "codeview/codeview_enum.c"
|
||||
#include "msf/msf.c"
|
||||
#include "msf/msf_parse.c"
|
||||
#include "pdb/pdb.c"
|
||||
|
||||
Reference in New Issue
Block a user