John Smith commited on 2022-206 08:50:59
Showing 3 changed files, with 6 additions and 6 deletions.
| ... | ... |
@@ -10,7 +10,7 @@ local recrw = dofile(SRC_DIR .. "recrw.lua") |
| 10 | 10 |
--[[ |
| 11 | 11 |
load a deck (a table of tables of `Prompt`s) from a Recfile |
| 12 | 12 |
]] |
| 13 |
-local function loaddeck(fname) |
|
| 13 |
+local function loaddeck(fname, conf) |
|
| 14 | 14 |
local fh = io.open(fname) |
| 15 | 15 |
if not fh then return nil end |
| 16 | 16 |
local rt = fh:read "a" |
| ... | ... |
@@ -18,7 +18,7 @@ local function loaddeck(fname) |
| 18 | 18 |
fh:close() |
| 19 | 19 |
local pr = recrw.read(rt) |
| 20 | 20 |
if not pr then return nil end |
| 21 |
- local ep = Prompt:fromrecs(pr) |
|
| 21 |
+ local ep = Prompt:fromrecs(pr, conf) |
|
| 22 | 22 |
return ep |
| 23 | 23 |
end |
| 24 | 24 |
|
| ... | ... |
@@ -191,7 +191,7 @@ math.randomseed(os.time()) |
| 191 | 191 |
]] |
| 192 | 192 |
-- Add card(s) |
| 193 | 193 |
if action == "a" then |
| 194 |
- local deck = loader.load(deckfname) |
|
| 194 |
+ local deck = loader.load(deckfname, config) |
|
| 195 | 195 |
if deck then |
| 196 | 196 |
if isatty() then |
| 197 | 197 |
io.write("Reading prompts -- press Ctrl-D to stop\n")
|
| ... | ... |
@@ -232,7 +232,7 @@ elseif action == "h" then |
| 232 | 232 |
elseif action == "r" then |
| 233 | 233 |
local deck |
| 234 | 234 |
if isatty() then |
| 235 |
- deck = loader.load(deckfname) |
|
| 235 |
+ deck = loader.load(deckfname, config) |
|
| 236 | 236 |
else |
| 237 | 237 |
io.write("Review should be done in the terminal\n")
|
| 238 | 238 |
end |
| ... | ... |
@@ -312,7 +312,7 @@ elseif action == "r" then |
| 312 | 312 |
local ev = io.read("l")
|
| 313 | 313 |
local cardrec = Prompt:torec(deck[ci]) |
| 314 | 314 |
cardrec.PromptText = { ev }
|
| 315 |
- deck[ci] = Prompt:fromrecs({ cardrec })[1]
|
|
| 315 |
+ deck[ci] = Prompt:fromrecs({ cardrec }, config)[1]
|
|
| 316 | 316 |
-- assume all other inputs to mean Cancel |
| 317 | 317 |
else |
| 318 | 318 |
end |
| ... | ... |
@@ -43,7 +43,7 @@ end |
| 43 | 43 |
extracts `Prompt`s from a record-based deck |
| 44 | 44 |
returns a table of tables of `Prompt`s |
| 45 | 45 |
]] |
| 46 |
-function Prompt:fromrecs(recs) |
|
| 46 |
+function Prompt:fromrecs(recs, conf) |
|
| 47 | 47 |
local ret = {}
|
| 48 | 48 |
for i, rec in ipairs(recs) do |
| 49 | 49 |
-- only bother with records with `PromptText` |
| 50 | 50 |