John Smith commited on 2023-161 12:43:07
Showing 1 changed files, with 8 additions and 3 deletions.
If the BoldContext option is set and a card has a context indicator at the start, in addition to displaying the context in bold, the rest of the card will be displayed only after a 0.3-second delay, forcing the user to distinctly notice the context. This fixes my common failure mode of giving the wrong answer to a prompt just sith I didn't actually look at the context and assumed it asked for something different.
| ... | ... |
@@ -13,7 +13,7 @@ end |
| 13 | 13 |
implementation may be platform-specific |
| 14 | 14 |
`basepath` points to the base directory of the images |
| 15 | 15 |
]] |
| 16 |
-local function imgify(text, basepath, ind, climn, conf) |
|
| 16 |
+local function imgify(text, basepath, ind, climn, conf, question) |
|
| 17 | 17 |
local fh = io.popen("tput lines")
|
| 18 | 18 |
local tl = tonumber(fh:read("a"))
|
| 19 | 19 |
io.write(("\n"):rep(math.floor(0.4 * tl)))
|
| ... | ... |
@@ -26,6 +26,10 @@ local function imgify(text, basepath, ind, climn, conf) |
| 26 | 26 |
io.write(cpt) |
| 27 | 27 |
io.write("\x1b[0m")
|
| 28 | 28 |
text = text:sub(cei + 1) |
| 29 |
+ if question then |
|
| 30 |
+ io.flush() |
|
| 31 |
+ os.execute("sleep 0.3")
|
|
| 32 |
+ end |
|
| 29 | 33 |
end |
| 30 | 34 |
end |
| 31 | 35 |
-- adapted from https://stackoverflow.com/a/1579673 |
| ... | ... |
@@ -124,7 +128,7 @@ local function fn(config, deck, deckfname) |
| 124 | 128 |
-- remove braces for display |
| 125 | 129 |
local pst = pr.text:gsub("%{([^{}]+)%}", "%1")
|
| 126 | 130 |
local st = os.time() |
| 127 |
- imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", ind, climn, config)
|
|
| 131 |
+ imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", ind, climn, config, true)
|
|
| 128 | 132 |
io.write("\n")
|
| 129 | 133 |
io.read("l")
|
| 130 | 134 |
clear() |
| ... | ... |
@@ -133,7 +137,8 @@ local function fn(config, deck, deckfname) |
| 133 | 137 |
deckfname:match(".*/") or "",
|
| 134 | 138 |
ind, |
| 135 | 139 |
climn, |
| 136 |
- config |
|
| 140 |
+ config, |
|
| 141 |
+ false |
|
| 137 | 142 |
) |
| 138 | 143 |
io.write(string.format( |
| 139 | 144 |
"\nAgain / Hard (%s) / Good (%s) / Easy (%s) / Correction ", |
| 140 | 145 |