aboutsummaryrefslogtreecommitdiff
path: root/src/Update/UpdateEdition.elm
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-03-22 12:53:55 +0100
committerJoris Guyonvarch2015-03-22 12:53:55 +0100
commit2abb8ffa46cbe86deedb9ddcbb9b042b51285feb (patch)
tree3756c16ccdf8b61000767637db0807f3d40e12cc /src/Update/UpdateEdition.elm
parentce4580451def7e86d0f67d2c353ac65239e17fd1 (diff)
Editing name first draft
Diffstat (limited to 'src/Update/UpdateEdition.elm')
-rw-r--r--src/Update/UpdateEdition.elm30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/Update/UpdateEdition.elm b/src/Update/UpdateEdition.elm
new file mode 100644
index 0000000..911a4c1
--- /dev/null
+++ b/src/Update/UpdateEdition.elm
@@ -0,0 +1,30 @@
+module Update.UpdateEdition
+ ( updateEdition
+ , EditionAction(..)
+ ) where
+
+import Char (..)
+
+import Model.Edition.Edition (..)
+
+import Utils.List (..)
+
+type EditionAction =
+ DeleteLast
+ | AddChar KeyCode
+
+updateEdition : EditionAction -> Edition -> Edition
+updateEdition action edition =
+ case action of
+ DeleteLast ->
+ case maybeTail edition.chars of
+ Just tailChars ->
+ { edition | chars <- tailChars }
+ Nothing ->
+ edition
+ AddChar keyCode ->
+ case keyCodeToChar edition.kind keyCode of
+ Just char ->
+ { edition | chars <- char :: edition.chars }
+ Nothing ->
+ edition