all repos — nifty @ 8ae4bf1557c130765f067ab44c9a539e260e2249

A tiny (pseudo) package manager and script runner.

Fixed compilation with Nim v2.0.
h3rald h3rald@h3rald.com
Wed, 02 Aug 2023 15:12:52 +0000
commit

8ae4bf1557c130765f067ab44c9a539e260e2249

parent

f2d24457b17a4bc16c91657103d61ded2e502bea

1 files changed, 5 insertions(+), 2 deletions(-)

jump to
M src/niftypkg/messaging.nimsrc/niftypkg/messaging.nim

@@ -11,6 +11,9 @@ TreeNode* = object

label: string nodes: seq[TreeNode] +method `==`(obj1, obj2: TreeNode): bool {.base, noSideEffect.} = + return obj1.label == obj2.label and obj1.nodes == obj2.nodes + proc foreground(str: string, color: ForegroundColor) = stdout.setForegroundColor(color) stdout.write(str)

@@ -82,7 +85,7 @@

proc tree*(node: TreeNode, prefix = ""): string = let splitterPart = if node.nodes.len > 0: ch("│") else: "" let splitter = "\n" & prefix & splitterPart & "" - return prefix & [node.label].join(splitter) & "\n" & node.nodes.map(proc(x: TreeNode): string = + let op = proc(x: TreeNode): string = let ix = node.nodes.find(x) let last = node.nodes.len-1 == ix let more = x.nodes.len > 0

@@ -97,7 +100,7 @@ if lastPart == ch("└"):

offset = 2 endSpace = " " return prefix & lastPart & ch("─") & morePart & endSpace & rec[prefix.len+offset .. rec.len-1] - ).join("") + return prefix & [node.label].join(splitter) & "\n" & node.nodes.map(op).join("")