diff options
author | Joris | 2016-09-04 21:21:11 +0200 |
---|---|---|
committer | Joris | 2016-09-04 21:21:31 +0200 |
commit | 973a039b54327df74396605410ea9abe19c8a4e7 (patch) | |
tree | c702564d17e0a490d56845027238eb4f231be785 /src/Edition/Update.elm | |
parent | 62fee9133f36f655c1ed83e0c2e85394f9948bf5 (diff) |
Upgrade to elm 0.17.1
Diffstat (limited to 'src/Edition/Update.elm')
-rw-r--r-- | src/Edition/Update.elm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Edition/Update.elm b/src/Edition/Update.elm new file mode 100644 index 0000000..e219629 --- /dev/null +++ b/src/Edition/Update.elm @@ -0,0 +1,30 @@ +module Edition.Update exposing + ( updateEdition + ) + +import Char +import Char exposing (KeyCode) +import List + +import Edition.Model exposing (..) +import Edition.Msg exposing (..) + +updateEdition : Msg -> Edition -> Edition +updateEdition msg edition = + case msg of + + DeleteLast -> + case List.tail edition.chars of + Just tailChars -> + { edition | chars = tailChars } + Nothing -> + edition + + AddChar keyCode -> + case keyCodeToChar edition.kind keyCode of + Just char -> + if keyCode == 32 && List.head edition.chars == Just (Char.fromCode 32) + then edition + else { edition | chars = char :: edition.chars } + Nothing -> + edition |