Skip to content

Commit

Permalink
[fix] Printing to terminal in js backend
Browse files Browse the repository at this point in the history
Issue: #20
  • Loading branch information
aruZeta committed Sep 9, 2022
1 parent 784dfdb commit 3f3709b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/QRgen/private/DrawedQRCode/print.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import
".."/[Drawing],
std/[strformat]

when defined(js):
import
std/[jsconsole]

proc printTerminal*(self: DrawedQRCode) =
## Print a `DrawedQRCode` to the terminal using `stdout`.
stdout.write "\n\n\n\n\n"
template log(s: string) =
when defined(js):
console.log s
else:
stdout.write s
log "\n\n\n\n\n"
for y in 0'u8..<self.drawing.size:
stdout.write " "
log " "
for x in 0'u8..<self.drawing.size:
stdout.write(
log(
if self.drawing[x, y]: "██"
else: " "
)
stdout.write "\n"
stdout.write "\n\n\n\n\n"
log "\n"
log "\n\n\n\n\n"

const svgHeader: string =
# SVG tag start
Expand Down

0 comments on commit 3f3709b

Please sign in to comment.