Template version of ANSI color code lib useful?
Shriramana Sharma
not.sure.why.a.mail.id.is.needed.even.if.invalid at gmail.com
Sat Oct 14 14:35:53 UTC 2017
Hello. I prepared a utility/library to output ANSI escape codes
for terminal text attributes with capabilities as advertised at
https://sites.google.com/site/jamadagni/files/temp/textattr-usage.html. (AFAIK this set of capabilities does not exist already in any existing package.)
This was first written in D and ported with much effort to C.
This is the utility/library I refer to at
http://forum.dlang.org/post/n6362a$1t7u$1@digitalmars.com.
Now I would prefer to keep the single C source and just write a
thin D wrapper to call the C library because C is also callable
from many other languages (and people can write wrappers for
their favourite one).
However the only disadvantage (as discussed in the above thread)
is that the C library function is not CTFE-able in D and thus I
cannot write a D template in the wrapper to evaluate the colour
codes at compile time.
On the other hand, I am not sure whether it is really useful to
evaluate colour codes at compile time because it is tantamount to
hardcoding them, and this means that any program using the
library is not able to switch off colour output at will if stdout
is not connected to a terminal.
If the library is only called at runtime, I am able to add a
boolean switch to just make the library always output an empty
string for all calls effectively switching off colour code output
which is useful when stdout is not a terminal.
My question: do people agree that there is not much point in
enabling CTFE of colour codes?
More information about the Digitalmars-d
mailing list