Closed Bebby6 closed 1 year ago
Hi, thanks for your suggestion. I've tried to improve the performance of the regexes by making use of the source generator Regex attribute available in .NET 7, but I have to admit I haven't measured the memory consumption by use of benchmarks as I felt it's beyond my control.
As you touch upon the subject of simplicity, I do prefer to keep Pastel simple and clean without all the bells and whistles, just the bare minimum functionality. If you want, feel free to fork the library and add any utility methods that fit your particular requirements.
I already tried adding text decorations, however, adding gradient effect with text decorations completely destroyed the output, so there's a lot of work reaming for me 😄
The biggest problem, for me, is regex. I don't understand how closing nested pastel strings works as I'm not experienced with regex.
I'll try my best :D
An ANSI code string has a start code and and end code. What the regex does is to transform nested ANSI code strings into isolated, non-nested ANSI strings.
If you suppose that ANSI codes behave like brackets ([
and ]
) then it basically transforms this:
my [colored [string]]
into this:
my [colored ][string]
If you don't do this then the terminal will only recognize the outermost ANSI code and ignore the rest.
Oh, thanks! I finally understand it.
So, that's all and... thank you for your explaination and your time.
This utility already has a nice way of coloring, supporting color nesting. It's pretty fast, but not that memory efficient (most probably due to regex, but that's not a big problem).
For example, when I want to make text underlined or blinking, I need to do it myself. It would be really nice, if this library had a text decorations (also supporting nesting) and maybe more methods, like PastelGradient and PastelGradientBg to make text gradient in more than just 2 colors.
Example (what I imagine):
And one more thing... Code doesn't look nice, when nesting and using too much Pastel methods, like
.Pastel(...).PastelBg(...)
(and nesting it multiple times in string). What about having one more method with optional arguments, like.Pastel(fore: Color.Red, back: Color.White, decorations: new Decorations(Decoration.Italic, Decoration.Underline))
, which can be used only once, minimalizing method calls per one string.I hope this will be added, because this library is awesome by it's simplicity and no need for changing the Console class, like Colorful.Console does.