image cards in basic engine

This commit is contained in:
2022-11-03 22:23:50 +00:00
parent b1567e9f66
commit 3d9fe72ada
4 changed files with 12 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
(reversed (basicText "dog") (basicText "chien"))
(reversed (typeText "owl") (typeText "chouette"))
(cloze "un" "deux" "trois" "quatre" "cinq")
(cloze "un" "deux" "trois" "quatre" "cinq")
(reversed (image "examples/france.png") (basicText "France"))

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -49,6 +49,12 @@
show (noConfirmShow.bind text)
score (typeScore.bind text)))
(function :CardSide image [:String path]
(object
show ->:Void [engine cc] (engine.showImageCC path cc)
score ->:Void [engine :Int->Void resolve] {(engine.showImage path)(engine.print "Score (0-5): ")(engine.input ->:Void str (resolve (Std.parseInt str)))}))
(defMacroVar cardId 0)
(defMacro card [front back &builder b]
@@ -87,7 +93,7 @@
#{cNextDate += oneDayInterval;}#)
(set ,cNextDate cNextDate))
(cc))
(engine.clear)
(if (or #{DateTime.now() > nextDate;}# (#if debug true false))
(.show .front ,cObject engine
->:Void
@@ -123,9 +129,10 @@
clear ->:Void {}
print ->:Void text (Sys.print text)
println ->:Void text (Sys.println text)
showImage ->:Void path (assertProcess (case (Sys.systemName) ("Windows" "cmd.exe") ("Linux" "xdg-open") ("Mac" "start") (never otherwise)) (case (Sys.systemName) ("Windows" ["/C" path]) ((or "Mac" "Linux") [path]) (never otherwise)))
printCC ->:Void [text cc] {(Sys.print text)(.readLine (Sys.stdin))(cc)}
printlnCC ->:Void [text cc] {(Sys.println text)(.readLine (Sys.stdin))(cc)}
showImageCC ->:Void [path cc] 0
showImageCC ->:Void [path cc] {(assertProcess (case (Sys.systemName) ("Windows" "cmd.exe") ("Linux" "xdg-open") ("Mac" "start") (never otherwise)) (case (Sys.systemName) ("Windows" ["/C" path]) ((or "Mac" "Linux") [path]) (never otherwise)))(.readLine (Sys.stdin))(cc)}
input ->:Void resolve (resolve (.readLine (Sys.stdin))))))
(when studyList
(let [nextIndex (Std.random studyList.length)

View File

@@ -6,6 +6,7 @@ typedef StudyEngine = {
clear: Void -> Void,
print: (String) -> Void,
println: (String) -> Void,
showImage: (String) -> Void,
printCC: (String, Continuation) -> Void,
printlnCC: (String, Continuation) -> Void,
showImageCC: (String, Continuation) -> Void,