Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: 'rgb_palette' - Term::ANSIColor Helper

by Tux (Canon)
on Aug 17, 2022 at 08:57 UTC ( [id://11146186]=note: print w/replies, xml ) Need Help??


in reply to 'rgb_palette' - Term::ANSIColor Helper

You might be interested in my xclorsel a Tk GUI to available X11 colors.

Not changed since 2007-05-08, so maybe apt for modernisation.

In relation: I have dis_colors to show the current setting for you ANSI-compliant terminal (xterm) related to colors. That makes it easier to choose the combination to select for your messages. This tool could do with an extension to show what to use from Term::ANSIColor, though that would make the display rather wide.

Note w.r.t. rgb_palette: I use light background and usually discard every tool that uses a black/dark background by default and has no easy/intuitive option to switch to light background. This excludes currently many IDE's as they default to dark background and their option(s) to switch to light background are not implemented well as obviously their developers do not use it. My own tools all default to something "nice" (YMMV) on a light background but when useful, a simple option or rc setting is supported for those that prefer a dark background.

It took me a bit to remember, but in the xterm source distributions come with color-tests in the vttests subfolder that show something similar to your rgb_palette.

EDIT: ExtUtils::MakeMaker is CORE and also comes with a prompt function, so you don't require an extra non-core dependancy.


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: 'rgb_palette' - Term::ANSIColor Helper
by kcott (Archbishop) on Aug 17, 2022 at 13:09 UTC

    G'day Tux,

    ++ Thanks for this wealth of information. I played with everything but don't have time to go into it all, in any great depth, right now (it's late evening here): some funtime ahead for the weekend.

    • xcolorsel — I had to change the shebang, but otherwise it worked out of the box; I like how you've displayed the full colour and the individual RGB components; I liked the second two dropdown lists ("/in name" & "/similar") which I see as being quite useful.
    • dis_colors — That's handy to get the codes and gives an immediate visualisation of foreground & background combinations. Term::ANSIColor provides a variety of ways to specify colours (strings, constants & arrayrefs); I don't have an answer to how you might lay out the display to include them.
    • vttests — I downloaded https://invisible-mirror.net/archives/xterm/current/xterm.tar.gz which was the latest. There are about 60 scripts in vttests/; I didn't see anything that looked like "color-tests"; I poked around in quite a few but didn't find the functionality you mentioned (i.e. "similar to your rgb_palette"). Could you provide specific filenames?
    • ExtUtils::MakeMaker::prompt() — I was aware of this but thanks for mentioning it anyway (you weren't to know and it's possibly useful for others). I do like the feature-rich IO::Prompter module; the menus are perhaps my favourite bit.

    At the outset, I'll say that I pretty much agree with what you said regarding light & dark backgrounds. In addition, I'm cognisant of accessibility issues (colour blindness, contrast, and so on).

    At the start of this thread, I said that I didn't find the rgbRGB codes intuitive. Initially, this script simply printed a 6x6x6 grid of those codes and the colours they represented. At that point, it was just a quick-and-dirty piece of code to help me with that.

    I then found the rNNNgNNNbNNN codes and realised, somewhat surprisedly, that I could use them. The script progressed from there, through multiple iterations, to what you see above. It was only after completion that I thought, "Others might find this useful; I should share".

    For your, and indeed anyone else's, light background, I think you may just need to make some very minimal changes: for instance, white to black (2 instances; 3 if you've changed fg()) and cyan to green (1 instance). Alternatively, you could use "on_black" for all of the text; although, I think that might end up looking a little messy. If you do make such changes, I'd appreciate feedback on your choices.

    — Ken

      Could you provide specific filenames?

      I should have mentioned 256colors.pl, 256colors2.pl, and 88colors2.pl.

      Regarding prompting, I find that perlfaq is missing some basics. There is a tiny part on how to read passwords and that is all.

      I had 2255 modules installed on my laptop and IO::Prompter was not one of them (now it is), so I think that proves it is not widely used.


      Enjoy, Have FUN! H.Merijn
        "I should have mentioned 256colors.pl, 256colors2.pl, and 88colors2.pl."

        Thanks. I'll check those out; probably at the weekend.

        "I had 2255 modules installed on my laptop and IO::Prompter was not one of them (now it is), so I think that proves it is not widely used."

        I think that proves that it's slightly more widely used than it was last week. :-)

        — Ken

      Hello kcott,

      > I do like the feature-rich IO::Prompter module; the menus are perhaps my favourite bit.

      well.. I dont know how to be kind about this, but I have a radical different opinion.

      Given anyone is free to choose their tool I find very irritating to spot a nice perl module ( IO::Prompter ) with this statement in the docomentation:

      Several features of this module are known to have problems under Windo +ws. If using that platform, you may have more success (and less distr +ess) by trying IO::Prompt::Tiny, IO::Prompt::Simple, or IO::Prompt::H +ooked first.

      Well.. it is kind to inform me, but consider this situation:

      Hey my friend! For sure I can lend you my wonderful supercar: it is very safe and fast but if you are not tall exactly 183 cm and 90 Kg the car probably will only go 40Km/h and the car can skid when cornering if your feet are not exactly 10 sized.

      :( thanks, better I'll take the bus..

      My busses are:

      use Term::Readline; $ENV{PERL_RL} = "Perl"; my $term = Term::ReadLine->new('sweet_ol_bus'); $term->Attribs->{completion_function} = sub { my $txt = shift; return grep { /^$txt/i } sort keys %$my_list_of +_autocompletion; }; my $in; while ( defined ( $in = $term->readline( 'my_prompt>' ) ) ) { chomp ($in); ... }

      More kind for IO::Prompter should be to have 00_OStest.t stating BAIL_OUT() if $^O eq "MSWin32" and instead I see all tests passing with only, ironically being an interactive module, t/styles.t ....................... skipped: Skipping interactive tests under Windows while all other interactive tests are ok:

      All tests successful. Files=38, Tests=163, 53 wallclock secs ( 0.09 usr + 0.09 sys = 0.19 +CPU) Result: PASS

      So please, consider it carefully before adopting a module if you plan to share your code widely. This is not criticism about you nor your code kcott, absolutely.

      You will see me at the next Perl conference selling t-shirts with: Strawberry setups matter and Say NO to OSsism

      </rant> :)

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
        Hey my friend! For sure I can lend you my wonderful supercar: it is very safe and fast but if you are not tall exactly 183 cm and 90 Kg the car probably will only go 40Km/h and the car can skid when cornering if your feet are not exactly 10 sized.

        Top rant! However, one cannot choose one's height or shoe size whereas one can choose one's OS. If the analogy were that the supercar handles perfectly if you support Torino but corners poorly if you support Juventus then that's more like it. :-p


        🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146186]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 07:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found