diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56ba610 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +elm-stuff/* +**/*.js diff --git a/src/Main.elm b/src/Main.elm index 4461099..47dd97d 100644 --- a/src/Main.elm +++ b/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.Events exposing (onInput) import Browser exposing (element) import Canvas exposing (Shape) import Dict exposing (Dict) import Parser exposing (Parser, (|.), (|=), variable, succeed, symbol, int, spaces, map, oneOf, lazy, sequence, Trailing(..), keyword, run, backtrackable) 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 {- @@ -52,7 +53,7 @@ type alias Model = } type Msg - = Run + = UpdateText String {- ======= Syntax Code @@ -294,7 +295,8 @@ allShapes (b, s) = pointerShape s.pos :: List.map lineShape b canvas : (Board, State) -> Html Msg 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.map (\prg -> evaluateAll prg [] initialState) (run parseProg m.programText) 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 m = (m, Cmd.none) +update msg m = case msg of + UpdateText s -> ({ m | programText = s }, Cmd.none) subscriptions : Model -> Sub Msg subscriptions m = Sub.none