aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/feature/syncsource.nim3
-rw-r--r--src/format.nim13
2 files changed, 10 insertions, 6 deletions
diff --git a/src/feature/syncsource.nim b/src/feature/syncsource.nim
index c050e6a..09e9c6d 100644
--- a/src/feature/syncsource.nim
+++ b/src/feature/syncsource.nim
@@ -130,7 +130,8 @@ proc cloneAndCopy(config: Config, quiet: bool, fullTargets: seq[FullPackageTarge
newSeq[BaseTarget]())
let (update, terminate) = if quiet:
- (proc (a: int, b: int) {.closure.} = discard, proc () {.closure.} = discard)
+ (proc (a: int, b: int) {.closure, sideEffect.} = discard,
+ proc () {.closure, sideEffect.} = discard)
else:
printProgressShare(config.common.progressBar, tr"cloning repositories")
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 & ") "