sample-curses_demo-attributes.adb 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ------------------------------------------------------------------------------
  2. -- --
  3. -- GNAT ncurses Binding Samples --
  4. -- --
  5. -- Sample.Curses_Demo.Attributes --
  6. -- --
  7. -- B O D Y --
  8. -- --
  9. ------------------------------------------------------------------------------
  10. -- Copyright (c) 1998 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: Juergen Pfeifer, 1996
  37. -- Version Control
  38. -- $Revision: 1.12 $
  39. -- Binding Version 01.00
  40. ------------------------------------------------------------------------------
  41. with Terminal_Interface.Curses; use Terminal_Interface.Curses;
  42. with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels;
  43. with Sample.Manifest; use Sample.Manifest;
  44. with Sample.Function_Key_Setting; use Sample.Function_Key_Setting;
  45. with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
  46. with Sample.Explanation; use Sample.Explanation;
  47. package body Sample.Curses_Demo.Attributes is
  48. procedure Demo
  49. is
  50. P : Panel := Create (Standard_Window);
  51. K : Real_Key_Code;
  52. begin
  53. Set_Meta_Mode;
  54. Set_KeyPad_Mode;
  55. Top (P);
  56. Push_Environment ("ATTRIBDEMO");
  57. Default_Labels;
  58. Notepad ("ATTRIB-PAD00");
  59. Set_Character_Attributes (Attr => (others => False));
  60. Add (Line => 1, Column => Columns / 2 - 10,
  61. Str => "This is NORMAL");
  62. Set_Character_Attributes (Attr => (Stand_Out => True,
  63. others => False));
  64. Add (Line => 2, Column => Columns / 2 - 10,
  65. Str => "This is Stand_Out");
  66. Set_Character_Attributes (Attr => (Under_Line => True,
  67. others => False));
  68. Add (Line => 3, Column => Columns / 2 - 10,
  69. Str => "This is Under_Line");
  70. Set_Character_Attributes (Attr => (Reverse_Video => True,
  71. others => False));
  72. Add (Line => 4, Column => Columns / 2 - 10,
  73. Str => "This is Reverse_Video");
  74. Set_Character_Attributes (Attr => (Blink => True,
  75. others => False));
  76. Add (Line => 5, Column => Columns / 2 - 10,
  77. Str => "This is Blink");
  78. Set_Character_Attributes (Attr => (Dim_Character => True,
  79. others => False));
  80. Add (Line => 6, Column => Columns / 2 - 10,
  81. Str => "This is Dim_Character");
  82. Set_Character_Attributes (Attr => (Bold_Character => True,
  83. others => False));
  84. Add (Line => 7, Column => Columns / 2 - 10,
  85. Str => "This is Bold_Character");
  86. Refresh_Without_Update;
  87. Update_Panels; Update_Screen;
  88. loop
  89. K := Get_Key;
  90. if K in Special_Key_Code'Range then
  91. case K is
  92. when QUIT_CODE => exit;
  93. when HELP_CODE => Explain_Context;
  94. when EXPLAIN_CODE => Explain ("ATTRIBKEYS");
  95. when others => null;
  96. end case;
  97. end if;
  98. end loop;
  99. Pop_Environment;
  100. Clear;
  101. Refresh_Without_Update;
  102. Delete (P);
  103. Update_Panels; Update_Screen;
  104. end Demo;
  105. end Sample.Curses_Demo.Attributes;