MockConsoleDriver.cs 4.5 KB

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