From 973a039b54327df74396605410ea9abe19c8a4e7 Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 4 Sep 2016 21:21:11 +0200 Subject: Upgrade to elm 0.17.1 --- src/Edition/Update.elm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Edition/Update.elm (limited to 'src/Edition/Update.elm') 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 -- cgit v1.2.3