John Smith commited on 2022-246 21:46:30
Showing 1 changed files, with 11 additions and 3 deletions.
If the BoldContext option is set in the user's configuration (which can be done by just having it present at all, no specific value needed), when reviewing a prompt, the context phrase (anything before the first colon) will be displayed in bold.
| ... | ... |
@@ -44,7 +44,15 @@ end |
| 44 | 44 |
implementation may be platform-specific |
| 45 | 45 |
`basepath` points to the base directory of the images |
| 46 | 46 |
]] |
| 47 |
-local function imgify(text, basepath) |
|
| 47 |
+local function imgify(text, basepath, conf) |
|
| 48 |
+ if conf:get("BoldContext") then
|
|
| 49 |
+ local csi, cei = text:find("^[^:]+:")
|
|
| 50 |
+ local cpt = text:sub(csi, cei) |
|
| 51 |
+ io.write("\x1b[1m")
|
|
| 52 |
+ io.write(cpt) |
|
| 53 |
+ io.write("\x1b[0m")
|
|
| 54 |
+ text = text:sub(cei + 1) |
|
| 55 |
+ end |
|
| 48 | 56 |
-- adapted from https://stackoverflow.com/a/1579673 |
| 49 | 57 |
local IMG_PATTERN = "IMG%[([^%]]+)%]" |
| 50 | 58 |
local PATTERN = "(.-)" .. IMG_PATTERN |
| ... | ... |
@@ -290,10 +298,10 @@ elseif action == "r" then |
| 290 | 298 |
-- remove braces for display |
| 291 | 299 |
local pst = pr.text:gsub("%{([^{}]+)%}", "%1")
|
| 292 | 300 |
local st = os.time() |
| 293 |
- imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "")
|
|
| 301 |
+ imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", config)
|
|
| 294 | 302 |
io.write("\n")
|
| 295 | 303 |
io.read("l")
|
| 296 |
- imgify(pst:gsub("%%A", (pr.ans:gsub("%%", "%%%%"))), deckfname:match(".*/") or "")
|
|
| 304 |
+ imgify(pst:gsub("%%A", (pr.ans:gsub("%%", "%%%%"))), deckfname:match(".*/") or "", config)
|
|
| 297 | 305 |
io.write(string.format( |
| 298 | 306 |
"\nAgain / Hard (%s) / Good (%s) / Easy (%s) / Correction ", |
| 299 | 307 |
disptime(review.schedule(pr, st, 0.5, config)), |
| 300 | 308 |