Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

winattrs.c 2.8KB

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