From 2abb8ffa46cbe86deedb9ddcbb9b042b51285feb Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sun, 22 Mar 2015 12:53:55 +0100 Subject: Editing name first draft --- src/Update/UpdateEdition.elm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Update/UpdateEdition.elm (limited to 'src/Update/UpdateEdition.elm') 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 -- cgit v1.2.3