handles.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. using System.Runtime.InteropServices;
  30. namespace Unix.Terminal {
  31. public partial class Curses {
  32. #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
  33. public class Window {
  34. public readonly IntPtr Handle;
  35. static Window curscr;
  36. static Window stdscr;
  37. static Window ()
  38. {
  39. Curses.initscr ();
  40. stdscr = new Window (Curses.console_sharp_get_stdscr ());
  41. curscr = new Window (Curses.console_sharp_get_curscr ());
  42. }
  43. internal Window (IntPtr handle)
  44. {
  45. Handle = handle;
  46. }
  47. static public Window Standard {
  48. get {
  49. return stdscr;
  50. }
  51. }
  52. static public Window Current {
  53. get {
  54. return curscr;
  55. }
  56. }
  57. public int wtimeout (int delay)
  58. {
  59. return Curses.wtimeout (Handle, delay);
  60. }
  61. public int notimeout (bool bf)
  62. {
  63. return Curses.notimeout (Handle, bf);
  64. }
  65. public int keypad (bool bf)
  66. {
  67. return Curses.keypad (Handle, bf);
  68. }
  69. public int meta (bool bf)
  70. {
  71. return Curses.meta (Handle, bf);
  72. }
  73. public int intrflush (bool bf)
  74. {
  75. return Curses.intrflush (Handle, bf);
  76. }
  77. public int clearok (bool bf)
  78. {
  79. return Curses.clearok (Handle, bf);
  80. }
  81. public int idlok (bool bf)
  82. {
  83. return Curses.idlok (Handle, bf);
  84. }
  85. public void idcok (bool bf)
  86. {
  87. Curses.idcok (Handle, bf);
  88. }
  89. public void immedok (bool bf)
  90. {
  91. Curses.immedok (Handle, bf);
  92. }
  93. public int leaveok (bool bf)
  94. {
  95. return Curses.leaveok (Handle, bf);
  96. }
  97. public int setscrreg (int top, int bot)
  98. {
  99. return Curses.wsetscrreg (Handle, top, bot);
  100. }
  101. public int scrollok (bool bf)
  102. {
  103. return Curses.scrollok (Handle, bf);
  104. }
  105. public int wrefresh ()
  106. {
  107. return Curses.wrefresh (Handle);
  108. }
  109. public int redrawwin ()
  110. {
  111. return Curses.redrawwin (Handle);
  112. }
  113. #if false
  114. public int wredrawwin (int beg_line, int num_lines)
  115. {
  116. return Curses.wredrawwin (Handle, beg_line, num_lines);
  117. }
  118. #endif
  119. public int wnoutrefresh ()
  120. {
  121. return Curses.wnoutrefresh (Handle);
  122. }
  123. public int move (int line, int col)
  124. {
  125. return Curses.wmove (Handle, line, col);
  126. }
  127. public int addch (char ch)
  128. {
  129. return Curses.waddch (Handle, ch);
  130. }
  131. public int refresh ()
  132. {
  133. return Curses.wrefresh (Handle);
  134. }
  135. }
  136. // Currently unused, to do later
  137. internal class Screen {
  138. public readonly IntPtr Handle;
  139. internal Screen (IntPtr handle)
  140. {
  141. Handle = handle;
  142. }
  143. }
  144. #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
  145. }
  146. }