Skip to content

Commit

Permalink
Draw an undo icon when in a snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
donadigo committed Jan 16, 2024
1 parent 39e3ed4 commit 77bb75a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/df/core/df_core.mdesk
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ DF_CoreCmdTable:
{StepIntoLine 0 0 0 0 0 Entity Null Null Null Null 0 0 StepInto "step_into_line" "Step Into (Line)" "Performs a step that goes into calls, at the source code line level." "step,thread" }
{StepOverLine 0 0 0 0 0 Entity Null Null Null Null 0 0 StepOver "step_over_line" "Step Over (Line)" "Performs a step that skips calls, at the source code line level." "step,thread" }
{StepOut 0 0 0 0 0 Entity Null Null Null Null 0 0 StepOut "step_out" "Step Out" "Runs to the end of the current function and exits it." "" }
{StepBack 0 0 0 0 0 Entity Null Null Null Null 0 0 StepOut "step_back" "Step Back" "Steps back in the execution." "step,back" }
{StepBack 0 0 0 0 0 Entity Null Null Null Null 0 0 LeftArrow "step_back" "Step Back" "Steps back in the execution." "step,back" }
{RunToAddress 0 0 0 0 0 Entity VirtualAddr Null Thread VirtualAddr 0 0 PlayStepForward "run_to_address" "Run To Address" "Runs the selected thread to the specified address." "" }
{RunToModuleOffset 0 0 0 0 0 Entity VirtualOff Null Thread VirtualOff 0 0 PlayStepForward "run_to_module_offset" "Run To Module Offset" "Runs the selected thread to the specified offset within the current module." "" }
{Halt 0 0 0 0 0 Null Null Null Null Null 0 0 Pause "halt" "Halt" "Halts all running processes." "pause" }
Expand Down
2 changes: 1 addition & 1 deletion src/df/core/generated/df_core.meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DF_CmdSpecInfo df_g_core_cmd_kind_spec_info_table[] =
{ str8_lit_comp("step_into_line"), str8_lit_comp("Performs a step that goes into calls, at the source code line level."), str8_lit_comp("step,thread"), str8_lit_comp("Step Into (Line)"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_StepInto, {0, 0}},
{ str8_lit_comp("step_over_line"), str8_lit_comp("Performs a step that skips calls, at the source code line level."), str8_lit_comp("step,thread"), str8_lit_comp("Step Over (Line)"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_StepOver, {0, 0}},
{ str8_lit_comp("step_out"), str8_lit_comp("Runs to the end of the current function and exits it."), str8_lit_comp(""), str8_lit_comp("Step Out"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_StepOut, {0, 0}},
{ str8_lit_comp("step_back"), str8_lit_comp("Steps back in the execution."), str8_lit_comp("step,back"), str8_lit_comp("Step Back"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_StepOut, {0, 0}},
{ str8_lit_comp("step_back"), str8_lit_comp("Steps back in the execution."), str8_lit_comp("step,back"), str8_lit_comp("Step Back"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_LeftArrow, {0, 0}},
{ str8_lit_comp("run_to_address"), str8_lit_comp("Runs the selected thread to the specified address."), str8_lit_comp(""), str8_lit_comp("Run To Address"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_VirtualAddr, DF_CmdParamSlot_Null}, DF_CmdQueryRule_VirtualAddr, DF_IconKind_PlayStepForward, {0, 0}},
{ str8_lit_comp("run_to_module_offset"), str8_lit_comp("Runs the selected thread to the specified offset within the current module."), str8_lit_comp(""), str8_lit_comp("Run To Module Offset"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Entity, DF_CmdParamSlot_VirtualOff, DF_CmdParamSlot_Null}, DF_CmdQueryRule_VirtualOff, DF_IconKind_PlayStepForward, {0, 0}},
{ str8_lit_comp("halt"), str8_lit_comp("Halts all running processes."), str8_lit_comp("pause"), str8_lit_comp("Halt"), (DF_CmdSpecFlag_OmitFromLists*0) | (DF_CmdSpecFlag_RunKeepsQuery*0) | (DF_CmdSpecFlag_QueryUsesOldInput*0) | (DF_CmdSpecFlag_AppliesToView*0) | (DF_CmdSpecFlag_QueryIsCode*0), {DF_CmdParamSlot_Null, DF_CmdParamSlot_Null, DF_CmdParamSlot_Null}, DF_CmdQueryRule_Null, DF_IconKind_Pause, {0, 0}},
Expand Down
14 changes: 13 additions & 1 deletion src/df/gfx/df_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -9204,12 +9204,24 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
ui_set_next_pref_height(ui_pct(1, 0));
ui_set_next_text_color(color);
ui_set_next_text_alignment(UI_TextAlign_Center);

B32 is_snapshot_active = 0;
for (DF_Entity *child = thread->first; !df_entity_is_nil(child); child = child->next)
{
if (child->kind == DF_EntityKind_Snapshot && child->b32 == 1)
{
is_snapshot_active = 1;
break;
}
}

DF_IconKind icon_kind = is_snapshot_active ? DF_IconKind_Undo : DF_IconKind_RightArrow;
UI_Box *thread_box = ui_build_box_from_stringf(UI_BoxFlag_DisableTextTrunc|
UI_BoxFlag_Clickable|
UI_BoxFlag_AnimatePosX|
UI_BoxFlag_DrawText,
"%S##ip_%p",
df_g_icon_kind_text_table[DF_IconKind_RightArrow],
df_g_icon_kind_text_table[icon_kind],
thread);
UI_Signal thread_sig = ui_signal_from_box(thread_box);

Expand Down

0 comments on commit 77bb75a

Please sign in to comment.