Skip to content

Commit

Permalink
Fix open and switch command behaviour
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
GloriousPtr committed Apr 13, 2024
1 parent d560f8c commit 83d30ee
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/df/gfx/df_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 83d30ee

Please sign in to comment.