mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
setting to prefer os native file dialog uis (off by default because they are slow and bad)
This commit is contained in:
@@ -680,6 +680,12 @@ os_graphical_message(B32 error, String8 title, String8 message)
|
||||
fprintf(stderr, "%.*s\n\n", str8_varg(message));
|
||||
}
|
||||
|
||||
internal String8
|
||||
os_graphical_pick_file(Arena *arena, String8 initial_path)
|
||||
{
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shell Operations
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@ internal void os_set_cursor(OS_Cursor cursor);
|
||||
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
|
||||
|
||||
internal void os_graphical_message(B32 error, String8 title, String8 message);
|
||||
internal String8 os_graphical_pick_file(Arena *arena, String8 initial_path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shell Operations
|
||||
|
||||
@@ -242,6 +242,12 @@ os_graphical_message(B32 error, String8 title, String8 message)
|
||||
{
|
||||
}
|
||||
|
||||
internal String8
|
||||
os_graphical_pick_file(Arena *arena, String8 initial_path)
|
||||
{
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shell Operations
|
||||
|
||||
|
||||
@@ -1577,6 +1577,29 @@ os_graphical_message(B32 error, String8 title, String8 message)
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
internal String8
|
||||
os_graphical_pick_file(Arena *arena, String8 initial_path)
|
||||
{
|
||||
String8 result = {0};
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
U64 buffer_size = 4096;
|
||||
U16 *buffer = push_array(scratch.arena, U16, buffer_size);
|
||||
OPENFILENAMEW params = {sizeof(params)};
|
||||
{
|
||||
params.lpstrFile = (WCHAR *)buffer;
|
||||
params.nMaxFile = buffer_size;
|
||||
params.lpstrInitialDir = (WCHAR *)str16_from_8(scratch.arena, initial_path).str;
|
||||
}
|
||||
if(GetOpenFileNameW(¶ms))
|
||||
{
|
||||
result = str8_from_16(arena, str16_cstring((U16 *)buffer));
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Shell Operations
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#pragma comment(lib, "UxTheme")
|
||||
#pragma comment(lib, "ole32")
|
||||
#pragma comment(lib, "user32")
|
||||
#pragma comment(lib, "comdlg32")
|
||||
#ifndef WM_NCUAHDRAWCAPTION
|
||||
#define WM_NCUAHDRAWCAPTION (0x00AE)
|
||||
#endif
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -279,6 +279,10 @@ RD_VocabTable:
|
||||
//- rjf: windows style menu bar
|
||||
@default(1) @display_name('Focus Menu Bar With Alt') @description("Mimics standard Windows behavior of focusing the menu bar using the Alt key.")
|
||||
'focus_menu_bar_with_alt': bool,
|
||||
|
||||
//- rjf: native filesystem dialogues
|
||||
@default(0) @display_name('Use Native File System Dialog') @description("Uses the operating system's file system dialog box, rather than the debugger's built-in UI.")
|
||||
'use_native_file_system_dialog': bool,
|
||||
}
|
||||
```
|
||||
}
|
||||
|
||||
@@ -12645,6 +12645,25 @@ rd_frame(void)
|
||||
RD_RegsScope(.cmd_name = str8_zero()) rd_push_cmd(cmd->regs->cmd_name, rd_regs());
|
||||
}
|
||||
|
||||
// rjf: command has filesystem query, user wants native filesystem UI -> get the path then run the command
|
||||
else if(info->query.slot == RD_RegSlot_FilePath && rd_setting_b32_from_name(str8_lit("use_native_file_system_dialog")))
|
||||
{
|
||||
RD_Cfg *user = rd_cfg_child_from_string(rd_state->root_cfg, str8_lit("user"));
|
||||
RD_Cfg *current_path = rd_cfg_child_from_string(user, str8_lit("current_path"));
|
||||
String8 current_path_string = current_path->first->string;
|
||||
if(current_path_string.size == 0)
|
||||
{
|
||||
current_path_string = path_normalized_from_string(scratch.arena, os_get_current_path(scratch.arena));
|
||||
}
|
||||
String8 file_path = os_graphical_pick_file(scratch.arena, current_path_string);
|
||||
file_path = path_normalized_from_string(scratch.arena, file_path);
|
||||
if(file_path.size != 0)
|
||||
{
|
||||
RD_RegsScope(.cmd_name = str8_zero(), .file_path = file_path) rd_push_cmd(cmd->regs->cmd_name, rd_regs());
|
||||
rd_cmd(RD_CmdKind_SetCurrentPath, .file_path = str8_chop_last_slash(file_path));
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: command has required query -> prep query
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user