browse button cell extension for cfg file path evaluations - route to 'pick file' command, fast-path for using query uis to inserting a path textually

This commit is contained in:
Ryan Fleury committed 2026-08-25 17:31:33 -07:00
1 parent e28a543573
commit fb06485b87
8 files changed
+115 -25

No files matched your search

+1 -1
View File
@@ -7,7 +7,6 @@ target:
working_directory: build
arguments: "--user:raddbg_test.user"
debug_subprocesses: 0
enabled: 1
}
target:
{
@@ -19,6 +18,7 @@ target:
executable: "build/mule_main.exe"
working_directory: build
output_label: output_a
enabled: 1
}
target:
{
+6 -8
View File
@@ -62,7 +62,7 @@ str8_lit_comp(""),
str8_lit_comp(""),
};
RD_VocabInfo rd_vocab_info_table[372] =
RD_VocabInfo rd_vocab_info_table[371] =
{
{str8_lit_comp("type_view"), str8_lit_comp("type_views"), str8_lit_comp("Type View"), str8_lit_comp("Type Views"), RD_IconKind_Binoculars},
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
@@ -400,9 +400,8 @@ RD_VocabInfo rd_vocab_info_table[372] =
{str8_lit_comp("break_when_value_changes"), str8_lit_comp(""), str8_lit_comp("Break When Value Changes"), str8_lit_comp(""), RD_IconKind_CircleFilled},
{str8_lit_comp("search"), str8_lit_comp(""), str8_lit_comp("Search"), str8_lit_comp(""), RD_IconKind_Find},
{str8_lit_comp("search_backwards"), str8_lit_comp(""), str8_lit_comp("Search Backwards"), str8_lit_comp(""), RD_IconKind_Find},
{str8_lit_comp("pick_file"), str8_lit_comp(""), str8_lit_comp("Pick File"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("pick_folder"), str8_lit_comp(""), str8_lit_comp("Pick Folder"), str8_lit_comp(""), RD_IconKind_FolderOpenFilled},
{str8_lit_comp("pick_file_or_folder"), str8_lit_comp(""), str8_lit_comp("Pick File/Folder"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("pick_file_replacement"), str8_lit_comp(""), str8_lit_comp("Pick File Replacement"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("pick_file_path"), str8_lit_comp(""), str8_lit_comp("Pick File Path"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("push_query"), str8_lit_comp(""), str8_lit_comp("Push Query"), str8_lit_comp(""), RD_IconKind_Null},
{str8_lit_comp("complete_query"), str8_lit_comp(""), str8_lit_comp("Complete Query"), str8_lit_comp(""), RD_IconKind_Null},
{str8_lit_comp("cancel_query"), str8_lit_comp(""), str8_lit_comp("Cancel Query"), str8_lit_comp(""), RD_IconKind_Null},
@@ -599,7 +598,7 @@ Rng1U64 rd_reg_slot_range_table[55] =
{OffsetOf(RD_Regs, wm_event), OffsetOf(RD_Regs, wm_event) + sizeof(WM_Event *)},
};
RD_CmdKindInfo rd_cmd_kind_info_table[259] =
RD_CmdKindInfo rd_cmd_kind_info_table[258] =
{
{0},
{ str8_lit_comp("launch_and_run"), str8_lit_comp("Starts debugging a new instance of a target, then runs."), str8_lit_comp("launch,start,run,target"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_Cfg, str8_lit_comp("query:targets")}},
@@ -824,9 +823,8 @@ RD_CmdKindInfo rd_cmd_kind_info_table[259] =
{ str8_lit_comp("break_when_value_changes"), str8_lit_comp("Adds a new write data breakpoint for this variable's range."), str8_lit_comp(""), str8_lit_comp("{memory_eval_commands}"), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*0), RD_RegSlot_Expr, str8_lit_comp("")}},
{ str8_lit_comp("search"), str8_lit_comp("Begins searching within the active interface."), str8_lit_comp("sort,search,filter,find"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*1)|(RD_QueryFlag_SelectOldInput*1)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*1), RD_RegSlot_String, str8_lit_comp("")}},
{ str8_lit_comp("search_backwards"), str8_lit_comp("Begins searching backwards within the active interface."), str8_lit_comp("sort,search,filter,find"), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*1), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*1)|(RD_QueryFlag_KeepOldInput*1)|(RD_QueryFlag_SelectOldInput*1)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*1), RD_RegSlot_String, str8_lit_comp("")}},
{ str8_lit_comp("pick_file"), str8_lit_comp("Opens the file browser to pick a file."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*1)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\"")}},
{ str8_lit_comp("pick_folder"), str8_lit_comp("Opens the file browser to pick a folder."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*1)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\"")}},
{ str8_lit_comp("pick_file_or_folder"), str8_lit_comp("Opens the file browser to pick a file or folder."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*1)|(RD_QueryFlag_AllowFolders*1)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\"")}},
{ str8_lit_comp("pick_file_replacement"), str8_lit_comp("Opens the file browser to pick a file replacement for a missing source file."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*1)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\"")}},
{ str8_lit_comp("pick_file_path"), str8_lit_comp("Opens the file browser to pick a file, then inserts that file's path as text."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*1)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*1)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*1)|(RD_QueryFlag_Required*1), RD_RegSlot_FilePath, str8_lit_comp("folder:\"$input\"")}},
{ str8_lit_comp("push_query"), str8_lit_comp("Opens a new temporary query interface."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp("")}},
{ str8_lit_comp("complete_query"), str8_lit_comp("Completes and closes a query."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp("")}},
{ str8_lit_comp("cancel_query"), str8_lit_comp("Closes a query."), str8_lit_comp(""), str8_lit_comp(""), (RD_CmdKindFlag_ListInUI*0)|(RD_CmdKindFlag_ListInIPCDocs*0), {(RD_QueryFlag_AllowFiles*0)|(RD_QueryFlag_AllowFolders*0)|(RD_QueryFlag_CodeInput*0)|(RD_QueryFlag_KeepOldInput*0)|(RD_QueryFlag_SelectOldInput*0)|(RD_QueryFlag_Floating*0)|(RD_QueryFlag_Required*0), RD_RegSlot_Null, str8_lit_comp("")}},
+3 -4
View File
@@ -291,9 +291,8 @@ RD_CmdKind_GoToMemory,
RD_CmdKind_BreakWhenValueChanges,
RD_CmdKind_Search,
RD_CmdKind_SearchBackwards,
RD_CmdKind_PickFile,
RD_CmdKind_PickFolder,
RD_CmdKind_PickFileOrFolder,
RD_CmdKind_PickFileReplacement,
RD_CmdKind_PickFilePath,
RD_CmdKind_PushQuery,
RD_CmdKind_CompleteQuery,
RD_CmdKind_CancelQuery,
@@ -629,7 +628,7 @@ Z(getting_started)\
C_LINKAGE_BEGIN
extern String8 rd_tab_fast_path_view_name_table[25];
extern String8 rd_tab_fast_path_query_name_table[25];
extern RD_VocabInfo rd_vocab_info_table[372];
extern RD_VocabInfo rd_vocab_info_table[371];
extern RD_NameSchemaInfo rd_name_schema_info_table[39];
extern String8 rd_reg_slot_code_name_table[55];
extern Rng1U64 rd_reg_slot_range_table[55];
+2 -3
View File
@@ -1235,9 +1235,8 @@ RD_CmdTable: // | | | |
{SearchBackwards 0 1 1 "" String 0 0 1 1 1 0 1 Find "search_backwards" "Search Backwards" "Begins searching backwards within the active interface." "sort,search,filter,find" "" }
//- rjf: queries
{PickFile 0 0 0 `folder:\\"$input\\"` FilePath 1 0 0 0 0 1 1 FileOutline "pick_file" "Pick File" "Opens the file browser to pick a file." "" "" }
{PickFolder 0 0 0 `folder:\\"$input\\"` FilePath 0 1 0 0 0 1 1 FolderOpenFilled "pick_folder" "Pick Folder" "Opens the file browser to pick a folder." "" "" }
{PickFileOrFolder 0 0 0 `folder:\\"$input\\"` FilePath 1 1 0 0 0 1 1 FileOutline "pick_file_or_folder" "Pick File/Folder" "Opens the file browser to pick a file or folder." "" "" }
{PickFileReplacement 0 0 0 `folder:\\"$input\\"` FilePath 1 0 0 0 0 1 1 FileOutline "pick_file_replacement" "Pick File Replacement" "Opens the file browser to pick a file replacement for a missing source file." "" "" }
{PickFilePath 0 1 0 `folder:\\"$input\\"` FilePath 1 0 0 0 0 1 1 FileOutline "pick_file_path" "Pick File Path" "Opens the file browser to pick a file, then inserts that file's path as text." "" "" }
//- rjf: query stack
{PushQuery 0 0 0 "" Null 0 0 0 0 0 0 0 Null "push_query" "Push Query" "Opens a new temporary query interface." "" "" }
+53
View File
@@ -4006,6 +4006,7 @@ rd_view_ui(Rng2F32 rect)
//
CFG_Node *cell_view = &cfg_nil_node;
B32 revert_cell = 0;
B32 browse_cell = 0;
UI_Signal sig = {0};
ProfScope("build cell contents")
UI_Parent(cell_box)
@@ -4187,6 +4188,27 @@ rd_view_ui(Rng2F32 rect)
MemoryZeroStruct(&cell_params.description);
}
// rjf: browse button for cfg file paths
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg && !(cell->flags & RD_WatchCellFlag_NoEval))
{
CFG_Node *root_cfg = rd_cfg_from_eval_space(cell->eval.space);
String8 child_key = e_string_from_id(cell->eval.space.u64s[1]);
MD_NodePtrList schemas = cfg_schemas_from_name(scratch.arena, rd_state->cfg_schema_table, root_cfg->string);
for EachNode(n, MD_NodePtrNode, schemas.first)
{
MD_Node *schema_child = md_child_from_string(n->v, child_key, 0);
if(schema_child != &md_nil_node)
{
if(str8_match(schema_child->first->string, s("path"), 0))
{
cell_params.flags |= RD_CellFlag_BrowseButton;
cell_params.browse_out = &browse_cell;
}
break;
}
}
}
// rjf: extra edit button for meta-cfg strings
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg)
{
@@ -4572,6 +4594,18 @@ rd_view_ui(Rng2F32 rect)
}
}
}
// rjf: apply browse
if(browse_cell)
{
ewv->next_cursor = ewv->next_mark = cell_pt;
if(!rd_watch_pt_match(ewv->cursor, cell_pt) && ewv->text_editing)
{
rd_cmd(RD_CmdKind_Accept);
}
rd_cmd(RD_CmdKind_FocusPanel);
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_PickFilePath].string);
}
}
}
@@ -16417,6 +16451,25 @@ rd_frame(void)
str8_list_pushf(rd_state->cmd_output_arena, &rd_state->cmd_outputs, "$%I64x", bp->id);
}break;
//- rjf: pick file paths
case RD_CmdKind_PickFilePath:
{
CFG_Node *window = cfg_node_from_id(rd_regs()->window);
RD_WindowState *ws = rd_window_state_from_cfg(window);
{
UI_Event evt = zero_struct;
evt.kind = UI_EventKind_Text;
evt.string = rd_regs()->file_path;
ui_event_list_push(scratch.arena, &ws->ui_events, &evt);
}
{
UI_Event evt = zero_struct;
evt.kind = UI_EventKind_Press;
evt.slot = UI_EventActionSlot_Accept;
ui_event_list_push(scratch.arena, &ws->ui_events, &evt);
}
}break;
//- rjf: queries
case RD_CmdKind_PushQuery:
{
+2 -2
View File
@@ -2315,7 +2315,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
default:{}break;
// rjf: override file picking
case RD_CmdKind_PickFile:
case RD_CmdKind_PickFileReplacement:
{
String8 src = rd_regs()->file_path;
String8 dst = cmd->regs->file_path;
@@ -2445,7 +2445,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
UI_TagF("pop")
if(ui_clicked(ui_buttonf("Find alternative...")))
{
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_PickFile].string);
rd_cmd(RD_CmdKind_RunCommand, .cmd_name = rd_cmd_kind_info_table[RD_CmdKind_PickFileReplacement].string);
}
scratch_end(scratch);
}
+37
View File
@@ -3656,6 +3656,43 @@ rd_cell(RD_CellParams *params, String8 string)
}
}
//////////////////////////////
//- rjf: build browse button
//
if(params->flags & RD_CellFlag_BrowseButton && !is_focus_active && !is_focus_active_disabled)
{
UI_Parent(box)
UI_PrefWidth(ui_children_sum(1))
RD_Font(RD_FontSlot_Main)
{
UI_TagF(".")
UI_TagF("weak")
UI_Column
UI_Padding(ui_pct(1, 0))
UI_PrefHeight(ui_em(2.f, 1.f))
UI_CornerRadius(ui_top_font_size()*0.5f)
UI_TextAlignment(UI_TextAlign_Center)
UI_PrefWidth(ui_text_dim(10, 1))
{
UI_Box *revert_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_DrawBackground|
UI_BoxFlag_DisableFocusOverlay|
UI_BoxFlag_DisableFocusBorder|
UI_BoxFlag_Clickable,
"Browse...");
UI_Signal sig = ui_signal_from_box(revert_box);
if(ui_clicked(sig) && params->browse_out)
{
params->browse_out[0] = 1;
}
}
ui_spacer(ui_em(1, 1));
}
}
//////////////////////////////
//- rjf: build toggle-switch
//
+11 -7
View File
@@ -28,19 +28,20 @@ enum
RD_CellFlag_EmptyEditButton = (1<<6),
RD_CellFlag_RevertButton = (1<<7),
RD_CellFlag_Lock = (1<<8),
RD_CellFlag_BrowseButton = (1<<9),
//- rjf: behavior
RD_CellFlag_DisableEdit = (1<<9),
RD_CellFlag_KeyboardClickable = (1<<10),
RD_CellFlag_SingleClickActivate = (1<<11),
RD_CellFlag_DisableEdit = (1<<10),
RD_CellFlag_KeyboardClickable = (1<<11),
RD_CellFlag_SingleClickActivate = (1<<12),
//- rjf: contents description
RD_CellFlag_CodeContents = (1<<12),
RD_CellFlag_CodeContents = (1<<13),
//- rjf: appearance
RD_CellFlag_Border = (1<<13),
RD_CellFlag_NoBackground = (1<<14),
RD_CellFlag_Button = (1<<15),
RD_CellFlag_Border = (1<<14),
RD_CellFlag_NoBackground = (1<<15),
RD_CellFlag_Button = (1<<16),
};
typedef struct RD_CellParams RD_CellParams;
@@ -75,6 +76,9 @@ struct RD_CellParams
//- rjf: revert out
B32 *revert_out;
//- rjf: browse out
B32 *browse_out;
//- rjf: text editing r/w info
U64 *cursor;
U64 *mark;