MockConsoleDriver.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #nullable enable
  2. using System.Text;
  3. using Terminal.Gui;
  4. using Attribute = Terminal.Gui.Attribute;
  5. using Color = Terminal.Gui.Color;
  6. internal class MockConsoleDriver : IConsoleDriver
  7. {
  8. public event EventHandler<Attribute>? AttributeSet;
  9. private IClipboard? _clipboard;
  10. private Rectangle _screen;
  11. private Region? _clip;
  12. private int _col;
  13. private int _cols;
  14. private Cell [,]? _contents;
  15. private int _left;
  16. private int _row;
  17. private int _rows;
  18. private int _top;
  19. private bool _supportsTrueColor;
  20. private bool _force16Colors;
  21. private Attribute _currentAttribute;
  22. /// <inheritdoc />
  23. public IClipboard? Clipboard => _clipboard;
  24. /// <inheritdoc />
  25. public Rectangle Screen => _screen;
  26. /// <inheritdoc />
  27. public Region? Clip
  28. {
  29. get => _clip;
  30. set => _clip = value;
  31. }
  32. /// <inheritdoc />
  33. public int Col => _col;
  34. /// <inheritdoc />
  35. public int Cols
  36. {
  37. get => _cols;
  38. set => _cols = value;
  39. }
  40. /// <inheritdoc />
  41. public Cell [,]? Contents
  42. {
  43. get => _contents;
  44. set => _contents = value;
  45. }
  46. /// <inheritdoc />
  47. public int Left
  48. {
  49. get => _left;
  50. set => _left = value;
  51. }
  52. /// <inheritdoc />
  53. public int Row => _row;
  54. /// <inheritdoc />
  55. public int Rows
  56. {
  57. get => _rows;
  58. set => _rows = value;
  59. }
  60. /// <inheritdoc />
  61. public int Top
  62. {
  63. get => _top;
  64. set => _top = value;
  65. }
  66. /// <inheritdoc />
  67. public bool SupportsTrueColor => _supportsTrueColor;
  68. /// <inheritdoc />
  69. public bool Force16Colors
  70. {
  71. get => _force16Colors;
  72. set => _force16Colors = value;
  73. }
  74. /// <inheritdoc />
  75. public Attribute CurrentAttribute
  76. {
  77. get => _currentAttribute;
  78. set => _currentAttribute = value;
  79. }
  80. /// <inheritdoc />
  81. public string GetVersionInfo () { return string.Empty; }
  82. /// <inheritdoc />
  83. public void WriteRaw (string ansi) { }
  84. /// <inheritdoc />
  85. public bool IsRuneSupported (Rune rune) { return true; }
  86. /// <inheritdoc />
  87. public bool IsValidLocation (Rune rune, int col, int row) { return true; }
  88. /// <inheritdoc />
  89. public void Move (int col, int row)
  90. {
  91. _col = col;
  92. _row = row;
  93. }
  94. /// <inheritdoc />
  95. public void AddRune (Rune rune) { }
  96. /// <inheritdoc />
  97. public void AddRune (char c) { }
  98. /// <inheritdoc />
  99. public void AddStr (string str) { }
  100. /// <inheritdoc />
  101. public void ClearContents () { }
  102. /// <inheritdoc />
  103. public event EventHandler<EventArgs>? ClearedContents;
  104. /// <inheritdoc />
  105. public void FillRect (Rectangle rect, Rune rune = default) { }
  106. /// <inheritdoc />
  107. public void FillRect (Rectangle rect, char c) { }
  108. /// <inheritdoc />
  109. public bool GetCursorVisibility (out CursorVisibility visibility)
  110. {
  111. visibility = CursorVisibility.Invisible;
  112. return false;
  113. }
  114. /// <inheritdoc />
  115. public void Refresh () { }
  116. /// <inheritdoc />
  117. public bool SetCursorVisibility (CursorVisibility visibility) { throw new NotImplementedException (); }
  118. /// <inheritdoc />
  119. public event EventHandler<SizeChangedEventArgs>? SizeChanged;
  120. /// <inheritdoc />
  121. public void Suspend () { }
  122. /// <inheritdoc />
  123. public void UpdateCursor () {}
  124. /// <inheritdoc />
  125. public MainLoop Init () { return null!; }
  126. /// <inheritdoc />
  127. public void End () { }
  128. /// <inheritdoc />
  129. /// <inheritdoc />
  130. public Attribute SetAttribute (Attribute c)
  131. {
  132. Attribute oldAttribute = _currentAttribute;
  133. _currentAttribute = c;
  134. AttributeSet?.Invoke (this, c);
  135. return oldAttribute;
  136. }
  137. /// <inheritdoc />
  138. public Attribute GetAttribute ()
  139. {
  140. return _currentAttribute;
  141. }
  142. /// <inheritdoc />
  143. public Attribute MakeColor (in Color foreground, in Color background) { throw new NotImplementedException (); }
  144. /// <inheritdoc />
  145. public event EventHandler<MouseEventArgs>? MouseEvent;
  146. /// <inheritdoc />
  147. public event EventHandler<Key>? KeyDown;
  148. /// <inheritdoc />
  149. public event EventHandler<Key>? KeyUp;
  150. /// <inheritdoc />
  151. public void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool ctrl) { throw new NotImplementedException (); }
  152. /// <inheritdoc />
  153. public void QueueAnsiRequest (AnsiEscapeSequenceRequest request) { throw new NotImplementedException (); }
  154. /// <inheritdoc />
  155. public AnsiRequestScheduler GetRequestScheduler () { throw new NotImplementedException (); }
  156. }