You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

colour.c 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <curses.h>
  2. FILE_LICENCE ( GPL2_OR_LATER );
  3. struct colour_pair {
  4. short fcol;
  5. short bcol;
  6. };
  7. static struct colour_pair cpairs[COLOUR_PAIRS] = {
  8. [0] = { COLOUR_WHITE, COLOUR_BLACK },
  9. };
  10. /**
  11. * Identify the RGB components of a given colour value
  12. *
  13. * @v colour colour value
  14. * @v *red address to store red component
  15. * @v *green address to store green component
  16. * @v *blue address to store blue component
  17. * @ret rc return status code
  18. */
  19. int colour_content ( short colour, short *red, short *green, short *blue ) {
  20. *red = ( ( colour & COLOUR_RED ) ? 1 : 0 );
  21. *green = ( ( colour & COLOUR_GREEN ) ? 1 : 0 );
  22. *blue = ( ( colour & COLOUR_BLUE ) ? 1 : 0 );
  23. return OK;
  24. }
  25. /**
  26. * Initialise colour pair
  27. *
  28. * @v pair colour pair number
  29. * @v fcol foreground colour
  30. * @v bcol background colour
  31. */
  32. int init_pair ( short pair, short fcol, short bcol ) {
  33. struct colour_pair *cpair;
  34. if ( ( pair < 1 ) || ( pair >= COLOUR_PAIRS ) )
  35. return ERR;
  36. cpair = &cpairs[pair];
  37. cpair->fcol = fcol;
  38. cpair->bcol = bcol;
  39. return OK;
  40. }
  41. /**
  42. * Get colours of colour pair
  43. *
  44. * @v pair colour pair number
  45. * @ret fcol foreground colour
  46. * @ret bcol background colour
  47. */
  48. int pair_content ( short pair, short *fcol, short *bcol ) {
  49. struct colour_pair *cpair;
  50. if ( ( pair < 0 ) || ( pair >= COLOUR_PAIRS ) )
  51. return ERR;
  52. cpair = &cpairs[pair];
  53. *fcol = cpair->fcol;
  54. *bcol = cpair->bcol;
  55. return OK;
  56. }