Hi guys.
I'm trying to use the box-drawing characters of Unicode to draw some fancy dialogs at the terminal. I could do it without problems but I'm trying to find if there is a more "straightforward" form.
The codepoints are defined as:
type
DialogBorderRunes = enum
dbrHLine = 0x2500
dbrVLine = 0x2502
dbrTopLeft = 0x250C
dbrTopRight =0x2510
dbrBottomLeft = 0x2514
dbrBottomRight = 0x2518
I can "draw"the top of the dialog with styledWrite in this manner:
setCursorPos(left, top)
stdout.styledWrite(bg, Rune(dbrTopLeft).toUTF8() &
Rune(dbrHLine).toUTF8().repeat(dlgWidth-2) &
Rune(dbrTopRight).toUTF8())
All works ok, but how about the efficiency in instancing Rune and converting to UTF8 repeatedly?
Considering that Nim string is UTF8, I'm wondering if I can do something like:
stdout.styledWrite(bg, "\x250C") & "\x2500".repeat(dlgWidth-2) & "\x2510)
I mean embedding the character codepoint in the string itself instead of creating a Rune a converting it to UTF8 subsequently?
Thank you very much.
Thanks, works awesome in Linux.
Windows CMD.EXE shows bad characters unless I set CHCP to 65001 (UTF8).