aboutsummaryrefslogtreecommitdiff
path: root/src/format.nim
diff options
context:
space:
mode:
authorshirleyquirk2020-08-04 23:54:04 +0000
committerGitHub2020-08-04 23:54:04 +0000
commit22799b2e439d6b74ca648060faa1e3f1ee13f946 (patch)
tree512a18c53d4e7e6878ea134a2a307e3caec2278d /src/format.nim
parentb2321b0ded6f4a9803daf9dbcbd88d56321a9305 (diff)
parent731f8d7692bfe08f5fd5890a98797f9b1b8d065d (diff)
Merge pull request #1 from shirleyquirk/collect
Collect
Diffstat (limited to 'src/format.nim')
-rw-r--r--src/format.nim16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/format.nim b/src/format.nim
index b8061f9..f85733a 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -110,7 +110,13 @@ proc printPackageInfo*(minPadding: int, color: bool, lines: varargs[PackageLineF
if values.len == 0:
@[]
elif forceBreak:
- lc[x | (y <- values.map(s => strutils.strip(s).splitLines(lineSize)), x <- y), string]
+ when NimVersion > "1.2":
+ collect(newSeq):
+ for y in values.map(s => strutils.strip(s).splitLines(lineSize)):
+ for x in y:
+ x
+ else:
+ lc[x | (y <- values.map(s => strutils.strip(s).splitLines(lineSize)), x <- y), string]
else:
values.map(v => strutils.strip(v)).foldl(a & " " & b).splitLines(lineSize)
@@ -301,7 +307,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
if not bar or width <= 0:
echo(title, "...")
- (proc (a: string, c: float) {.closure.} = discard, proc {.closure.} = discard)
+ (proc (a: string, c: float) {.sideEffect,closure.} = discard, proc {.sideEffect,closure.} = discard)
else:
let infoLen = max(width * 6 / 10, 50).int
let progressLen = width - infoLen
@@ -311,7 +317,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) {.sideEffect,closure.} =
let progressTrim = max(min(1, progress + 0.005), 0)
let progressStr = $(progressTrim * 100).int & "%"
let paddedProgressStr = ' '.repeat(5 - progressStr.len) & progressStr
@@ -349,7 +355,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
' ', timeLeft, indicator, paddedProgressStr, "\x1b[0K\r")
stdout.flushFile()
- proc terminate() {.closure.} =
+ proc terminate() {.sideEffect,closure.} =
echo()
update(" ", 0)
@@ -359,7 +365,7 @@ proc printProgressFull*(bar: bool, title: string): ((string, float) -> void, ()
proc printProgressShare*(bar: bool, title: string): ((int, int) -> void, () -> void) =
let (updateFull, terminate) = printProgressFull(bar, title)
- proc update(current: int, total: int) {.closure.} =
+ proc update(current: int, total: int) {.sideEffect,closure.} =
let prefix = if total > 0:
"(" & ' '.repeat(($total).len - ($current).len) & $current & "/" &
$total & ") "