Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 654931 Details for
Bug 882185
Few values (0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, and 255) don't display colours accurately on the terminal window.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
A program to change the colour of the terminal screen from value 0 to 255
testing_colors.c (text/x-csrc), 3.33 KB, created by
Kanda-kanda Malangu
on 2012-11-30 11:03:01 UTC
(
hide
)
Description:
A program to change the colour of the terminal screen from value 0 to 255
Filename:
MIME Type:
Creator:
Kanda-kanda Malangu
Created:
2012-11-30 11:03:01 UTC
Size:
3.33 KB
patch
obsolete
>/*********************************** testing_colors.c ************************************ > * * > * A program for observing the appearance of the 256 colors on the enhanced terminal. * > * * > * AUTHOR: Kanda-kanda Malangu * > * * > * Date: Thursday November 29, 2012 at 00:30 EST * > *****************************************************************************************/ >#include <ncurses.h> >#include <string.h> > >#define NUMBER_OF_COLORS 256 // total number of colors for the enhanced terminal > >#define BLACK_COLOR 16 /* sets the "black" color to 16 instead of 0 because 16 seems to > appear much darker than any other value in the range */ > >#define WHITE_COLOR 231 /* sets the "white" color to 231 instead of 7 because 231 seems to > appear much clearer than any other value in the range */ > >void create_color_pairs(void); >void print_message(int color_value, char *message); > >int >main(void) >{ > char *greetings = "HELLO WORLD!"; > int color_value; > > if (initscr() == NULL) > { > fprintf(stderr, "Cannot initialize the standard screen for curses mode\n"); > return 1; > } > > if (start_color() != OK) > { > endwin(); > fprintf(stderr, "Cannot initialize the color mode on this terminal"); > return 2; > } > > noecho(); > > // initializes the 256 color-pairs designed for this test-program. > create_color_pairs(); > > // prints 256 times the greetings on a different background color for each iteration. > for (color_value = 0; color_value < NUMBER_OF_COLORS; color_value++) > { > print_message(color_value, greetings); > } > > endwin(); > return 0; >} > >/* > * Creates only 256 color-pairs by setting a white foreground on 6 selected background colors > * to ease comparisons and readability, and black foreground on the remaining 250 background > * colors for the same raison. However for this enhanced terminal as many as 65,536 color-pairs > * can be created. > */ >void >create_color_pairs(void) >{ > for (int color_value = 0; color_value < NUMBER_OF_COLORS; color_value++) > { > if ((color_value == 7) || (color_value == 15) || (color_value == 16) || (color_value == 187) || (color_value == 188) || (color_value == 230)) > init_pair(color_value+1, WHITE_COLOR, color_value); // foreground is set to white > else > init_pair(color_value+1, BLACK_COLOR, color_value); // foreground is set to black > } >} > >/* > * Prints the message passed to it as argument, along with other information, on a background > * color determined by the parameter of the macro COLOR_PAIR(). It allows the user observe the > * background color of the standard screen and consequently decide on the name of the color. > */ >void >print_message(int color_value, char *message) >{ > int n = strlen(message); > > // the value to be passed to the macro COLOR_PAIR() should start from 1 up to 256 > bkgd(COLOR_PAIR(color_value+1)); > > mvprintw(LINES/2, (COLS-n)/2, message); > mvprintw(LINES-5, 5, "This background color has value %3d. Which color do you think it is?", color_value); > if (color_value != 255) > mvprintw(LINES-3, 15, "Press any printable key to see the next background color."); > else > { > move(LINES-3, 0); > clrtoeol(); > mvprintw(LINES-3, 15, "That's it! Press any key to quit"); > } > > refresh(); > getch(); >} >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 882185
: 654931