From 83d30eedd3cb46dff786cb06c88729d065fb9c77 Mon Sep 17 00:00:00 2001 From: Mohit Sethi Date: Sat, 13 Apr 2024 03:16:44 +0100 Subject: [PATCH] Fix open and switch command behaviour - Open command uses Switch command- Switches to file if already opened; if not, opens the file. - Improve switch command to search for the candidate entity in all panels, not just the selected panel, also focus on the panel when found. Both improvements are a real time saver when using these commands with ipc. --- src/df/gfx/df_gfx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index e59611d14..b8b55f71f 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -1837,7 +1837,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Window); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Panel); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); - df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PendingEntity)); + df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Switch)); } }break; case DF_CoreCmdKind_Reload: @@ -1870,14 +1870,18 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D { B32 already_opened = 0; DF_Panel *panel = df_panel_from_handle(params.panel); - for(DF_View *v = panel->first_tab_view; !df_view_is_nil(v); v = v->next) + for(DF_Panel *p = ws->root_panel; !df_panel_is_nil(p); p = df_panel_rec_df_pre(p).next) { - DF_Entity *v_param_entity = df_entity_from_handle(v->entity); - if(v_param_entity == df_entity_from_handle(params.entity)) + for(DF_View *v = p->first_tab_view; !df_view_is_nil(v); v = v->next) { - panel->selected_tab_view = df_handle_from_view(v); - already_opened = 1; - break; + DF_Entity *v_param_entity = df_entity_from_handle(v->entity); + if(v_param_entity == df_entity_from_handle(params.entity)) + { + p->selected_tab_view = df_handle_from_view(v); + ws->focused_panel = p; + already_opened = 1; + break; + } } } if(already_opened == 0)