Open midshell-ghoul opened 2 weeks ago
looks like the prompt length calculator not calculating the color correctly. The calculator should ignore the color chars length.
Is there a proper way to pass Color to the Styler.init() ? I tried:
let fgCustomColor = rgb(150, 50, 250)
let prompt = Styler.init(fgCustomColor, "prompt> ")
but that didn't seem to take despite there being code in the library to handle Color.
What kind of terminal you use? Is the example/test.nim
works for your terminal?
I'm using the default kali terminal. The examples in example/test.nim
work as they are using ForegroundColor. Anything from std/colors
fails (https://nim-lang.org/docs/colors.html)
Edit: zsh version 5.9. It seems nim-noise uses stdout.setForegroundColor c.rgbVal
when using Color. This function checks to make sure the terminal supports true color, which mine supposedly does... (https://github.com/nim-lang/Nim/blob/version-2-2/lib/pure/terminal.nim#L764). This might just be a configuration issue on my end.
Edit2: Terminal supports true color just fine
Final Edit: Okay it turns out I needed to call enableTrueColors()
. std/terminal doesn't seem to actually check whether true color is supported, you've got to explicitly tell it.
Glad you can solve it
Using custom colors in the prompt adds dead space at the end of it. This occurs anytime you pass a string with ANSI escape characters in it, and seems to be roughly the length of the escape characters used.
This code:
Results in this output:
I tried another method, by using a Color value directly in the Styler initialization, however it didn't work. I might be reading the source code wrong, but I believe it is supported here (https://github.com/jangko/nim-noise/blob/master/noise/styler.nim#L54). Please let me know if I've misunderstood something.