allow grouping card namespaces
This commit is contained in:
@@ -56,15 +56,22 @@
|
|||||||
score ->:Void [engine :Int->Void resolve] {(engine.showImage path)(engine.print "Score (0-5): ")(engine.input ->:Void str (resolve (Std.parseInt str)))}))
|
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)
|
(defMacroVar cardId 0)
|
||||||
|
(defMacroVar groupId 0)
|
||||||
|
|
||||||
|
(defMacro group [&body body]
|
||||||
|
(setMacroVar groupId (+ groupId 1))
|
||||||
|
(setMacroVar cardId 0)
|
||||||
|
`{,@body})
|
||||||
|
|
||||||
(defMacro card [front back &builder b]
|
(defMacro card [front back &builder b]
|
||||||
(let [cObject (b.symbol "cObject$cardId")
|
(let [idSymbol ->name (b.symbol "${name}${groupId}_${cardId}")
|
||||||
cScore (b.symbol "cScore$cardId")
|
cObject (idSymbol "cObject")
|
||||||
cRepetitions (b.symbol "cRepetitions$cardId")
|
cScore (idSymbol "cScore")
|
||||||
cPreviousEaseFactor (b.symbol "cPreviousEaseFactor$cardId")
|
cRepetitions (idSymbol "cRepetitions")
|
||||||
cPreviousInterval (b.symbol "cPreviousInterval$cardId")
|
cPreviousEaseFactor (idSymbol "cPreviousEaseFactor")
|
||||||
cNextDate (b.symbol "cNextDate$cardId")
|
cPreviousInterval (idSymbol "cPreviousInterval")
|
||||||
cStudy (b.symbol "cStudy$cardId")]
|
cNextDate (idSymbol "cNextDate")
|
||||||
|
cStudy (idSymbol "cStudy")]
|
||||||
(setMacroVar cardId (+ cardId 1))
|
(setMacroVar cardId (+ cardId 1))
|
||||||
`{
|
`{
|
||||||
(var ,cObject (object front ,front back ,back))
|
(var ,cObject (object front ,front back ,back))
|
||||||
@@ -106,13 +113,12 @@
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
(defMacro reversed [front back]
|
(defMacro reversed [front back]
|
||||||
`{
|
`(group
|
||||||
(card ,front ,back)
|
(card ,front ,back)
|
||||||
(card ,back ,front)
|
(card ,back ,front)))
|
||||||
})
|
|
||||||
|
|
||||||
(defMacro cloze [&builder b &body textLines]
|
(defMacro cloze [&builder b &body textLines]
|
||||||
(b.begin
|
(b.callSymbol "group"
|
||||||
(for i (range textLines.length)
|
(for i (range textLines.length)
|
||||||
`(card
|
`(card
|
||||||
(object
|
(object
|
||||||
|
Reference in New Issue
Block a user