drag/drop work & cleanup; memory view work; pull initial project path (if not specified on command line) from user recent projects before forming a default path

This commit is contained in:
Ryan Fleury
2025-05-02 10:29:22 -07:00
parent a96546c5f5
commit 58b1aa41f6
6 changed files with 118 additions and 67 deletions
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -139,6 +139,7 @@ RD_CmdKind_MoveTabLeft,
RD_CmdKind_OpenTab,
RD_CmdKind_BuildTab,
RD_CmdKind_DuplicateTab,
RD_CmdKind_CopyTabFullPath,
RD_CmdKind_CloseTab,
RD_CmdKind_MoveView,
RD_CmdKind_TabBarTop,
@@ -688,8 +689,8 @@ Z(getting_started)\
C_LINKAGE_BEGIN
extern String8 rd_tab_fast_path_view_name_table[24];
extern String8 rd_tab_fast_path_query_name_table[24];
extern RD_VocabInfo rd_vocab_info_table[332];
extern RD_NameSchemaInfo rd_name_schema_info_table[23];
extern RD_VocabInfo rd_vocab_info_table[333];
extern RD_NameSchemaInfo rd_name_schema_info_table[24];
extern Rng1U64 rd_reg_slot_range_table[43];
extern String8 rd_binding_version_remap_old_name_table[8];
extern String8 rd_binding_version_remap_new_name_table[8];
+13 -2
View File
@@ -422,7 +422,7 @@ RD_VocabTable:
{
tab,
```
@row_commands(duplicate_tab, close_tab)
@row_commands(@file copy_tab_full_path, @file show_file_in_explorer, duplicate_tab, close_tab)
x:
{
@default(11) @display_name('Tab Font Size') @description("Controls the tab's font size.")
@@ -544,6 +544,16 @@ RD_VocabTable:
```
}
//- rjf: getting started
{
getting_started,
```
@inherit(tab) x:
{
}
```
}
//- rjf: targets
{
target,
@@ -833,6 +843,7 @@ RD_CmdTable: // | | | |
{OpenTab 1 1 0 0 "query:tab_commands" CmdName commands Nil Null 0 0 0 0 0 1 1 Null "open_tab" "Open New Tab" "Opens a new tab." "" "" }
{BuildTab 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Null "build_tab" "Build Tab" "Opens a new tab with the parameterized view specification." "" "" }
{DuplicateTab 1 1 0 0 "" Tab null Nil Null 0 0 0 0 0 0 0 Duplicate "duplicate_tab" "Duplicate Tab" "Duplicates a tab." "" "$tab," }
{CopyTabFullPath 0 0 0 0 "" Tab null Nil Null 0 0 0 0 0 0 0 Clipboard "copy_tab_full_path" "Copy Full Path" "Copies the full path of the file being viewed by this tab." "" "$tab," }
{CloseTab 1 1 0 0 "" Tab null Nil Null 0 0 0 0 0 0 0 X "close_tab" "Close Tab" "Closes the currently opened tab." "" "$tab," }
{MoveView 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 Null "move_view" "Move View" "Moves a view to a new panel." "" "" }
{TabBarTop 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 UpArrow "tab_bar_top" "Anchor Tab Bar To Top" "Anchors a panel's tab bar to the top of the panel." "" "$tab," }
@@ -845,7 +856,7 @@ RD_CmdTable: // | | | |
{Switch 1 1 0 0 "query:recent_files" Cfg null RecentFile Null 0 0 0 0 0 1 1 FileOutline "switch" "Switch" "Switches to a recent file." "code,source,file" "" }
{SwitchToPartnerFile 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "switch_to_partner_file" "Switch To Partner File" "Switches to the focused file's partner; or from header to implementation or vice versa." "code,source,file" "" }
{RecordFileInProject 0 0 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "record_file_in_project" "Record File In Project" "Records the passed file path as a recent file in the currently loaded project." "" "" }
{ShowFileInExplorer 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FileOutline "show_file_in_explorer" "Show File In Explorer" "Opens the operating system's file explorer and shows the selected file." "" "$file," }
{ShowFileInExplorer 1 1 0 0 "" Null null Nil Null 0 0 0 0 0 0 0 FolderClosedFilled "show_file_in_explorer" "Show File In Explorer" "Opens the operating system's file explorer and shows the selected file." "" "$file," }
//- rjf: source <-> disasm
{GoToDisassembly 1 1 1 0 "" Null null Nil Null 0 0 0 0 0 0 0 Glasses "go_to_disassembly" "Go To Disassembly" "Goes to the disassembly, if any, for a given source code line." "code,source,disassembly,disasm" "$text_pt," }
+35 -9
View File
@@ -8462,7 +8462,9 @@ rd_window_frame(void)
UI_Box *view_drop_site = &ui_nil_box;
{
RD_ViewUIRule *view_ui_rule = rd_view_ui_rule_from_string(selected_tab->string);
if(view_ui_rule != &rd_nil_view_ui_rule && rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_Expr)
if(view_ui_rule != &rd_nil_view_ui_rule && rd_drag_is_active() && rd_state->drag_drop_regs_slot == RD_RegSlot_Expr &&
!str8_match(selected_tab->string, str8_lit("text"), 0) &&
!str8_match(selected_tab->string, str8_lit("disasm"), 0))
{
UI_FixedSize(dim_2f32(content_rect))
view_drop_site = ui_build_box_from_stringf(UI_BoxFlag_DropSite|UI_BoxFlag_Floating, "drop_site_%I64x", selected_tab->id);
@@ -8513,7 +8515,7 @@ rd_window_frame(void)
UI_Signal sig = ui_signal_from_box(view_drop_site);
if(ui_key_match(view_drop_site->key, ui_drop_hot_key()))
{
UI_Parent(view_drop_site) UI_WidthFill UI_HeightFill UI_TagF("drop_site") UI_Transparency(0.5f)
UI_Parent(view_drop_site) UI_WidthFill UI_HeightFill UI_TagF("drop_site")
{
ui_build_box_from_key(UI_BoxFlag_DrawBackground|UI_BoxFlag_DrawBorder, ui_key_zero());
}
@@ -10396,15 +10398,14 @@ rd_init(CmdLine *cmdln)
{
user_path = push_str8f(scratch.arena, "%S/default.raddbg_user", user_data_folder);
}
if(project_path.size == 0)
{
project_path = push_str8f(scratch.arena, "%S/default.raddbg_project", user_data_folder);
}
}
// rjf: do initial load
rd_cmd(RD_CmdKind_OpenUser, .file_path = user_path);
rd_cmd(RD_CmdKind_OpenProject, .file_path = project_path);
// rjf: do initial load of user (project will be loaded by the initial user load if not specified)
rd_cmd(RD_CmdKind_OpenUser, .file_path = user_path);
if(project_path.size != 0)
{
rd_cmd(RD_CmdKind_OpenProject, .file_path = project_path);
}
scratch_end(scratch);
}
@@ -12483,6 +12484,24 @@ rd_frame(void)
}
}
//- rjf: if we've just loaded the user, and we do not have a project path,
// then we should try to look at the user's data for recent projects and
// load one of those, *or* just the default.
if(file_is_okay && kind == RD_CmdKind_OpenUser && rd_state->project_path.size == 0)
{
RD_Cfg *user = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"));
RD_Cfg *recent_project = rd_cfg_child_from_string(user, str8_lit("recent_project"));
String8 project_path = rd_path_from_cfg(recent_project);
if(project_path.size == 0)
{
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
String8 user_data_folder = push_str8f(scratch.arena, "%S/%S", user_program_data_path, str8_lit("raddbg"));
os_make_directory(user_data_folder);
project_path = push_str8f(scratch.arena, "%S/default.raddbg_project", user_data_folder);
}
rd_cmd(RD_CmdKind_OpenProject, .file_path = project_path);
}
//- rjf: update all window titles
if(file_is_okay)
{
@@ -13219,6 +13238,13 @@ rd_frame(void)
rd_cfg_insert_child(src->parent, src, dst);
rd_cmd(RD_CmdKind_FocusTab, .tab = dst->id);
}break;
case RD_CmdKind_CopyTabFullPath:
{
RD_Cfg *tab = rd_cfg_from_id(rd_regs()->tab);
String8 expr = rd_expr_from_cfg(tab);
String8 full_path = rd_file_path_from_eval_string(scratch.arena, expr);
os_set_clipboard_text(full_path);
}break;
case RD_CmdKind_CloseTab:
{
RD_Cfg *tab = rd_cfg_from_id(rd_regs()->tab);
+5
View File
@@ -1197,6 +1197,11 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
MD_Node *cmds_root = md_tag_from_string(schema, str8_lit("row_commands"), 0);
for MD_EachNode(cmd, cmds_root->first)
{
B32 is_file_only = md_node_has_tag(cmd, str8_lit("file"), 0);
if(is_file_only && e_eval_from_string(rd_expr_from_cfg(evalled_cfg)).space.kind != E_SpaceKind_File)
{
continue;
}
String8 cmd_name = cmd->string;
RD_CmdKind cmd_kind = rd_cmd_kind_from_string(cmd_name);
switch(cmd_kind)
+54 -49
View File
@@ -1261,6 +1261,52 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
}
}
//////////////////////////////
//- rjf: dragging cfgs/entities/expressions? -> drop site
//
B32 drop_can_hit_lines = 0;
RD_Cfg *drop_cfg = &rd_nil_cfg;
CTRL_Entity *drop_thread = &ctrl_entity_nil;
String8 drop_expr = {0};
Vec4F32 drop_color = pop_color;
UI_Key drop_site_key = ui_key_from_stringf(top_container_box->key, "drop_site");
if(rd_drag_is_active())
{
RD_Cfg *cfg = rd_cfg_from_id(rd_state->drag_drop_regs->cfg);
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Cfg &&
(str8_match(cfg->string, str8_lit("breakpoint"), 0) ||
str8_match(cfg->string, str8_lit("watch_pin"), 0)))
{
drop_can_hit_lines = 1;
drop_cfg = cfg;
drop_color = linear_from_srgba(rd_color_from_cfg(cfg));
if(drop_color.w == 0)
{
drop_color = pop_color;
}
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread)
{
drop_can_hit_lines = 1;
drop_thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_state->drag_drop_regs->thread);
drop_color = rd_color_from_ctrl_entity(drop_thread);
if(drop_color.w == 0)
{
drop_color = pop_color;
}
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Expr)
{
drop_can_hit_lines = 1;
drop_expr = rd_state->drag_drop_regs->expr;
}
if(drop_can_hit_lines) UI_WidthFill UI_HeightFill
{
UI_Box *drop_site_box = ui_build_box_from_key(UI_BoxFlag_DropSite|UI_BoxFlag_Floating, drop_site_key);
ui_signal_from_box(drop_site_box);
}
}
//////////////////////////////
//- rjf: build per-line background colors
//
@@ -2102,10 +2148,6 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
UI_Signal priority_margin_container_sig = ui_signal_from_box(priority_margin_container_box);
UI_Signal catchall_margin_container_sig = ui_signal_from_box(catchall_margin_container_box);
UI_Signal text_container_sig = ui_signal_from_box(text_container_box);
B32 line_drag_drop = 0;
RD_Cfg *line_drag_cfg = &rd_nil_cfg;
CTRL_Entity *line_drag_ctrl_entity = &ctrl_entity_nil;
Vec4F32 line_drag_drop_color = pop_color;
{
//- rjf: determine mouse drag range
TxtRng mouse_drag_rng = txt_rng(mouse_pt, mouse_pt);
@@ -2181,46 +2223,10 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
.lines = lines);
}
//- rjf: dragging threads, breakpoints, or watch pins over this slice ->
// drop target
if(rd_drag_is_active() && contains_2f32(clipped_top_container_rect, ui_mouse()))
{
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_state->drag_drop_regs->thread);
RD_Cfg *cfg = rd_cfg_from_id(rd_state->drag_drop_regs->cfg);
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Cfg &&
(str8_match(cfg->string, str8_lit("breakpoint"), 0) ||
str8_match(cfg->string, str8_lit("watch_pin"), 0)))
{
line_drag_drop = 1;
line_drag_cfg = cfg;
line_drag_drop_color = linear_from_srgba(rd_color_from_cfg(cfg));
if(line_drag_drop_color.w == 0)
{
line_drag_drop_color = pop_color;
}
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Expr)
{
line_drag_drop = 1;
line_drag_cfg = cfg;
line_drag_drop_color = pop_color;
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread)
{
line_drag_drop = 1;
line_drag_ctrl_entity = thread;
line_drag_drop_color = rd_color_from_ctrl_entity(thread);
if(line_drag_drop_color.w == 0)
{
line_drag_drop_color = pop_color;
}
}
}
//- rjf: drop target is dropped -> process
if(contains_1s64(params->line_num_range, mouse_pt.line) && contains_2f32(clipped_top_container_rect, ui_mouse()))
if(drop_can_hit_lines && ui_key_match(ui_drop_hot_key(), drop_site_key) && rd_drag_drop())
{
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Expr && rd_drag_drop())
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Expr)
{
S64 line_num = mouse_pt.line;
U64 line_idx = line_num - params->line_num_range.min;
@@ -2231,24 +2237,23 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
.cursor = line_vaddr == 0 ? txt_pt(line_num, 1) : txt_pt(0, 0),
.vaddr = line_vaddr);
}
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Cfg && line_drag_cfg != &rd_nil_cfg && rd_drag_drop())
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Cfg && drop_cfg != &rd_nil_cfg)
{
RD_Cfg *dropped_cfg = line_drag_cfg;
S64 line_num = mouse_pt.line;
U64 line_idx = line_num - params->line_num_range.min;
U64 line_vaddr = params->line_vaddrs[line_idx];
rd_cmd(RD_CmdKind_RelocateCfg,
.cfg = dropped_cfg->id,
.cfg = drop_cfg->id,
.file_path = line_vaddr == 0 ? rd_regs()->file_path : str8_zero(),
.cursor = line_vaddr == 0 ? txt_pt(line_num, 1) : txt_pt(0, 0),
.vaddr = line_vaddr);
}
if(line_drag_ctrl_entity != &ctrl_entity_nil && rd_drag_drop())
if(drop_thread != &ctrl_entity_nil)
{
S64 line_num = mouse_pt.line;
U64 line_idx = line_num - params->line_num_range.min;
U64 line_vaddr = params->line_vaddrs[line_idx];
CTRL_Entity *thread = line_drag_ctrl_entity;
CTRL_Entity *thread = drop_thread;
U64 new_rip_vaddr = line_vaddr;
if(params->line_vaddrs[line_idx] == 0)
{
@@ -2355,12 +2360,12 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
//////////////////////////////
//- rjf: dragging/dropping which applies to lines over this slice -> visualize
//
if(line_drag_drop && contains_2f32(clipped_top_container_rect, ui_mouse()))
if(drop_can_hit_lines && ui_key_match(drop_site_key, ui_drop_hot_key()))
{
DR_Bucket *bucket = dr_bucket_make();
DR_BucketScope(bucket)
{
Vec4F32 color = line_drag_drop_color;
Vec4F32 color = drop_color;
color.w *= 0.2f;
Rng2F32 drop_line_rect = r2f32p(top_container_box->rect.x0,
top_container_box->rect.y0 + (mouse_pt.line - params->line_num_range.min) * params->line_height_px,