Add support for editing the meta rules
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
535c714b47
commit
abd6a848f8
12
src/Main.elm
12
src/Main.elm
|
@ -18,12 +18,14 @@ import Tuple
|
|||
|
||||
type Tab
|
||||
= Editor
|
||||
| MetaEditor
|
||||
| Rendered
|
||||
|
||||
tabEq : Tab -> Tab -> Bool
|
||||
tabEq t1 t2 =
|
||||
case (t1, t2) of
|
||||
(Editor, Editor) -> True
|
||||
(MetaEditor, MetaEditor) -> True
|
||||
(Rendered, Rendered) -> True
|
||||
_ -> False
|
||||
|
||||
|
@ -48,6 +50,7 @@ type alias Model =
|
|||
type alias Flags = { renderRules: String, rules: String, query: String }
|
||||
type Msg
|
||||
= SetProgram String
|
||||
| SetRenderProgram String
|
||||
| SetQuery String
|
||||
| SetTab Tab
|
||||
| SetEditMode EditMode
|
||||
|
@ -59,10 +62,11 @@ viewSection : String -> Html Msg -> Html Msg
|
|||
viewSection name content =
|
||||
Html.div [ class "bergamot-section" ] [ Html.em [ class "bergamot-section-heading" ] [ Html.text name ], content ]
|
||||
|
||||
viewTab : Tab -> Html Msg -> Html Msg -> Html Msg
|
||||
viewTab tab editor rendered =
|
||||
viewTab : Tab -> Html Msg -> Html Msg -> Html Msg -> Html Msg
|
||||
viewTab tab editor metaEditor rendered =
|
||||
case tab of
|
||||
Editor -> editor
|
||||
MetaEditor -> metaEditor
|
||||
Rendered -> rendered
|
||||
|
||||
viewSelector : (a -> a -> Bool) -> (a -> Msg) -> a -> List (a, String) -> Html Msg
|
||||
|
@ -129,12 +133,13 @@ viewProofTree mode renderProgs progs querys = viewSection "Proof Tree" <|
|
|||
|
||||
view : Model -> Html Msg
|
||||
view m = Html.div [ class "bergamot-root" ]
|
||||
[ viewTabSelector m.tab [(Editor, "Rule Editor"), (Rendered, "Rendered Rules")]
|
||||
[ viewTabSelector m.tab [(Editor, "Rule Editor"), (MetaEditor, "Meta Rule Editor"), (Rendered, "Rendered Rules")]
|
||||
, viewEditModeSelector m.editMode [(Query, "Query"), (Syntax, "Language Term")]
|
||||
, viewSection "Query" <| Html.input [ type_ "text", onInput SetQuery, value m.query ] []
|
||||
, viewProofTree m.editMode m.renderProgram m.program m.query
|
||||
, viewTab m.tab
|
||||
(viewSection "Rules" <| Html.textarea [ onInput SetProgram ] [ Html.text m.program ])
|
||||
(viewSection "Meta Rules" <| Html.textarea [ onInput SetRenderProgram ] [ Html.text m.renderProgram ])
|
||||
(Html.Lazy.lazy2 viewRules m.renderProgram m.program)
|
||||
]
|
||||
|
||||
|
@ -142,6 +147,7 @@ update : Msg -> Model -> (Model, Cmd Msg)
|
|||
update msg m =
|
||||
case msg of
|
||||
SetProgram prog -> ({ m | program = prog }, Cmd.none)
|
||||
SetRenderProgram prog -> ({ m | renderProgram = prog }, Cmd.none)
|
||||
SetQuery query -> ({ m | query = query }, Cmd.none)
|
||||
SetTab tab -> ({ m | tab = tab }, Cmd.none)
|
||||
SetEditMode mode -> ({ m | editMode = mode }, Cmd.none)
|
||||
|
|
Loading…
Reference in New Issue
Block a user