aboutsummaryrefslogtreecommitdiff
path: root/src/Update/UpdateEdition.elm
diff options
context:
space:
mode:
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