mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 13:28:40 +00:00
f1 lister completion; improve command listing
This commit is contained in:
@@ -2960,7 +2960,10 @@ rd_view_ui(Rng2F32 rect)
|
|||||||
{
|
{
|
||||||
taken = 1;
|
taken = 1;
|
||||||
E_Eval eval = row->eval;
|
E_Eval eval = row->eval;
|
||||||
switch(eval.space.kind)
|
|
||||||
|
// rjf: if we have a specific command we are trying to complete, then
|
||||||
|
// fill registers based on this row's evaluation.
|
||||||
|
if(cmd_name.size != 0) switch(eval.space.kind)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -2993,6 +2996,67 @@ rd_view_ui(Rng2F32 rect)
|
|||||||
rd_cmd(RD_CmdKind_CompleteQuery, .pid = pid);
|
rd_cmd(RD_CmdKind_CompleteQuery, .pid = pid);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rjf: if we do not have a specific command, then we can just
|
||||||
|
// pick a sensible default based on what was selected.
|
||||||
|
if(cmd_name.size == 0)
|
||||||
|
{
|
||||||
|
B32 did_cmd = 1;
|
||||||
|
switch(eval.space.kind)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
String8 symbol_name = d_symbol_name_from_process_vaddr(scratch.arena, ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_regs()->process), eval.value.u64, 0, 0);
|
||||||
|
if(symbol_name.size != 0)
|
||||||
|
{
|
||||||
|
rd_cmd(RD_CmdKind_GoToName, .string = symbol_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
did_cmd = 0;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case E_SpaceKind_File:
|
||||||
|
case E_SpaceKind_FileSystem:
|
||||||
|
{
|
||||||
|
String8 file = rd_file_path_from_eval(scratch.arena, eval);
|
||||||
|
rd_cmd(RD_CmdKind_FindCodeLocation, .file_path = file, .vaddr = 0);
|
||||||
|
}break;
|
||||||
|
case RD_EvalSpaceKind_MetaCfg:
|
||||||
|
{
|
||||||
|
RD_Cfg *cfg = rd_cfg_from_eval_space(eval.space);
|
||||||
|
if(str8_match(cfg->string, str8_lit("recent_file"), 0))
|
||||||
|
{
|
||||||
|
rd_cmd(RD_CmdKind_Switch, .cfg = cfg->id);
|
||||||
|
}
|
||||||
|
else if(str8_match(cfg->string, str8_lit("recent_project"), 0))
|
||||||
|
{
|
||||||
|
rd_cmd(RD_CmdKind_OpenRecentProject, .cfg = cfg->id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
did_cmd = 0;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case RD_EvalSpaceKind_MetaUnattachedProcess:
|
||||||
|
{
|
||||||
|
U64 pid = eval.value.u128.u64[0];
|
||||||
|
}break;
|
||||||
|
case RD_EvalSpaceKind_MetaCmd:
|
||||||
|
{
|
||||||
|
String8 cmd_name = rd_cmd_name_from_eval(eval);
|
||||||
|
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = cmd_name);
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
if(did_cmd)
|
||||||
|
{
|
||||||
|
rd_cmd(RD_CmdKind_CompleteQuery);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
taken = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14760,9 +14824,11 @@ Z(getting_started)
|
|||||||
}break;
|
}break;
|
||||||
case RD_CmdKind_CompleteQuery:
|
case RD_CmdKind_CompleteQuery:
|
||||||
{
|
{
|
||||||
|
// rjf: unpack params
|
||||||
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
|
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
|
||||||
String8 cmd_name = rd_view_query_cmd();
|
String8 cmd_name = rd_view_query_cmd();
|
||||||
RD_CmdKindInfo *cmd_kind_info = rd_cmd_kind_info_from_string(cmd_name);
|
|
||||||
|
// rjf: push command
|
||||||
if(cmd_name.size != 0) RD_RegsScope()
|
if(cmd_name.size != 0) RD_RegsScope()
|
||||||
{
|
{
|
||||||
rd_push_cmd(cmd_name, rd_regs());
|
rd_push_cmd(cmd_name, rd_regs());
|
||||||
@@ -14771,7 +14837,9 @@ Z(getting_started)
|
|||||||
// rjf: find out if this view is a lister
|
// rjf: find out if this view is a lister
|
||||||
B32 is_lister = (rd_cfg_child_from_string(view, str8_lit("lister")) != &rd_nil_cfg);
|
B32 is_lister = (rd_cfg_child_from_string(view, str8_lit("lister")) != &rd_nil_cfg);
|
||||||
|
|
||||||
// rjf: complete query
|
// rjf: complete query, either by closing the query popup, or closing the
|
||||||
|
// tab-embedded query edit
|
||||||
|
RD_CmdKindInfo *cmd_kind_info = rd_cmd_kind_info_from_string(cmd_name);
|
||||||
if(is_lister)
|
if(is_lister)
|
||||||
{
|
{
|
||||||
RD_Cfg *window = rd_cfg_from_id(rd_regs()->window);
|
RD_Cfg *window = rd_cfg_from_id(rd_regs()->window);
|
||||||
|
|||||||
+36
-54
@@ -4,36 +4,6 @@
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: `commands` Type Hooks
|
//~ rjf: `commands` Type Hooks
|
||||||
|
|
||||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(commands)
|
|
||||||
{
|
|
||||||
E_TypeExpandInfo result = {0};
|
|
||||||
if(filter.size != 0)
|
|
||||||
{
|
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
|
||||||
String8List cmd_names = {0};
|
|
||||||
for EachNonZeroEnumVal(RD_CmdKind, k)
|
|
||||||
{
|
|
||||||
RD_CmdKindInfo *info = &rd_cmd_kind_info_table[k];
|
|
||||||
String8 name = info->string;
|
|
||||||
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, name);
|
|
||||||
if(matches.count == matches.needle_part_count)
|
|
||||||
{
|
|
||||||
str8_list_push(scratch.arena, &cmd_names, name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String8Array *accel = push_array(arena, String8Array, 1);
|
|
||||||
*accel = str8_array_from_list(arena, &cmd_names);
|
|
||||||
result.user_data = accel;
|
|
||||||
result.expr_count = accel->count;
|
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.expr_count = RD_CmdKind_COUNT - 1;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
E_TYPE_ACCESS_FUNCTION_DEF(commands)
|
E_TYPE_ACCESS_FUNCTION_DEF(commands)
|
||||||
{
|
{
|
||||||
E_IRTreeAndType result = {&e_irnode_nil};
|
E_IRTreeAndType result = {&e_irnode_nil};
|
||||||
@@ -47,34 +17,46 @@ E_TYPE_ACCESS_FUNCTION_DEF(commands)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
E_TYPE_EXPAND_INFO_FUNCTION_DEF(commands)
|
||||||
|
{
|
||||||
|
E_TypeExpandInfo result = {0};
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
String8List cmd_names = {0};
|
||||||
|
for EachNonZeroEnumVal(RD_CmdKind, k)
|
||||||
|
{
|
||||||
|
RD_CmdKindInfo *info = &rd_cmd_kind_info_table[k];
|
||||||
|
if(info->flags & RD_CmdKindFlag_ListInUI)
|
||||||
|
{
|
||||||
|
String8 name = info->string;
|
||||||
|
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, name);
|
||||||
|
if(matches.count == matches.needle_part_count)
|
||||||
|
{
|
||||||
|
str8_list_push(scratch.arena, &cmd_names, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String8Array *accel = push_array(arena, String8Array, 1);
|
||||||
|
*accel = str8_array_from_list(arena, &cmd_names);
|
||||||
|
result.user_data = accel;
|
||||||
|
result.expr_count = accel->count;
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(commands)
|
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(commands)
|
||||||
{
|
{
|
||||||
U64 out_idx = 0;
|
U64 out_idx = 0;
|
||||||
if(user_data != 0)
|
String8Array *accel = (String8Array *)user_data;
|
||||||
|
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
|
||||||
{
|
{
|
||||||
String8Array *accel = (String8Array *)user_data;
|
String8 cmd_name = accel->v[idx];
|
||||||
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
|
E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
|
||||||
{
|
expr->type_key = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
|
||||||
String8 cmd_name = accel->v[idx];
|
expr->space = e_space_make(RD_EvalSpaceKind_MetaCmd);
|
||||||
E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
|
expr->value.u64 = e_id_from_string(cmd_name);
|
||||||
expr->type_key = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
|
exprs_out[out_idx] = expr;
|
||||||
expr->space = e_space_make(RD_EvalSpaceKind_MetaCmd);
|
|
||||||
expr->value.u64 = e_id_from_string(cmd_name);
|
|
||||||
exprs_out[out_idx] = expr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
|
|
||||||
{
|
|
||||||
RD_CmdKind cmd_kind = (RD_CmdKind)(idx+1);
|
|
||||||
String8 cmd_name = rd_cmd_kind_info_table[cmd_kind].string;
|
|
||||||
E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
|
|
||||||
expr->type_key = e_type_key_cons(.kind = E_TypeKind_U64, .name = str8_lit("command"));
|
|
||||||
expr->space = e_space_make(RD_EvalSpaceKind_MetaCmd);
|
|
||||||
expr->value.u64 = e_id_from_string(cmd_name);
|
|
||||||
exprs_out[out_idx] = expr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user