DUB colored output proposal/showcase

Steven Schveighoffer schveiguy at yahoo.com
Fri Jun 8 14:25:36 UTC 2018


On 6/8/18 9:51 AM, gdelazzari wrote:
> On Friday, 8 June 2018 at 13:38:59 UTC, Steven Schveighoffer wrote:
>> Looks excellent! Two thumbs up from me. Is it cross-platform?
>>
>> Note on some platforms (ahem, Macos) the background is white, so this 
>> should be correctly colored for that possibility.
>>
> 
> At the moment it's "probably" Linux-only, but that's because I only 
> wanted a proof of concept and I worked on it on my Linux installation. I 
> imported this library/Dub package https://github.com/yamadapc/d-colorize 
> and just used it. Which, by the way, it's no-good at the moment since I 
> saw that Dub doesn't use Dub packages itself - probably because, 
> otherwise, you don't have a way to easily compile it without Dub itself, 
> I guess :P so I'll need to either write my custom color outputting code 
> within Dub's source or just import that library.

Yeah, I would expect that the colorization is simply a matter of 
outputting the right control characters. You probably just need to 
include some simple stuff inside dub source itself. But I'm far from 
experienced on this.

> 
> Of course making it cross-platform is a mandatory thing to me. Windows 
> also needs some specific stuff to output colors, as you can see in the 
> library I linked, so there are definitely some things to do to support 
> all the platforms. I may even take a look at how DMD itself outputs 
> colored output, I guess it will be nice to keeps things consistent.
> 
> As for MacOS having a different background... I don't really own a Mac 
> nor I have ever used one before, so I don't even know how tools usually 
> output their colored text on it. 

I'm assuming it's similar to Linux, it's just that the background is 
white instead of black.

>At the moment it just sets the 
> foreground color to green/yellow/blue/whatever, without changing the 
> background, if that was your concern. If you meant that yellow-on-white 
> is not readable... well... I guess so.

Yes. In fact, I've used the new vibe.d and it appears not to adjust its 
colorization to my screen, it's light grey on white (almost impossible 
to read).

> Maybe two different color 
> palettes should be used? IDK, as I said I never used a Mac before so I 
> don't really know how other tools handle this, maybe if some Mac user 
> could help on this, it would be great.

The way I would solve it is to have a "light" mode and a "dark" mode, 
and version the default mode based on the OS (Linux, windows, etc. all 
dark mode by default, macos light mode by default).

> 
> Thanks for the appreciation by the way!

Thanks for the effort!

-Steve


More information about the Digitalmars-d mailing list