textattr library for text colors and attributes available in D

Basile B. b2.temp at gmx.com
Sat Nov 24 01:07:35 UTC 2018


On Thursday, 8 November 2018 at 13:37:08 UTC, Shriramana Sharma 
wrote:
> https://github.com/jamadagni/textattr/
>
> textattr is a library and command-line tool that makes adding 
> color and attributes to beautify the terminal output of your 
> program easier by translating human-readable specs into ANSI 
> escape codes.
>
> The library is available for C, C++, Python and D. C++ and 
> Python use the C code for internal processing but the D code is 
> a separate implementation for easy inclusion of textattr.d in a 
> D compilation command without requiring any external linking.
>
> Copyright: Shriramana Sharma, 2018
> License: BSD-2-Clause

i was thinking to something like this the other day:


struct ColoredText(int color)
{
     string payload;
     alias payload this;
}

with a writeln() like function that check if the args are 
template instances of ColoredText.


or even more versatile:

@Color!Blue string b1, b2;
@Color!Red  string r1, r2;
@Color!Green int i1, i2;


with a writeln() like function that inspects the UDA or the args.


More information about the Digitalmars-d-announce mailing list