Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #include <curses.h>
  2. /** @file
  3. *
  4. * MuCurses window attribute functions
  5. *
  6. */
  7. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  8. /**
  9. * Get the background rendition attributes for a window
  10. *
  11. * @v *win subject window
  12. * @ret ch chtype rendition representation
  13. */
  14. inline chtype getbkgd ( WINDOW *win ) {
  15. return win->attrs;
  16. }
  17. /**
  18. * Turn off attributes in a window
  19. *
  20. * @v win subject window
  21. * @v attrs attributes to enable
  22. * @ret rc return status code
  23. */
  24. int wattroff ( WINDOW *win, int attrs ) {
  25. win->attrs &= ~attrs;
  26. return OK;
  27. }
  28. /**
  29. * Turn on attributes in a window
  30. *
  31. * @v win subject window
  32. * @v attrs attributes to enable
  33. * @ret rc return status code
  34. */
  35. int wattron ( WINDOW *win, int attrs ) {
  36. win->attrs |= attrs;
  37. return OK;
  38. }
  39. /**
  40. * Set attributes in a window
  41. *
  42. * @v win subject window
  43. * @v attrs attributes to enable
  44. * @ret rc return status code
  45. */
  46. int wattrset ( WINDOW *win, int attrs ) {
  47. win->attrs = ( attrs | ( win->attrs & A_COLOR ) );
  48. return OK;
  49. }
  50. /**
  51. * Get attributes and colour pair information
  52. *
  53. * @v *win window to obtain information from
  54. * @v *attrs address in which to store attributes
  55. * @v *pair address in which to store colour pair
  56. * @v *opts undefined (for future implementation)
  57. * @ret rc return status cude
  58. */
  59. int wattr_get ( WINDOW *win, attr_t *attrs, short *pair,
  60. void *opts __unused ) {
  61. *attrs = win->attrs & A_ATTRIBUTES;
  62. *pair = PAIR_NUMBER ( win->attrs );
  63. return OK;
  64. }
  65. /**
  66. * Turn off attributes in a window
  67. *
  68. * @v *win subject window
  69. * @v attrs attributes to toggle
  70. * @v *opts undefined (for future implementation)
  71. * @ret rc return status code
  72. */
  73. int wattr_off ( WINDOW *win, attr_t attrs,
  74. void *opts __unused ) {
  75. wattroff( win, attrs );
  76. return OK;
  77. }
  78. /**
  79. * Turn on attributes in a window
  80. *
  81. * @v *win subject window
  82. * @v attrs attributes to toggle
  83. * @v *opts undefined (for future implementation)
  84. * @ret rc return status code
  85. */
  86. int wattr_on ( WINDOW *win, attr_t attrs,
  87. void *opts __unused ) {
  88. wattron( win, attrs );
  89. return OK;
  90. }
  91. /**
  92. * Set attributes and colour pair information in a window
  93. *
  94. * @v *win subject window
  95. * @v attrs attributes to set
  96. * @v cpair colour pair to set
  97. * @v *opts undefined (for future implementation)
  98. * @ret rc return status code
  99. */
  100. int wattr_set ( WINDOW *win, attr_t attrs, short cpair,
  101. void *opts __unused ) {
  102. wattrset( win, attrs | COLOUR_PAIR ( cpair ) );
  103. return OK;
  104. }
  105. /**
  106. * Set colour pair for a window
  107. *
  108. * @v *win subject window
  109. * @v colour_pair_number colour pair integer
  110. * @v *opts undefined (for future implementation)
  111. * @ret rc return status code
  112. */
  113. int wcolour_set ( WINDOW *win, short colour_pair_number,
  114. void *opts __unused ) {
  115. if ( ( unsigned short )colour_pair_number > COLOUR_PAIRS )
  116. return ERR;
  117. win->attrs = ( ( win->attrs & A_ATTRIBUTES ) |
  118. COLOUR_PAIR ( colour_pair_number ) );
  119. return OK;
  120. }