handles.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // handles.cs: OO wrappers for some curses objects
  3. //
  4. // Authors:
  5. // Miguel de Icaza ([email protected])
  6. //
  7. // Copyright (C) 2007 Novell (http://www.novell.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. namespace Unix.Terminal {
  30. #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
  31. public partial class Curses {
  32. public class Window {
  33. public readonly IntPtr Handle;
  34. static Window curscr;
  35. static Window stdscr;
  36. static Window ()
  37. {
  38. Curses.initscr ();
  39. stdscr = new Window (Curses.console_sharp_get_stdscr ());
  40. curscr = new Window (Curses.console_sharp_get_curscr ());
  41. }
  42. internal Window (IntPtr handle)
  43. {
  44. Handle = handle;
  45. }
  46. static public Window Standard {
  47. get {
  48. return stdscr;
  49. }
  50. }
  51. static public Window Current {
  52. get {
  53. return curscr;
  54. }
  55. }
  56. public int wtimeout (int delay)
  57. {
  58. return Curses.wtimeout (Handle, delay);
  59. }
  60. public int notimeout (bool bf)
  61. {
  62. return Curses.notimeout (Handle, bf);
  63. }
  64. public int keypad (bool bf)
  65. {
  66. return Curses.keypad (Handle, bf);
  67. }
  68. public int meta (bool bf)
  69. {
  70. return Curses.meta (Handle, bf);
  71. }
  72. public int intrflush (bool bf)
  73. {
  74. return Curses.intrflush (Handle, bf);
  75. }
  76. public int clearok (bool bf)
  77. {
  78. return Curses.clearok (Handle, bf);
  79. }
  80. public int idlok (bool bf)
  81. {
  82. return Curses.idlok (Handle, bf);
  83. }
  84. public void idcok (bool bf)
  85. {
  86. Curses.idcok (Handle, bf);
  87. }
  88. public void immedok (bool bf)
  89. {
  90. Curses.immedok (Handle, bf);
  91. }
  92. public int leaveok (bool bf)
  93. {
  94. return Curses.leaveok (Handle, bf);
  95. }
  96. public int setscrreg (int top, int bot)
  97. {
  98. return Curses.wsetscrreg (Handle, top, bot);
  99. }
  100. public int scrollok (bool bf)
  101. {
  102. return Curses.scrollok (Handle, bf);
  103. }
  104. public int wrefresh ()
  105. {
  106. return Curses.wrefresh (Handle);
  107. }
  108. public int redrawwin ()
  109. {
  110. return Curses.redrawwin (Handle);
  111. }
  112. #if false
  113. public int wredrawwin (int beg_line, int num_lines)
  114. {
  115. return Curses.wredrawwin (Handle, beg_line, num_lines);
  116. }
  117. #endif
  118. public int wnoutrefresh ()
  119. {
  120. return Curses.wnoutrefresh (Handle);
  121. }
  122. public int move (int line, int col)
  123. {
  124. return Curses.wmove (Handle, line, col);
  125. }
  126. public int addch (char ch)
  127. {
  128. return Curses.waddch (Handle, ch);
  129. }
  130. public int refresh ()
  131. {
  132. return Curses.wrefresh (Handle);
  133. }
  134. }
  135. // Currently unused, to do later
  136. internal class Screen {
  137. public readonly IntPtr Handle;
  138. internal Screen (IntPtr handle)
  139. {
  140. Handle = handle;
  141. }
  142. }
  143. #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
  144. }
  145. }