aboutsummaryrefslogtreecommitdiff
path: root/src/Edition/Model.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/Edition/Model.elm')
-rw-r--r--src/Edition/Model.elm45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Edition/Model.elm b/src/Edition/Model.elm
new file mode 100644
index 0000000..5c1b295
--- /dev/null
+++ b/src/Edition/Model.elm
@@ -0,0 +1,45 @@
+module Edition.Model exposing
+ ( Edition
+ , Kind(..)
+ , newEdition
+ , keyCodeToChar
+ , isEmpty
+ )
+
+import String
+
+import Model.Id exposing (..)
+import Model.Keyboard exposing (KeyCode)
+
+import Edition.Model.Name as NameEdition
+import Edition.Model.Time as TimeEdition
+
+type alias Edition =
+ { id : Id
+ , kind : Kind
+ , chars : List Char
+ }
+
+type Kind =
+ Name
+ | Time
+
+newEdition id kind =
+ { id = id
+ , kind = kind
+ , chars = []
+ }
+
+keyCodeToChar : Kind -> KeyCode -> Maybe Char
+keyCodeToChar kind =
+ case kind of
+ Name -> NameEdition.keyCodeToChar
+ Time -> TimeEdition.keyCodeToChar
+
+isEmpty : Edition -> Bool
+isEmpty edition =
+ edition.chars
+ |> String.fromList
+ |> String.trim
+ |> String.length
+ |> (==) 0