aboutsummaryrefslogtreecommitdiff
path: root/src/format.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.nim')
-rw-r--r--src/format.nim13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/format.nim b/src/format.nim
index e8645b8..1e28e47 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -294,12 +294,14 @@ macro choices*(choices: varargs[untyped]): untyped =
else:
error("error")
-proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, () -> void) =
+proc printProgressFull*(bar: bool, title: string):
+ (proc (prefix: string, progress: float) {.closure.}, proc {.closure.}) =
let width = getWindowSize().width
if not bar or width <= 0:
echo(title, "...")
- (proc (a: string, c: float) {.closure.} = discard, proc {.closure.} = discard)
+ (proc (a: string, b: float) {.closure, sideEffect.} = discard,
+ proc () {.closure, sideEffect.} = discard)
else:
let infoLen = max(width * 6 / 10, 50).int
let progressLen = width - infoLen
@@ -309,7 +311,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
var lastProgress = 0f
var averageSpeed = -1f
- proc update(prefix: string, progress: float) {.closure.} =
+ proc update(prefix: string, progress: float) =
let progressTrim = max(min(1, progress + 0.005), 0)
let progressStr = $(progressTrim * 100).int & "%"
let paddedProgressStr = ' '.repeat(5 - progressStr.len) & progressStr
@@ -354,10 +356,11 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
(update, terminate)
-proc printProgressShare*(bar: bool, title: string): ((int, int) -> void, () -> void) =
+proc printProgressShare*(bar: bool, title: string):
+ (proc (current: int, total: int) {.closure.}, proc {.closure.}) =
let (updateFull, terminate) = printProgressFull(bar, title)
- proc update(current: int, total: int) {.closure.} =
+ proc update(current: int, total: int) =
let prefix = if total > 0:
"(" & ' '.repeat(($total).len - ($current).len) & $current & "/" &
$total & ") "