more progress in df cmds -> msgs

This commit is contained in:
Ryan Fleury
2024-09-01 15:49:06 -07:00
parent 6ead03ac17
commit 06f65857db
8 changed files with 137 additions and 38 deletions
+5
View File
@@ -488,6 +488,11 @@ DF_ViewTable:
@expand(DF_ViewTable a) `DF_VIEW_UI_FUNCTION_DEF($(a.name_lower));`;
}
@data(String8) df_view_kind_name_lower_table:
{
@expand(DF_ViewTable a) `str8_lit_comp("$(a.name_lower)")`
}
@data(DF_ViewSpecInfo) df_g_gfx_view_kind_spec_info_table:
{
@expand(DF_ViewTable a) ```{(0|$(a.parameterized_by_entity)*DF_ViewSpecFlag_ParameterizedByEntity|$(a.project_specific)*DF_ViewSpecFlag_ProjectSpecific|$(a.can_serialize)*DF_ViewSpecFlag_CanSerialize|$(a.can_filter)*DF_ViewSpecFlag_CanFilter|$(a.filter_is_code)*DF_ViewSpecFlag_FilterIsCode|$(a.typing_automatically_filters)*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("$(a.name_lower)"), str8_lit_comp("$(a.display_string)"), DF_IconKind_$(a.icon), DF_VIEW_SETUP_FUNCTION_NAME($(a.name_lower)), DF_VIEW_CMD_FUNCTION_NAME($(a.name_lower)), DF_VIEW_UI_FUNCTION_NAME($(a.name_lower))}```;
+70 -29
View File
@@ -2758,7 +2758,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, D_CmdList *cmds)
UI_WidthFill UI_PrefHeight(ui_children_sum(1.f)) UI_Column UI_Padding(ui_pct(1, 0))
{
UI_TextRasterFlags(df_raster_flags_from_slot(DF_FontSlot_Main)) UI_FontSize(ui_top_font_size()*2.f) UI_PrefHeight(ui_em(3.f, 1.f)) ui_label(df_state->confirm_title);
UI_PrefHeight(ui_em(3.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_state->confirm_msg);
UI_PrefHeight(ui_em(3.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(df_state->confirm_desc);
ui_spacer(ui_em(1.5f, 1.f));
UI_Row UI_Padding(ui_pct(1.f, 0.f)) UI_WidthFill UI_PrefHeight(ui_em(5.f, 1.f))
{
@@ -8313,7 +8313,34 @@ df_frame(void)
//- rjf: meta
case DF_MsgKind_Exit:
{
// TODO(rjf): current implementation is wrong - will lose multiple windows!!!
D_EntityList running_processes = d_query_cached_entity_list_with_kind(D_EntityKind_Process);
// NOTE(rjf): if targets are running, push confirmation first, and
// get user's OK
UI_Key key = ui_key_from_string(ui_key_zero(), str8_lit("lossy_exit_confirmation"));
if(!ui_key_match(key, df_state->confirm_key) && running_processes.count != 0 && !regs->force_confirm)
{
df_state->confirm_key = key;
df_state->confirm_active = 1;
arena_clear(df_state->confirm_arena);
MemoryZeroStruct(&df_state->confirm_msg);
df_state->confirm_title = push_str8f(df_state->confirm_arena, "Are you sure you want to exit?");
df_state->confirm_desc = push_str8f(df_state->confirm_arena, "The debugger is still attached to %slive process%s.",
running_processes.count == 1 ? "a " : "",
running_processes.count == 1 ? "" : "es");
df_state->confirm_msg.kind = DF_MsgKind_Exit;
df_state->confirm_msg.regs = d_regs_copy(df_state->confirm_arena, regs);
df_state->confirm_msg.regs->force_confirm = 1;
}
// rjf: if no targets are running, or this is force-confirmed,
// then save & exit
else
{
df_msg(DF_MsgKind_WriteUserData);
df_msg(DF_MsgKind_WriteProjectData);
df_state->quit = 1;
}
}break;
case DF_MsgKind_RunCommand:
{
@@ -8321,7 +8348,8 @@ df_frame(void)
}break;
case DF_MsgKind_ToggleDevMenu:
{
// TODO(rjf)
DF_Window *window = df_window_from_handle(regs->window);
window->dev_menu_is_open ^= 1;
}break;
//- rjf: config reading/writing
@@ -8366,7 +8394,13 @@ df_frame(void)
//- rjf: confirmation
case DF_MsgKind_ConfirmAccept:
{
// TODO(rjf): confirm cmds -> msgs
df_state->confirm_active = 0;
df_state->confirm_key = ui_key_zero();
D_RegsScope
{
d_regs_copy_contents(scratch.arena, d_regs(), df_state->confirm_msg.regs);
df_msg(df_state->confirm_msg.kind);
}
}break;
case DF_MsgKind_ConfirmCancel:
{
@@ -8819,7 +8853,15 @@ df_frame(void)
//- rjf: tab creation/removal
case DF_MsgKind_OpenTab:
{
// TODO(rjf): need some way to pass down the view
DF_Panel *panel = df_panel_from_handle(regs->panel);
DF_View *view = df_view_alloc();
df_view_equip_spec(view, &df_nil_view_spec, regs->string, regs->params_tree);
DF_View *prev_view = panel->last_tab_view;
if(!df_view_is_nil(df_view_from_handle(regs->prev_view)))
{
prev_view = df_view_from_handle(regs->prev_view);
}
df_panel_insert_tab_view(panel, prev_view, view);
}break;
case DF_MsgKind_CloseTab:
{
@@ -9258,21 +9300,20 @@ df_frame(void)
FileProperties props = os_properties_from_file_path(path);
if(props.created != 0)
{
// TODO(rjf): open new tab, evaluating file path, using pending_file view rule
df_msg(DF_MsgKind_OpenTab);
#if 0
D_CmdParams p = *params;
p.window = df_handle_from_window(ws);
p.panel = df_handle_from_panel(ws->focused_panel);
d_cmd_list_push(scratch.arena, &cmds, &p, d_cmd_spec_from_kind(D_CmdKind_PendingFile));
#endif
df_msg(DF_MsgKind_OpenTab,
.panel = df_handle_from_panel(ws->focused_panel),
.string = d_eval_string_from_file_path(scratch.arena, path),
.params_tree = md_tree_from_string(scratch.arena, df_view_kind_name_lower_table[DF_ViewKind_PendingFile]));
}
else
{
log_user_errorf("Couldn't open file at \"%S\".", path);
}
}break;
case DF_MsgKind_Switch:{}break;
case DF_MsgKind_Switch:
{
// TODO(rjf): @msgs
}break;
case DF_MsgKind_SwitchToPartnerFile:
{
DF_Panel *panel = df_panel_from_handle(regs->panel);
@@ -9301,10 +9342,7 @@ df_frame(void)
FileProperties candidate_props = os_properties_from_file_path(candidate_path);
if(candidate_props.modified != 0)
{
// TODO(rjf):
//D_CmdParams p = df_cmd_params_from_panel(ws, panel);
//p.entity = d_handle_from_entity(candidate);
//d_cmd_list_push(arena, cmds, &p, d_cmd_spec_from_kind(D_CmdKind_Switch));
df_msg(DF_MsgKind_FindCodeLocation, .file_path = candidate_path, .cursor = txt_pt(0, 0));
break;
}
}
@@ -9625,11 +9663,14 @@ df_frame(void)
{
disasm_view_prioritized = (df_selected_tab_from_panel(dst_panel) == view_w_disasm);
dst_panel->selected_tab_view = df_handle_from_view(dst_view);
df_msg(DF_MsgKind_GoToLine,
.panel = df_handle_from_panel(dst_panel),
.view = df_handle_from_view(dst_view),
.cursor = point);
df_msg(cursor_snap_kind);
if(point.line != 0)
{
df_msg(DF_MsgKind_GoToLine,
.panel = df_handle_from_panel(dst_panel),
.view = df_handle_from_view(dst_view),
.cursor = point);
df_msg(cursor_snap_kind);
}
panel_used_for_src_code = dst_panel;
}
}
@@ -9672,7 +9713,7 @@ df_frame(void)
if(!df_panel_is_nil(dst_panel))
{
dst_panel->selected_tab_view = df_handle_from_view(dst_view);
df_msg(DF_MsgKind_GoToLine,
df_msg(DF_MsgKind_GoToAddress,
.panel = df_handle_from_panel(dst_panel),
.view = df_handle_from_view(dst_view),
.process = d_handle_from_entity(process),
@@ -9814,9 +9855,9 @@ df_frame(void)
arena_clear(df_state->confirm_arena);
MemoryZeroStruct(&df_state->confirm_cmds);
df_state->confirm_title = push_str8f(df_state->confirm_arena, "Are you sure you want to exit?");
df_state->confirm_msg = push_str8f(df_state->confirm_arena, "The debugger is still attached to %slive process%s.",
running_processes.count == 1 ? "a " : "",
running_processes.count == 1 ? "" : "es");
df_state->confirm_desc = push_str8f(df_state->confirm_arena, "The debugger is still attached to %slive process%s.",
running_processes.count == 1 ? "a " : "",
running_processes.count == 1 ? "" : "es");
D_CmdParams p = df_cmd_params_from_window(ws);
p.force_confirm = 1;
d_cmd_list_push(df_state->confirm_arena, &df_state->confirm_cmds, &p, d_cmd_spec_from_kind(D_CmdKind_CloseWindow));
@@ -11086,7 +11127,7 @@ df_frame(void)
}break;
case D_CmdKind_Switch:
{
// TODO(rjf): @viz_merge
// TODO(rjf): @msgs
#if 0
B32 already_opened = 0;
DF_Panel *panel = df_panel_from_handle(params->panel);
@@ -12227,7 +12268,7 @@ df_frame(void)
}
//////////////////////////////
//- rjf: queue drag drop (TODO(rjf))
//- rjf: queue drag drop (TODO(rjf): @msgs)
//
B32 queue_drag_drop = 0;
if(queue_drag_drop)
+3 -1
View File
@@ -607,6 +607,7 @@ struct DF_State
{
// rjf: arenas
Arena *arena;
B32 quit;
// rjf: messages
Arena *msgs_arena;
@@ -641,8 +642,9 @@ struct DF_State
F32 confirm_t;
Arena *confirm_arena;
D_CmdList confirm_cmds;
DF_Msg confirm_msg;
String8 confirm_title;
String8 confirm_msg;
String8 confirm_desc;
// rjf: string search state
Arena *string_search_arena;
@@ -281,6 +281,44 @@ str8_lit_comp("5"),
str8_lit_comp("c"),
};
String8 df_view_kind_name_lower_table[34] =
{
str8_lit_comp("null"),
str8_lit_comp("empty"),
str8_lit_comp("getting_started"),
str8_lit_comp("commands"),
str8_lit_comp("file_system"),
str8_lit_comp("system_processes"),
str8_lit_comp("entity_lister"),
str8_lit_comp("symbol_lister"),
str8_lit_comp("target"),
str8_lit_comp("targets"),
str8_lit_comp("file_path_map"),
str8_lit_comp("auto_view_rules"),
str8_lit_comp("breakpoints"),
str8_lit_comp("watch_pins"),
str8_lit_comp("scheduler"),
str8_lit_comp("call_stack"),
str8_lit_comp("modules"),
str8_lit_comp("watch"),
str8_lit_comp("locals"),
str8_lit_comp("registers"),
str8_lit_comp("globals"),
str8_lit_comp("thread_locals"),
str8_lit_comp("types"),
str8_lit_comp("procedures"),
str8_lit_comp("pending_file"),
str8_lit_comp("text"),
str8_lit_comp("disasm"),
str8_lit_comp("output"),
str8_lit_comp("memory"),
str8_lit_comp("bitmap"),
str8_lit_comp("color_rgba"),
str8_lit_comp("geo3d"),
str8_lit_comp("exception_filters"),
str8_lit_comp("settings"),
};
DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[34] =
{
{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanFilter|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("null"), str8_lit_comp(""), DF_IconKind_Null, DF_VIEW_SETUP_FUNCTION_NAME(null), DF_VIEW_CMD_FUNCTION_NAME(null), DF_VIEW_UI_FUNCTION_NAME(null)},
@@ -427,6 +427,7 @@ extern DF_StringBindingPair df_g_default_binding_table[110];
extern String8 df_g_binding_version_remap_old_name_table[7];
extern String8 df_g_binding_version_remap_new_name_table[7];
extern String8 df_g_icon_kind_text_table[69];
extern String8 df_view_kind_name_lower_table[34];
extern DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[34];
extern DF_IconKind df_cmd_kind_icon_kind_table[221];
extern DF_IconKind df_entity_kind_icon_kind_table[31];
+13
View File
@@ -1098,6 +1098,19 @@ if(work_top == 0) {work_top = &broken_work;}\
return result;
}
////////////////////////////////
//~ rjf: Bundled Text -> Tree Functions
internal MD_ParseResult
md_parse_from_text(Arena *arena, String8 filename, String8 text)
{
Temp scratch = scratch_begin(&arena, 1);
MD_TokenizeResult tokenize = md_tokenize_from_text(scratch.arena, text);
MD_ParseResult parse = md_parse_from_text_tokens(arena, filename, text, tokenize.tokens);
scratch_end(scratch);
return parse;
}
////////////////////////////////
//~ rjf: Tree -> Text Functions
+6
View File
@@ -298,6 +298,12 @@ internal MD_TokenizeResult md_tokenize_from_text(Arena *arena, String8 text);
internal MD_ParseResult md_parse_from_text_tokens(Arena *arena, String8 filename, String8 text, MD_TokenArray tokens);
////////////////////////////////
//~ rjf: Bundled Text -> Tree Functions
internal MD_ParseResult md_parse_from_text(Arena *arena, String8 filename, String8 text);
#define md_tree_from_string(arena, string) (md_parse_from_text((arena), str8_zero(), (string)).root)
////////////////////////////////
//~ rjf: Tree -> Text Functions
+1 -8
View File
@@ -671,7 +671,6 @@ internal B32
frame(void)
{
ProfBeginFunction();
B32 should_quit = 0;
Temp scratch = scratch_begin(0, 0);
//- rjf: begin logging
@@ -700,15 +699,9 @@ frame(void)
}
}
//- rjf: quit if no windows are left
if(df_state->first_window == 0)
{
should_quit = 1;
}
scratch_end(scratch);
ProfEnd();
return should_quit;
return df_state->quit;
}
////////////////////////////////