Show progress within review sessions
John Smith

John Smith commited on 2022-360 14:16:26
Showing 1 changed files, with 12 additions and 0 deletions.


If the ShowProgress option is present in the config file,
Memoire will display an indicator of the form
"(prompt number/session size)" thruout a review session.
... ...
@@ -141,6 +141,16 @@ local function showpctiles(list, pctiles, func, name)
141 141
     return s .. "\n"
142 142
 end
143 143
 
144
+--[[
145
+    show progress thru a review session, conditioned on the user
146
+    configuring that to happen
147
+]]
148
+local function showprogress(k, n, conf)
149
+    if conf:get("ShowProgress") then
150
+        io.write(string.format("(%d/%d) ", k, n))
151
+    end
152
+end
153
+
144 154
 local actions = {
145 155
     a = {
146 156
         desc = "(a)dd card (from stdin)",
... ...
@@ -272,10 +282,12 @@ local actions = {
272 282
                 -- remove braces for display
273 283
                 local pst = pr.text:gsub("%{([^{}]+)%}", "%1")
274 284
                 local st = os.time()
285
+                showprogress(ind, climn, config)
275 286
                 imgify(pst:gsub("%%A", "___"), deckfname:match(".*/") or "", config)
276 287
                 io.write("\n")
277 288
                 io.read("l")
278 289
                 clear()
290
+                showprogress(ind, climn, config)
279 291
                 imgify(
280 292
                     pst:gsub("%%A", "\x1b[1m" .. (pr.ans:gsub("%%", "%%%%")) .. "\x1b[0m"),
281 293
                     deckfname:match(".*/") or "",
282 294