ncurses2-test_sgr_attributes.adb 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. ------------------------------------------------------------------------------
  2. -- --
  3. -- GNAT ncurses Binding Samples --
  4. -- --
  5. -- ncurses --
  6. -- --
  7. -- B O D Y --
  8. -- --
  9. ------------------------------------------------------------------------------
  10. -- Copyright (c) 2000,2006 Free Software Foundation, Inc. --
  11. -- --
  12. -- Permission is hereby granted, free of charge, to any person obtaining a --
  13. -- copy of this software and associated documentation files (the --
  14. -- "Software"), to deal in the Software without restriction, including --
  15. -- without limitation the rights to use, copy, modify, merge, publish, --
  16. -- distribute, distribute with modifications, sublicense, and/or sell --
  17. -- copies of the Software, and to permit persons to whom the Software is --
  18. -- furnished to do so, subject to the following conditions: --
  19. -- --
  20. -- The above copyright notice and this permission notice shall be included --
  21. -- in all copies or substantial portions of the Software. --
  22. -- --
  23. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
  24. -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
  25. -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
  26. -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
  27. -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
  28. -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
  29. -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
  30. -- --
  31. -- Except as contained in this notice, the name(s) of the above copyright --
  32. -- holders shall not be used in advertising or otherwise to promote the --
  33. -- sale, use or other dealings in this Software without prior written --
  34. -- authorization. --
  35. ------------------------------------------------------------------------------
  36. -- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
  37. -- Version Control
  38. -- $Revision: 1.2 $
  39. -- $Date: 2006/06/25 14:24:40 $
  40. -- Binding Version 01.00
  41. ------------------------------------------------------------------------------
  42. with Terminal_Interface.Curses; use Terminal_Interface.Curses;
  43. with ncurses2.util; use ncurses2.util;
  44. -- Graphic-rendition test (adapted from vttest)
  45. procedure ncurses2.test_sgr_attributes is
  46. procedure xAdd (l : Line_Position; c : Column_Position; s : String);
  47. procedure xAdd (l : Line_Position; c : Column_Position; s : String) is
  48. begin
  49. Add (Line => l, Column => c, Str => s);
  50. end xAdd;
  51. normal, current : Attributed_Character;
  52. begin
  53. for pass in reverse Boolean loop
  54. if pass then
  55. normal := (Ch => ' ', Attr => Normal_Video, Color => 0);
  56. else
  57. normal := (Ch => ' ', Attr =>
  58. (Reverse_Video => True, others => False), Color => 0);
  59. end if;
  60. -- Use non-default colors if possible to exercise bce a little
  61. if Has_Colors then
  62. Init_Pair (1, White, Blue);
  63. normal.Color := 1;
  64. end if;
  65. Set_Background (Ch => normal);
  66. Erase;
  67. xAdd (1, 20, "Graphic rendition test pattern:");
  68. xAdd (4, 1, "vanilla");
  69. current := normal;
  70. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  71. Set_Background (Ch => current);
  72. xAdd (4, 40, "bold");
  73. current := normal;
  74. current.Attr.Under_Line := not current.Attr.Under_Line;
  75. Set_Background (Ch => current);
  76. xAdd (6, 6, "underline");
  77. current := normal;
  78. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  79. current.Attr.Under_Line := not current.Attr.Under_Line;
  80. Set_Background (Ch => current);
  81. xAdd (6, 45, "bold underline");
  82. current := normal;
  83. current.Attr.Blink := not current.Attr.Blink;
  84. Set_Background (Ch => current);
  85. xAdd (8, 1, "blink");
  86. current := normal;
  87. current.Attr.Blink := not current.Attr.Blink;
  88. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  89. Set_Background (Ch => current);
  90. xAdd (8, 40, "bold blink");
  91. current := normal;
  92. current.Attr.Under_Line := not current.Attr.Under_Line;
  93. current.Attr.Blink := not current.Attr.Blink;
  94. Set_Background (Ch => current);
  95. xAdd (10, 6, "underline blink");
  96. current := normal;
  97. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  98. current.Attr.Under_Line := not current.Attr.Under_Line;
  99. current.Attr.Blink := not current.Attr.Blink;
  100. Set_Background (Ch => current);
  101. xAdd (10, 45, "bold underline blink");
  102. current := normal;
  103. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  104. Set_Background (Ch => current);
  105. xAdd (12, 1, "negative");
  106. current := normal;
  107. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  108. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  109. Set_Background (Ch => current);
  110. xAdd (12, 40, "bold negative");
  111. current := normal;
  112. current.Attr.Under_Line := not current.Attr.Under_Line;
  113. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  114. Set_Background (Ch => current);
  115. xAdd (14, 6, "underline negative");
  116. current := normal;
  117. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  118. current.Attr.Under_Line := not current.Attr.Under_Line;
  119. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  120. Set_Background (Ch => current);
  121. xAdd (14, 45, "bold underline negative");
  122. current := normal;
  123. current.Attr.Blink := not current.Attr.Blink;
  124. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  125. Set_Background (Ch => current);
  126. xAdd (16, 1, "blink negative");
  127. current := normal;
  128. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  129. current.Attr.Blink := not current.Attr.Blink;
  130. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  131. Set_Background (Ch => current);
  132. xAdd (16, 40, "bold blink negative");
  133. current := normal;
  134. current.Attr.Under_Line := not current.Attr.Under_Line;
  135. current.Attr.Blink := not current.Attr.Blink;
  136. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  137. Set_Background (Ch => current);
  138. xAdd (18, 6, "underline blink negative");
  139. current := normal;
  140. current.Attr.Bold_Character := not current.Attr.Bold_Character;
  141. current.Attr.Under_Line := not current.Attr.Under_Line;
  142. current.Attr.Blink := not current.Attr.Blink;
  143. current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
  144. Set_Background (Ch => current);
  145. xAdd (18, 45, "bold underline blink negative");
  146. Set_Background (Ch => normal);
  147. Move_Cursor (Line => Lines - 2, Column => 1);
  148. if pass then
  149. Add (Str => "Dark");
  150. else
  151. Add (Str => "Light");
  152. end if;
  153. Add (Str => " background. ");
  154. Clear_To_End_Of_Line;
  155. Pause;
  156. end loop;
  157. Set_Background (Ch => Blank2);
  158. Erase;
  159. End_Windows;
  160. end ncurses2.test_sgr_attributes;