aboutsummaryrefslogtreecommitdiff
path: root/src/Edition/Update.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Edition/Update.elm')
-rw-r--r--src/Edition/Update.elm30
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