Skip to content

Commit

Permalink
merge fix
Browse files Browse the repository at this point in the history
  • Loading branch information
disconcision committed Dec 16, 2024
2 parents 1ea2ac4 + b429e57 commit 31c8e72
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 20 deletions.
26 changes: 23 additions & 3 deletions src/haz3lweb/app/editors/cell/CellEditor.re
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ module Update = {
CodeEditable.Update.update(~settings, action, model.editor);
{...model, editor};
| ResultAction(action) =>
let* result = EvalResult.Update.update(~settings, action, model.result);
let* result =
EvalResult.Update.update(
~settings={
...settings,
core: {
...settings.core,
assist: false,
},
},
action,
model.result,
);
{...model, result};
};
};
Expand All @@ -66,7 +77,7 @@ module Update = {
);
let result =
EvalResult.Update.calculate(
~settings,
~settings={...settings, assist: false},
~queue_worker,
~is_edited,
editor |> CodeEditable.Model.get_statics,
Expand Down Expand Up @@ -136,7 +147,16 @@ module View = {
) => {
let (footer, overlays) =
EvalResult.View.view(
~globals,
~globals={
...globals,
settings: {
...globals.settings,
core: {
...globals.settings.core,
assist: false,
},
},
},
~signal=
fun
| MakeActive(a) => signal(MakeActive(Result(a)))
Expand Down
35 changes: 25 additions & 10 deletions src/haz3lweb/app/editors/decoration/Deco.re
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,31 @@ module Deco =
Some((l, r));
};
};
PieceDec.indicated(
~base_clss="tile-next-step",
~attr=[Virtual_dom.Vdom.Attr.on_mousedown(_ => {inject(i)})],
~line_clss=["next-step-line"],
~font_metrics,
~caret=(Id.invalid, 0),
~rows=measured.rows,
~tiles=[(id, mold, shards)],
)
|> Option.map(_, range);
Option.map(
x => {
PieceDec.indicated(
~base_clss="tile-next-step",
~attr=[Virtual_dom.Vdom.Attr.on_mousedown(_ => {inject(i)})],
~line_clss=["next-step-line"],
~font_metrics,
~caret=(Id.invalid, 0),
~rows=measured.rows,
~tiles=[(id, mold, shards)],
x,
)
@ PieceDec.indicated(
~base_clss="tile-next-step-top",
~attr=[Virtual_dom.Vdom.Attr.on_mousedown(_ => {inject(i)})],
~line_clss=["next-step-line"],
~font_metrics,
~caret=(Id.invalid, 0),
~rows=measured.rows,
~tiles=[(id, mold, shards)],
x,
)
},
range,
);
},
tiles,
)
Expand Down
65 changes: 58 additions & 7 deletions src/haz3lweb/view/StepperView.re
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module Update = {
[@deriving (show({with_path: false}), sexp, yojson)]
type t =
// int here should include hidden steps
// Note this int is backwards compared to the selection (0 is the most recent step)
| StepperEditor(int, StepperEditor.Update.t)
| StepForward(int)
| StepBackward;
Expand Down Expand Up @@ -289,13 +290,15 @@ module Update = {
evaluation: {
...a.evaluation,
show_settings: true,
stepper_history: true,
},
}
== CoreSettings.{
...b,
evaluation: {
...b.evaluation,
show_settings: true,
stepper_history: true,
},
}
});
Expand Down Expand Up @@ -357,14 +360,17 @@ module Selection = {
[@deriving (show({with_path: false}), sexp, yojson)]
type t =
// int here should include hidden steps
// Note this int is backwards compared to the editors (so that 0 is the oldest step, and selections are preserved)
| A(int, StepperEditor.Selection.t);

let get_cursor_info = (~selection: t, mr: Model.t): Cursor.cursor(Update.t) => {
Cursor.(
switch (selection) {
| A(n, editor_selection) =>
let a: option(Model.a) =
mr.history |> Aba.get_as |> List.nth_opt(_, n);
mr.history
|> Aba.get_as
|> ListUtil.nth_opt(List.length(mr.history |> Aba.get_as) - n - 1);
switch (a) {
| Some(Calculated(a)) =>
let+ x =
Expand All @@ -383,7 +389,10 @@ module Selection = {
let handle_key_event =
(~selection: t, ~event, mr: Model.t): option(Update.t) => {
let A(i, s) = selection;
let a: option(Model.a) = mr.history |> Aba.get_as |> List.nth_opt(_, i);
let a: option(Model.a) =
mr.history
|> Aba.get_as
|> ListUtil.nth_opt(List.length(mr.history |> Aba.get_as) - i - 1);
switch (a) {
| Some(Calculated(a)) =>
let+ x =
Expand Down Expand Up @@ -465,15 +474,34 @@ module View = {
StepperEditor.View.view(
~globals,
~overlays=[],
~selected=selection == Some(A(i + 1, ())),
~selected=
selection
== Some(
A(
List.length(stepper.history |> Aba.get_as)
- (i + 1)
- 1,
(),
),
),
~dynamics=Dynamics.Map.empty,
~inject=
(x: StepperEditor.Update.t) =>
inject(StepperEditor(i + 1, x)),
~signal=
fun
| TakeStep(_) => Ui_effect.Ignore
| MakeActive => signal(MakeActive(A(i + 1, ()))),
| MakeActive =>
signal(
MakeActive(
A(
List.length(stepper.history |> Aba.get_as)
- (i + 1)
- 1,
(),
),
),
),
{
editor: a.editor |> Calc.get_value,
next_steps: [],
Expand Down Expand Up @@ -513,15 +541,38 @@ module View = {
div(~attrs=[Attr.class_("equiv")], [Node.text("≡")]),
StepperEditor.View.view(
~globals,
~selected=selection == Some(A(current_n, ())),
~selected=
selection
== Some(
A(
List.length(stepper.history |> Aba.get_as)
- current_n
- 1,
(),
),
),
~inject=
(x: StepperEditor.Update.t) =>
inject(StepperEditor(current_n, x)),
~dynamics=Dynamics.Map.empty,
~signal=
fun
| TakeStep(x) => inject(Update.StepForward(x))
| MakeActive => signal(MakeActive(A(current_n, ()))),
| TakeStep(x) =>
Effect.Many([
inject(Update.StepForward(x)),
Effect.Stop_propagation,
])
| MakeActive =>
signal(
MakeActive(
A(
List.length(stepper.history |> Aba.get_as)
- current_n
- 1,
(),
),
),
),
~overlays=[],
{
editor: model.editor |> Calc.get_value,
Expand Down
8 changes: 8 additions & 0 deletions src/haz3lweb/www/style/dynamics.css
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ svg.tile-next-step {
filter: drop-shadow(1px 1px var(--G2));
}

svg.tile-next-step-top {
pointer-events: all;
cursor: pointer;
visibility: hidden;
z-index: var(--stepper-interactive-z);
filter: drop-shadow(1px 1px var(--G2));
}

svg.tile-taken-step {
filter: drop-shadow(1px 1px var(--BR1));
}
Expand Down
1 change: 1 addition & 0 deletions src/haz3lweb/www/style/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@
/* ABOVE CODE LEVEL */
--backpack-targets-z: 11;
--code-hovers-z: 11;
--stepper-interactive-z: 15;
--caret-z: 20;
--code-emblems-z: 21;

Expand Down

0 comments on commit 31c8e72

Please sign in to comment.