iximeow / yaxpeax-arch

fundamental traits to describe an architecture in the yaxpeax project
BSD Zero Clause License
11 stars 2 forks source link

YaxColors impossible to implement through public API #5

Open Ben-Lichtman opened 1 year ago

Ben-Lichtman commented 1 year ago

The methods in YaxColors require returning yaxpeax_arch::color::Colored which is not accessible through the public API.

Please make this available through the public API.

Without this the only options are to use NoColors or the default scheme ColorSettings

iximeow commented 4 months ago

oh dear, sorry i missed this one for so long. that's definitely not great, though i've been also discovering that none of yaxpeax_arch::color::Colored inlines nearly as well as i was hoping in more specialized uses (the display-opt branch of yaxpeax-x86 is where i've really been pushing things recently) ... so!

i'll make this public in the next few days, that'll be yaxpeax-arch 0.2.9. but once i've figured out a more inlining-friendly YaxColors that whole module might need a bit of tweaking. at this rate maybe that will be next year 😅

iximeow commented 3 months ago

as it turns out YaxColors was quite misguided - for consoles that don't support ANSI color sequences, crossterm would reasonably try doing things like invoking the Windows Console APIs (example) ... and so YaxColors only works in those environments if this Display impl is used to write directly to a console (either by stdout or stderr). otherwise the console mode would be twiddled while writing to a file, for example, with the outcome that there would be no colors anyway.

... it also requires that anything colorizing text understands ANSI color sequences and maps that to whatever application-appropriate markup is necessary - this all works right in the context i suspect the handful of yaxpeax users currently use it (writing instructions to unixy VT100-like terminals), but is almost counterproductive if you want to print marked up instructions anywhere else.

as for YaxColors itself, i suspect the trait will have to change but i'm not yet sure how. it probably shouldn't be so closely interwoven with "printing to a terminal". whatever happens here, it's nice to be able to easily get colorized text to a terminal, and the library will definitely keep an easy way to do that.