termenv icon indicating copy to clipboard operation
termenv copied to clipboard

fix(templatehelper): no styles in Ascii mode

Open justenwalker opened this issue 4 years ago • 2 comments

If the color profile doesn't support ANSI color codes, then it likely shouldn't support any Style options either. This returns a no-op funcmap from termenv.TemplateFuncs when the color profile is Ascii.

justenwalker avatar Jul 24 '20 01:07 justenwalker

If the terminal doesn't support colors, also it doesn't support styles like Bold, Cross-out, etc.

I'm actually not sure this is the case, but I'm not aware of terminals which do support text style options that don't also support colors. And also, from the principle of least surprise -- I'd expect if my color profile is Ascii, I shouldn't be getting any ANSI escape codes in the output. (ie: my output is going to a file, not the terminal)

justenwalker avatar Jul 24 '20 01:07 justenwalker

Hi,

First, really cool library 🚀

I wanted to use it and I ran into the same issue today. @muesli are you OK with this change? Do you consider merging it soon?

It is just a helper function, so I just introduce my own. However, it would be to use built-in one ;)

mszostok avatar Aug 03 '22 18:08 mszostok

I'm not opposed to the change, it's the right thing to do. I didn't merge it so far, because it was consistent with the actual behavior of termenv's core API. That was always a design issue however and never the intended behavior. Recent API changes (termenv.Output) rectified this situation and as such I'm leaning towards (finally!) merging this PR.

muesli avatar Sep 22 '22 09:09 muesli