Skip to content

Commit

Permalink
Enable re-editing of source code
Browse files Browse the repository at this point in the history
  • Loading branch information
matijapretnar committed Oct 30, 2020
1 parent f74df3b commit a51810a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/webInterface/model.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type msg =
| UseStdlib of bool
| ChangeSource of string
| LoadSource
| EditSource
| SelectReduction of int option
| Step of Interpreter.top_step
| RandomStep
Expand Down Expand Up @@ -134,6 +135,7 @@ let update model = function
( (if model.use_stdlib then Loader.stdlib_source else "")
^ "\n\n\n" ^ model.unparsed_code );
}
| EditSource -> { model with loaded_code = Error "" }
| ChangeRandomStepSize random_step_size -> { model with random_step_size }
| ChangeInterruptOperation operation ->
{ model with interrupt_operation = Some operation }
Expand Down
17 changes: 15 additions & 2 deletions src/webInterface/view.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,20 @@ let step_action (red, step) =
elt "ol" (back_action :: :: step_actions @ [interrupt_action]) *)

let view_steps (model : Model.model) (code : Model.loaded_code) steps =
let view_undo_last_step =
let view_edit_source =
panel_block
[
elt "button"
~a:
[
class_ "button is-outlined is-fullwidth is-small is-danger";
onclick (fun _ -> Model.EditSource);
attr "title"
"Re-editing source code will abort current evaluation";
]
[ text "Re-edit source code" ];
]
and view_undo_last_step =
panel_block
[
elt "button"
Expand Down Expand Up @@ -240,7 +253,7 @@ let view_steps (model : Model.model) (code : Model.loaded_code) steps =
in
panel "Interaction"
~a:[ onmousemove (fun _ -> Model.SelectReduction None) ]
( view_undo_last_step :: view_random_steps steps
( view_edit_source :: view_undo_last_step :: view_random_steps steps
:: List.mapi view_step steps
@ [ send_interrupt ] )

Expand Down

0 comments on commit a51810a

Please sign in to comment.