aboutsummaryrefslogtreecommitdiff
path: root/src/format.nim
diff options
context:
space:
mode:
authorzqqw2020-08-05 13:53:43 +0000
committerGitHub2020-08-05 13:53:43 +0000
commitf2a93bea278e9f43cad98ca8e74f9a423f36e333 (patch)
tree721da2b78793860b6fb020194efe2eccea88bac9 /src/format.nim
parentb2321b0ded6f4a9803daf9dbcbd88d56321a9305 (diff)
parent4bbf3dc2097f1de206fa053fac32f675d4ae2927 (diff)
Merge pull request #4 from shirleyquirk/lc_useVersion
I mean it this time
Diffstat (limited to 'src/format.nim')
-rw-r--r--src/format.nim15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/format.nim b/src/format.nim
index b8061f9..bd6d393 100644
--- a/src/format.nim
+++ b/src/format.nim
@@ -1,6 +1,6 @@
import
macros, options, posix, sequtils, strutils, sugar, times, unicode,
- utils, "listcomp"
+ utils
type
PackageLineFormat* = tuple[
@@ -110,7 +110,10 @@ 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]
+ collect(newSeq):
+ for y in values.map(s => strutils.strip(s).splitLines(lineSize)):
+ for x in y:
+ x
else:
values.map(v => strutils.strip(v)).foldl(a & " " & b).splitLines(lineSize)
@@ -301,7 +304,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 +314,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 +352,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 +362,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 & ") "