Add code editing ability.
Code still executes instantly.
This commit is contained in:
parent
bda42ad2e0
commit
91a294a56d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
elm-stuff/*
|
||||||
|
**/*.js
|
18
src/Main.elm
18
src/Main.elm
|
@ -1,11 +1,12 @@
|
||||||
import Html exposing (Html, div, text)
|
import Html exposing (Html, div, text, textarea)
|
||||||
import Html.Attributes exposing (class)
|
import Html.Attributes exposing (class)
|
||||||
|
import Html.Events exposing (onInput)
|
||||||
import Browser exposing (element)
|
import Browser exposing (element)
|
||||||
import Canvas exposing (Shape)
|
import Canvas exposing (Shape)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Parser exposing (Parser, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable)
|
import Parser exposing (Parser, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable)
|
||||||
import Color
|
import Color
|
||||||
import Canvas exposing (Point, path, lineTo, circle, shapes, stroke, lineWidth)
|
import Canvas exposing (Point, path, lineTo, circle, shapes, stroke, lineWidth, fill, rect)
|
||||||
import Set
|
import Set
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
@ -52,7 +53,7 @@ type alias Model =
|
||||||
}
|
}
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= Run
|
= UpdateText String
|
||||||
|
|
||||||
{-
|
{-
|
||||||
======= Syntax Code
|
======= Syntax Code
|
||||||
|
@ -294,7 +295,8 @@ allShapes (b, s) = pointerShape s.pos :: List.map lineShape b
|
||||||
|
|
||||||
canvas : (Board, State) -> Html Msg
|
canvas : (Board, State) -> Html Msg
|
||||||
canvas dat = Canvas.toHtml (500, 500) []
|
canvas dat = Canvas.toHtml (500, 500) []
|
||||||
[ shapes [ stroke Color.blue, lineWidth 5] (allShapes dat)
|
[ shapes [ fill Color.white ] [ rect (0, 0) 500 500 ]
|
||||||
|
, shapes [ stroke Color.blue, lineWidth 5] (allShapes dat)
|
||||||
]
|
]
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
@ -318,10 +320,14 @@ view m =
|
||||||
<| Result.withDefault (Err "Couldn't parse program")
|
<| Result.withDefault (Err "Couldn't parse program")
|
||||||
<| Result.map (\prg -> evaluateAll prg [] initialState) (run parseProg m.programText)
|
<| Result.map (\prg -> evaluateAll prg [] initialState) (run parseProg m.programText)
|
||||||
in
|
in
|
||||||
canvas dat
|
div [ class "logo-container" ]
|
||||||
|
[ div [ class "logo-pane" ] [ textarea [ onInput UpdateText ] [ text m.programText ] ]
|
||||||
|
, div [ class "logo-pane" ] [ canvas dat ]
|
||||||
|
]
|
||||||
|
|
||||||
update : Msg -> Model -> (Model, Cmd Msg)
|
update : Msg -> Model -> (Model, Cmd Msg)
|
||||||
update msg m = (m, Cmd.none)
|
update msg m = case msg of
|
||||||
|
UpdateText s -> ({ m | programText = s }, Cmd.none)
|
||||||
|
|
||||||
subscriptions : Model -> Sub Msg
|
subscriptions : Model -> Sub Msg
|
||||||
subscriptions m = Sub.none
|
subscriptions m = Sub.none
|
||||||
|
|
Loading…
Reference in New Issue
Block a user