@@ -5747,75 +5747,73 @@ rd_window_frame(void)
57475747 ////////////////////////////
57485748 //- rjf: @window_ui_part drop-completion context menu
57495749 //
5750- if(ws->drop_completion_paths.node_count != 0)
5750+ if(ws->top_drop_completion_task != 0)
57515751 {
5752+ RD_DropCompletionTask *task = ws->top_drop_completion_task;
5753+ B32 done = 0;
57525754 UI_CtxMenu(rd_state->drop_completion_key) UI_PrefWidth(ui_em(40.f, 1.f)) UI_TagF("implicit")
57535755 {
5754- UI_TagF("weak")
5755- for(String8Node *n = ws->drop_completion_paths.first; n != 0; n = n->next )
5756+ // rjf: file names
5757+ UI_TagF("weak") UI_Row UI_Padding(ui_em(1.25f, 1.f) )
57565758 {
5757- UI_Row UI_Padding(ui_em(1.f, 1.f))
5759+ String8List strings = {0};
5760+ U64 idx = 0;
5761+ for(String8Node *n = task->paths.first; n != 0 && idx < 20; n = n->next, idx += 1)
57585762 {
5759- UI_PrefWidth(ui_em(2.f, 1.f)) RD_Font(RD_FontSlot_Icons) ui_label(rd_icon_kind_text_table[RD_IconKind_FileOutline]);
5760- UI_PrefWidth(ui_text_dim(10, 1)) ui_label(n->string);
5763+ str8_list_push(scratch.arena, &strings, str8_skip_last_slash(n->string));
5764+ if(idx+1 == 20)
5765+ {
5766+ str8_list_push(scratch.arena, &strings, str8_lit("..."));
5767+ }
57615768 }
5769+ StringJoin join = {.sep = str8_lit(", ")};
5770+ String8 string = str8_list_join(scratch.arena, &strings, &join);
5771+ UI_PrefWidth(ui_pct(1, 0)) ui_label(string);
57625772 }
5763- ui_divider(ui_em(1.f, 1.f));
5764- if(ui_clicked(rd_icon_buttonf(RD_IconKind_Target, 0, "Add File%s As Target%s",
5765- (ws->drop_completion_paths.node_count > 1) ? "s" : "",
5766- (ws->drop_completion_paths.node_count > 1) ? "s" : "")))
5767- {
5768- for(String8Node *n = ws->drop_completion_paths.first; n != 0; n = n->next)
5769- {
5770- rd_cmd(RD_CmdKind_AddTarget, .file_path = n->string);
5771- }
5772- ui_ctx_menu_close();
5773- }
5774- if(ws->drop_completion_paths.node_count == 1)
5773+
5774+ // rjf: option to add EXEs as targets
5775+ if(task->exe)
57755776 {
5776- if(ui_clicked(rd_icon_buttonf(RD_IconKind_Play, 0, "Add File%s As Target%s And Run",
5777- (ws->drop_completion_paths.node_count > 1) ? "s" : "",
5778- (ws->drop_completion_paths.node_count > 1) ? "s" : "")))
5777+ if(ui_clicked(rd_icon_buttonf(RD_IconKind_Target, 0, "Add as target%s", (task->paths.node_count > 1) ? "s" : "")))
57795778 {
5780- for(String8Node *n = ws->drop_completion_paths .first; n != 0; n = n->next)
5779+ for(String8Node *n = task->paths .first; n != 0; n = n->next)
57815780 {
57825781 rd_cmd(RD_CmdKind_AddTarget, .file_path = n->string);
57835782 }
5784- CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
5785- if(processes.count != 0)
5786- {
5787- rd_cmd(RD_CmdKind_KillAll);
5788- }
5789- rd_cmd(RD_CmdKind_Run);
5790- ui_ctx_menu_close();
5783+ done = 1;
57915784 }
57925785 }
5793- if(ws->drop_completion_paths.node_count == 1)
5786+
5787+ // rjf: option to load files as debug info
5788+ if(task->dbg)
57945789 {
5795- if(ui_clicked(rd_icon_buttonf(RD_IconKind_StepInto, 0, "Add File%s As Target%s And Step Into",
5796- (ws->drop_completion_paths.node_count > 1) ? "s" : "",
5797- (ws->drop_completion_paths.node_count > 1) ? "s" : "")))
5790+ if(ui_clicked(rd_icon_buttonf(RD_IconKind_Module, 0, "Load as debug info")))
57985791 {
5799- for(String8Node *n = ws->drop_completion_paths.first; n != 0; n = n->next)
5800- {
5801- rd_cmd(RD_CmdKind_AddTarget, .file_path = n->string);
5802- }
5803- CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
5804- if(processes.count != 0)
5792+ for(String8Node *n = task->paths.first; n != 0; n = n->next)
58055793 {
5806- rd_cmd(RD_CmdKind_KillAll );
5794+ rd_cmd(RD_CmdKind_LoadDebugInfo, .file_path = n->string );
58075795 }
5808- rd_cmd(RD_CmdKind_StepInto);
5809- ui_ctx_menu_close();
5796+ done = 1;
58105797 }
58115798 }
5812- if(ui_clicked(rd_icon_buttonf(RD_IconKind_Target, 0, "View File%s",
5813- (ws->drop_completion_paths.node_count > 1) ? "s" : "")))
5799+
5800+ // rjf: option to just open & view the file contents
5801+ if(ui_clicked(rd_icon_buttonf(RD_IconKind_FileOutline, 0, "View file%s contents", (task->paths.node_count > 1) ? "s'" : "")))
58145802 {
5815- for(String8Node *n = ws->drop_completion_paths .first; n != 0; n = n->next)
5803+ for(String8Node *n = task->paths .first; n != 0; n = n->next)
58165804 {
58175805 rd_cmd(RD_CmdKind_Open, .file_path = n->string);
58185806 }
5807+ done = 1;
5808+ }
5809+ }
5810+
5811+ // rjf: pop task, close context menu if needed, when done
5812+ if(done)
5813+ {
5814+ SLLStackPop(ws->top_drop_completion_task);
5815+ if(ws->top_drop_completion_task == 0)
5816+ {
58195817 ui_ctx_menu_close();
58205818 }
58215819 }
@@ -8349,23 +8347,45 @@ rd_window_frame(void)
83498347 {
83508348 B32 need_drop_completion = 0;
83518349 arena_clear(ws->drop_completion_arena);
8352- MemoryZeroStruct(&ws->drop_completion_paths);
8350+ ws->top_drop_completion_task = 0;
8351+ ws->drop_completion_panel = panel->cfg->id;
8352+ String8List exe_paths = {0};
8353+ String8List dbg_paths = {0};
83538354 for(String8Node *n = evt->paths.first; n != 0; n = n->next)
83548355 {
83558356 Temp scratch = scratch_begin(0, 0);
83568357 String8 path = n->string;
8357- if(str8_match(str8_skip_last_dot(path), str8_lit("exe"), StringMatchFlag_CaseInsensitive))
8358+ String8 ext = str8_skip_last_dot(path);
8359+ if(str8_match(ext, str8_lit("exe"), StringMatchFlag_CaseInsensitive))
8360+ {
8361+ str8_list_push(ws->drop_completion_arena, &exe_paths, str8_copy(ws->drop_completion_arena, path));
8362+ }
8363+ else if(str8_match(ext, str8_lit("pdb"), StringMatchFlag_CaseInsensitive) ||
8364+ str8_match(ext, str8_lit("rdi"), StringMatchFlag_CaseInsensitive))
83588365 {
8359- str8_list_push(ws->drop_completion_arena, &ws->drop_completion_paths, push_str8_copy(ws->drop_completion_arena, path));
8360- need_drop_completion = 1;
8366+ str8_list_push(ws->drop_completion_arena, &dbg_paths, str8_copy(ws->drop_completion_arena, path));
83618367 }
83628368 else
83638369 {
8364- rd_cmd(RD_CmdKind_Open, .file_path = path);
8370+ rd_cmd(RD_CmdKind_Open, .file_path = path, .panel = panel->cfg->id );
83658371 }
83668372 scratch_end(scratch);
83678373 }
8368- if(need_drop_completion)
8374+ if(dbg_paths.node_count != 0)
8375+ {
8376+ RD_DropCompletionTask *t = push_array(ws->drop_completion_arena, RD_DropCompletionTask, 1);
8377+ SLLStackPush(ws->top_drop_completion_task, t);
8378+ t->dbg = 1;
8379+ t->paths = dbg_paths;
8380+ }
8381+ if(exe_paths.node_count != 0)
8382+ {
8383+ RD_DropCompletionTask *t = push_array(ws->drop_completion_arena, RD_DropCompletionTask, 1);
8384+ SLLStackPush(ws->top_drop_completion_task, t);
8385+ t->exe = 1;
8386+ t->paths = exe_paths;
8387+ }
8388+ if(ws->top_drop_completion_task != 0)
83698389 {
83708390 ui_ctx_menu_open(rd_state->drop_completion_key, ui_key_zero(), evt->pos);
83718391 }
0 commit comments