I've been having a good romp getting familiar with the Curses module in preparation for building a spiffy UI for an admin tool that has outgrown its command line interface. I've made much progress. Found lots of nice control over colors and text attributes. Alternate char set with box graphics chars. Etc...

But one thing eludes me. I can find no way to produce Color-on-TrueWhite text on a can_change_color()==0 terminal. What Curses calls "White" is actually Gray or OffWhite. You can bold that in the foreground to get TrueWhite text on a darker background. And setting a default of Black-on-TrueWhite is possible with a trick I stumbled upon. But I can find no way to produce Red-on-TrueWhite or Green-on-TrueWhite once a default has been set.

Before you point me to init_color(...) let me mention again that can_change_color() returns 0 on the setups where this will run (RedHad 7.n).

Is there hope? Here's some code to play with...

#!/usr/bin/perl -w use strict; use Curses; initscr(); start_color(); noecho(); cbreak(); # No input buffering assume_default_colors(COLOR_BLACK, 8); # True White bg! Why? init_pair(1, COLOR_BLUE, COLOR_RED); init_pair(2, COLOR_RED, COLOR_WHITE); # Actually OFF-White init_pair(3, COLOR_RED, 8); # Produces Black on Black my $win = new Curses; my $row = 0; $win->addstr($row++, 0, "Black on White"); attron( $win, COLOR_PAIR(1) ); $win->addstr($row++, 0, "Blue on Red"); attron( $win, COLOR_PAIR(2) ); $win->addstr($row++, 0, "Red on Off-White"); attron( $win, COLOR_PAIR(3) ); $win->addstr($row++, 0, "Red on True White? No! (All Black)"); attron( $win, COLOR_PAIR(1) ); $win->addstr($row++, 0, "Blue on Red again"); attroff( $win, COLOR_PAIR(1) ); $win->addstr($row++, 0, "Hit any key: "); $win->refresh(); my $ch = $win->getch(); endwin(); __END__ Color Reference: 0 COLOR_BLACK 4 COLOR_BLUE 1 COLOR_RED 5 COLOR_MAGENTA 2 COLOR_GREEN 6 COLOR_CYAN 3 COLOR_YELLOW 7 COLOR_WHITE

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall


In reply to No Color on TrueWhite in Curses? by dvergin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.