FakeDriver.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. //
  2. // FakeDriver.cs: A fake ConsoleDriver for unit tests.
  3. //
  4. // Authors:
  5. // Charlie Kindel (github.com/tig)
  6. //
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Runtime.InteropServices;
  11. using System.Threading;
  12. using NStack;
  13. // Alias Console to MockConsole so we don't accidentally use Console
  14. using Console = Terminal.Gui.FakeConsole;
  15. namespace Terminal.Gui {
  16. /// <summary>
  17. /// Implements a mock ConsoleDriver for unit testing
  18. /// </summary>
  19. public class FakeDriver : ConsoleDriver {
  20. #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
  21. int cols, rows, left, top;
  22. public override int Cols => cols;
  23. public override int Rows => rows;
  24. // Only handling left here because not all terminals has a horizontal scroll bar.
  25. public override int Left => 0;
  26. public override int Top => 0;
  27. public override bool HeightAsBuffer { get; set; }
  28. public override IClipboard Clipboard { get; }
  29. // The format is rows, columns and 3 values on the last column: Rune, Attribute and Dirty Flag
  30. int [,,] contents;
  31. bool [] dirtyLine;
  32. /// <summary>
  33. /// Assists with testing, the format is rows, columns and 3 values on the last column: Rune, Attribute and Dirty Flag
  34. /// </summary>
  35. internal override int [,,] Contents => contents;
  36. void UpdateOffscreen ()
  37. {
  38. int cols = Cols;
  39. int rows = Rows;
  40. contents = new int [rows, cols, 3];
  41. for (int r = 0; r < rows; r++) {
  42. for (int c = 0; c < cols; c++) {
  43. contents [r, c, 0] = ' ';
  44. contents [r, c, 1] = MakeColor (ConsoleColor.Gray, ConsoleColor.Black);
  45. contents [r, c, 2] = 0;
  46. }
  47. }
  48. dirtyLine = new bool [rows];
  49. for (int row = 0; row < rows; row++)
  50. dirtyLine [row] = true;
  51. }
  52. static bool sync = false;
  53. public FakeDriver ()
  54. {
  55. if (RuntimeInformation.IsOSPlatform (OSPlatform.Windows)) {
  56. Clipboard = new WindowsClipboard ();
  57. } else if (RuntimeInformation.IsOSPlatform (OSPlatform.OSX)) {
  58. Clipboard = new MacOSXClipboard ();
  59. } else {
  60. if (CursesDriver.Is_WSL_Platform ()) {
  61. Clipboard = new WSLClipboard ();
  62. } else {
  63. Clipboard = new CursesClipboard ();
  64. }
  65. }
  66. }
  67. bool needMove;
  68. // Current row, and current col, tracked by Move/AddCh only
  69. int ccol, crow;
  70. public override void Move (int col, int row)
  71. {
  72. ccol = col;
  73. crow = row;
  74. if (Clip.Contains (col, row)) {
  75. FakeConsole.CursorTop = row;
  76. FakeConsole.CursorLeft = col;
  77. needMove = false;
  78. } else {
  79. FakeConsole.CursorTop = Clip.Y;
  80. FakeConsole.CursorLeft = Clip.X;
  81. needMove = true;
  82. }
  83. }
  84. public override void AddRune (Rune rune)
  85. {
  86. rune = MakePrintable (rune);
  87. if (Clip.Contains (ccol, crow)) {
  88. if (needMove) {
  89. //MockConsole.CursorLeft = ccol;
  90. //MockConsole.CursorTop = crow;
  91. needMove = false;
  92. }
  93. contents [crow, ccol, 0] = (int)(uint)rune;
  94. contents [crow, ccol, 1] = currentAttribute;
  95. contents [crow, ccol, 2] = 1;
  96. dirtyLine [crow] = true;
  97. } else
  98. needMove = true;
  99. ccol++;
  100. //if (ccol == Cols) {
  101. // ccol = 0;
  102. // if (crow + 1 < Rows)
  103. // crow++;
  104. //}
  105. if (sync)
  106. UpdateScreen ();
  107. }
  108. public override void AddStr (ustring str)
  109. {
  110. foreach (var rune in str)
  111. AddRune (rune);
  112. }
  113. public override void End ()
  114. {
  115. FakeConsole.ResetColor ();
  116. FakeConsole.Clear ();
  117. }
  118. static Attribute MakeColor (ConsoleColor f, ConsoleColor b)
  119. {
  120. // Encode the colors into the int value.
  121. return new Attribute (
  122. value: ((((int)f) & 0xffff) << 16) | (((int)b) & 0xffff),
  123. foreground: (Color)f,
  124. background: (Color)b
  125. );
  126. }
  127. public override void Init (Action terminalResized)
  128. {
  129. TerminalResized = terminalResized;
  130. cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;
  131. rows = FakeConsole.WindowHeight = FakeConsole.BufferHeight = FakeConsole.HEIGHT;
  132. FakeConsole.Clear ();
  133. ResizeScreen ();
  134. UpdateOffScreen ();
  135. Colors.TopLevel = new ColorScheme ();
  136. Colors.Base = new ColorScheme ();
  137. Colors.Dialog = new ColorScheme ();
  138. Colors.Menu = new ColorScheme ();
  139. Colors.Error = new ColorScheme ();
  140. Clip = new Rect (0, 0, Cols, Rows);
  141. Colors.TopLevel.Normal = MakeColor (ConsoleColor.Green, ConsoleColor.Black);
  142. Colors.TopLevel.Focus = MakeColor (ConsoleColor.White, ConsoleColor.DarkCyan);
  143. Colors.TopLevel.HotNormal = MakeColor (ConsoleColor.DarkYellow, ConsoleColor.Black);
  144. Colors.TopLevel.HotFocus = MakeColor (ConsoleColor.DarkBlue, ConsoleColor.DarkCyan);
  145. Colors.TopLevel.Disabled = MakeColor (ConsoleColor.DarkGray, ConsoleColor.Black);
  146. Colors.Base.Normal = MakeColor (ConsoleColor.White, ConsoleColor.Blue);
  147. Colors.Base.Focus = MakeColor (ConsoleColor.Black, ConsoleColor.Cyan);
  148. Colors.Base.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Blue);
  149. Colors.Base.HotFocus = MakeColor (ConsoleColor.Yellow, ConsoleColor.Cyan);
  150. Colors.Base.Disabled = MakeColor (ConsoleColor.DarkGray, ConsoleColor.DarkBlue);
  151. // Focused,
  152. // Selected, Hot: Yellow on Black
  153. // Selected, text: white on black
  154. // Unselected, hot: yellow on cyan
  155. // unselected, text: same as unfocused
  156. Colors.Menu.HotFocus = MakeColor (ConsoleColor.Yellow, ConsoleColor.Black);
  157. Colors.Menu.Focus = MakeColor (ConsoleColor.White, ConsoleColor.Black);
  158. Colors.Menu.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Cyan);
  159. Colors.Menu.Normal = MakeColor (ConsoleColor.White, ConsoleColor.Cyan);
  160. Colors.Menu.Disabled = MakeColor (ConsoleColor.DarkGray, ConsoleColor.Cyan);
  161. Colors.Dialog.Normal = MakeColor (ConsoleColor.Black, ConsoleColor.Gray);
  162. Colors.Dialog.Focus = MakeColor (ConsoleColor.Black, ConsoleColor.Cyan);
  163. Colors.Dialog.HotNormal = MakeColor (ConsoleColor.Blue, ConsoleColor.Gray);
  164. Colors.Dialog.HotFocus = MakeColor (ConsoleColor.Blue, ConsoleColor.Cyan);
  165. Colors.Dialog.Disabled = MakeColor (ConsoleColor.DarkGray, ConsoleColor.Gray);
  166. Colors.Error.Normal = MakeColor (ConsoleColor.White, ConsoleColor.Red);
  167. Colors.Error.Focus = MakeColor (ConsoleColor.Black, ConsoleColor.Gray);
  168. Colors.Error.HotNormal = MakeColor (ConsoleColor.Yellow, ConsoleColor.Red);
  169. Colors.Error.HotFocus = Colors.Error.HotNormal;
  170. Colors.Error.Disabled = MakeColor (ConsoleColor.DarkGray, ConsoleColor.White);
  171. //MockConsole.Clear ();
  172. }
  173. public override Attribute MakeAttribute (Color fore, Color back)
  174. {
  175. return MakeColor ((ConsoleColor)fore, (ConsoleColor)back);
  176. }
  177. int redrawColor = -1;
  178. void SetColor (int color)
  179. {
  180. redrawColor = color;
  181. IEnumerable<int> values = Enum.GetValues (typeof (ConsoleColor))
  182. .OfType<ConsoleColor> ()
  183. .Select (s => (int)s);
  184. if (values.Contains (color & 0xffff)) {
  185. FakeConsole.BackgroundColor = (ConsoleColor)(color & 0xffff);
  186. }
  187. if (values.Contains ((color >> 16) & 0xffff)) {
  188. FakeConsole.ForegroundColor = (ConsoleColor)((color >> 16) & 0xffff);
  189. }
  190. }
  191. public override void UpdateScreen ()
  192. {
  193. int top = Top;
  194. int left = Left;
  195. int rows = Math.Min (Console.WindowHeight + top, Rows);
  196. int cols = Cols;
  197. FakeConsole.CursorTop = 0;
  198. FakeConsole.CursorLeft = 0;
  199. for (int row = top; row < rows; row++) {
  200. dirtyLine [row] = false;
  201. for (int col = left; col < cols; col++) {
  202. contents [row, col, 2] = 0;
  203. var color = contents [row, col, 1];
  204. if (color != redrawColor)
  205. SetColor (color);
  206. FakeConsole.Write ((char)contents [row, col, 0]);
  207. }
  208. }
  209. }
  210. public override void Refresh ()
  211. {
  212. int rows = Rows;
  213. int cols = Cols;
  214. var savedRow = FakeConsole.CursorTop;
  215. var savedCol = FakeConsole.CursorLeft;
  216. for (int row = 0; row < rows; row++) {
  217. if (!dirtyLine [row])
  218. continue;
  219. dirtyLine [row] = false;
  220. for (int col = 0; col < cols; col++) {
  221. if (contents [row, col, 2] != 1)
  222. continue;
  223. FakeConsole.CursorTop = row;
  224. FakeConsole.CursorLeft = col;
  225. for (; col < cols && contents [row, col, 2] == 1; col++) {
  226. var color = contents [row, col, 1];
  227. if (color != redrawColor)
  228. SetColor (color);
  229. FakeConsole.Write ((char)contents [row, col, 0]);
  230. contents [row, col, 2] = 0;
  231. }
  232. }
  233. }
  234. FakeConsole.CursorTop = savedRow;
  235. FakeConsole.CursorLeft = savedCol;
  236. }
  237. Attribute currentAttribute;
  238. public override void SetAttribute (Attribute c)
  239. {
  240. currentAttribute = c;
  241. }
  242. Key MapKey (ConsoleKeyInfo keyInfo)
  243. {
  244. switch (keyInfo.Key) {
  245. case ConsoleKey.Escape:
  246. return MapKeyModifiers (keyInfo, Key.Esc);
  247. case ConsoleKey.Tab:
  248. return keyInfo.Modifiers == ConsoleModifiers.Shift ? Key.BackTab : Key.Tab;
  249. case ConsoleKey.Home:
  250. return MapKeyModifiers (keyInfo, Key.Home);
  251. case ConsoleKey.End:
  252. return MapKeyModifiers (keyInfo, Key.End);
  253. case ConsoleKey.LeftArrow:
  254. return MapKeyModifiers (keyInfo, Key.CursorLeft);
  255. case ConsoleKey.RightArrow:
  256. return MapKeyModifiers (keyInfo, Key.CursorRight);
  257. case ConsoleKey.UpArrow:
  258. return MapKeyModifiers (keyInfo, Key.CursorUp);
  259. case ConsoleKey.DownArrow:
  260. return MapKeyModifiers (keyInfo, Key.CursorDown);
  261. case ConsoleKey.PageUp:
  262. return MapKeyModifiers (keyInfo, Key.PageUp);
  263. case ConsoleKey.PageDown:
  264. return MapKeyModifiers (keyInfo, Key.PageDown);
  265. case ConsoleKey.Enter:
  266. return MapKeyModifiers (keyInfo, Key.Enter);
  267. case ConsoleKey.Spacebar:
  268. return MapKeyModifiers (keyInfo, keyInfo.KeyChar == 0 ? Key.Space : (Key)keyInfo.KeyChar);
  269. case ConsoleKey.Backspace:
  270. return MapKeyModifiers (keyInfo, Key.Backspace);
  271. case ConsoleKey.Delete:
  272. return MapKeyModifiers (keyInfo, Key.DeleteChar);
  273. case ConsoleKey.Insert:
  274. return MapKeyModifiers (keyInfo, Key.InsertChar);
  275. case ConsoleKey.Oem1:
  276. case ConsoleKey.Oem2:
  277. case ConsoleKey.Oem3:
  278. case ConsoleKey.Oem4:
  279. case ConsoleKey.Oem5:
  280. case ConsoleKey.Oem6:
  281. case ConsoleKey.Oem7:
  282. case ConsoleKey.Oem8:
  283. case ConsoleKey.Oem102:
  284. case ConsoleKey.OemPeriod:
  285. case ConsoleKey.OemComma:
  286. case ConsoleKey.OemPlus:
  287. case ConsoleKey.OemMinus:
  288. if (keyInfo.KeyChar == 0)
  289. return Key.Unknown;
  290. return (Key)((uint)keyInfo.KeyChar);
  291. }
  292. var key = keyInfo.Key;
  293. if (key >= ConsoleKey.A && key <= ConsoleKey.Z) {
  294. var delta = key - ConsoleKey.A;
  295. if (keyInfo.Modifiers == ConsoleModifiers.Control) {
  296. return (Key)(((uint)Key.CtrlMask) | ((uint)Key.A + delta));
  297. }
  298. if (keyInfo.Modifiers == ConsoleModifiers.Alt) {
  299. return (Key)(((uint)Key.AltMask) | ((uint)Key.A + delta));
  300. }
  301. if ((keyInfo.Modifiers & (ConsoleModifiers.Alt | ConsoleModifiers.Control)) != 0) {
  302. if (keyInfo.KeyChar == 0) {
  303. return (Key)(((uint)Key.AltMask | (uint)Key.CtrlMask) | ((uint)Key.A + delta));
  304. } else {
  305. return (Key)((uint)keyInfo.KeyChar);
  306. }
  307. }
  308. return (Key)((uint)keyInfo.KeyChar);
  309. }
  310. if (key >= ConsoleKey.D0 && key <= ConsoleKey.D9) {
  311. var delta = key - ConsoleKey.D0;
  312. if (keyInfo.Modifiers == ConsoleModifiers.Alt) {
  313. return (Key)(((uint)Key.AltMask) | ((uint)Key.D0 + delta));
  314. }
  315. if (keyInfo.Modifiers == ConsoleModifiers.Control) {
  316. return (Key)(((uint)Key.CtrlMask) | ((uint)Key.D0 + delta));
  317. }
  318. if (keyInfo.KeyChar == 0 || keyInfo.KeyChar == 30) {
  319. return MapKeyModifiers (keyInfo, (Key)((uint)Key.D0 + delta));
  320. }
  321. return (Key)((uint)keyInfo.KeyChar);
  322. }
  323. if (key >= ConsoleKey.F1 && key <= ConsoleKey.F12) {
  324. var delta = key - ConsoleKey.F1;
  325. if ((keyInfo.Modifiers & (ConsoleModifiers.Shift | ConsoleModifiers.Alt | ConsoleModifiers.Control)) != 0) {
  326. return MapKeyModifiers (keyInfo, (Key)((uint)Key.F1 + delta));
  327. }
  328. return (Key)((uint)Key.F1 + delta);
  329. }
  330. if (keyInfo.KeyChar != 0) {
  331. return MapKeyModifiers (keyInfo, (Key)((uint)keyInfo.KeyChar));
  332. }
  333. return (Key)(0xffffffff);
  334. }
  335. KeyModifiers keyModifiers;
  336. private Key MapKeyModifiers (ConsoleKeyInfo keyInfo, Key key)
  337. {
  338. Key keyMod = new Key ();
  339. if ((keyInfo.Modifiers & ConsoleModifiers.Shift) != 0)
  340. keyMod = Key.ShiftMask;
  341. if ((keyInfo.Modifiers & ConsoleModifiers.Control) != 0)
  342. keyMod |= Key.CtrlMask;
  343. if ((keyInfo.Modifiers & ConsoleModifiers.Alt) != 0)
  344. keyMod |= Key.AltMask;
  345. return keyMod != Key.Null ? keyMod | key : key;
  346. }
  347. Action<KeyEvent> keyHandler;
  348. Action<KeyEvent> keyUpHandler;
  349. public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandler, Action<KeyEvent> keyDownHandler, Action<KeyEvent> keyUpHandler, Action<MouseEvent> mouseHandler)
  350. {
  351. this.keyHandler = keyHandler;
  352. this.keyUpHandler = keyUpHandler;
  353. // Note: Net doesn't support keydown/up events and thus any passed keyDown/UpHandlers will never be called
  354. (mainLoop.Driver as FakeMainLoop).KeyPressed += (consoleKey) => ProcessInput (consoleKey);
  355. }
  356. void ProcessInput (ConsoleKeyInfo consoleKey)
  357. {
  358. keyModifiers = new KeyModifiers ();
  359. var map = MapKey (consoleKey);
  360. if (map == (Key)0xffffffff)
  361. return;
  362. if (consoleKey.Modifiers.HasFlag (ConsoleModifiers.Alt)) {
  363. keyModifiers.Alt = true;
  364. }
  365. if (consoleKey.Modifiers.HasFlag (ConsoleModifiers.Shift)) {
  366. keyModifiers.Shift = true;
  367. }
  368. if (consoleKey.Modifiers.HasFlag (ConsoleModifiers.Control)) {
  369. keyModifiers.Ctrl = true;
  370. }
  371. keyHandler (new KeyEvent (map, keyModifiers));
  372. keyUpHandler (new KeyEvent (map, keyModifiers));
  373. }
  374. public override Attribute GetAttribute ()
  375. {
  376. return currentAttribute;
  377. }
  378. /// <inheritdoc/>
  379. public override bool GetCursorVisibility (out CursorVisibility visibility)
  380. {
  381. if (FakeConsole.CursorVisible) {
  382. visibility = CursorVisibility.Default;
  383. } else {
  384. visibility = CursorVisibility.Invisible;
  385. }
  386. return false;
  387. }
  388. /// <inheritdoc/>
  389. public override bool SetCursorVisibility (CursorVisibility visibility)
  390. {
  391. if (visibility == CursorVisibility.Invisible) {
  392. FakeConsole.CursorVisible = false;
  393. } else {
  394. FakeConsole.CursorVisible = true;
  395. }
  396. return false;
  397. }
  398. /// <inheritdoc/>
  399. public override bool EnsureCursorVisibility ()
  400. {
  401. return false;
  402. }
  403. public override void SendKeys (char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
  404. {
  405. ProcessInput (new ConsoleKeyInfo (keyChar, key, shift, alt, control));
  406. }
  407. public void SetBufferSize (int width, int height)
  408. {
  409. cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = width;
  410. rows = FakeConsole.WindowHeight = FakeConsole.BufferHeight = height;
  411. ProcessResize ();
  412. }
  413. public void SetWindowSize (int width, int height)
  414. {
  415. FakeConsole.WindowWidth = width;
  416. FakeConsole.WindowHeight = height;
  417. if (width > cols || !HeightAsBuffer) {
  418. cols = FakeConsole.BufferWidth = width;
  419. }
  420. if (height > rows || !HeightAsBuffer) {
  421. rows = FakeConsole.BufferHeight = height;
  422. }
  423. ProcessResize ();
  424. }
  425. public void SetWindowPosition (int left, int top)
  426. {
  427. if (HeightAsBuffer) {
  428. this.left = FakeConsole.WindowLeft = Math.Max (Math.Min (left, Cols - FakeConsole.WindowWidth), 0);
  429. this.top = FakeConsole.WindowTop = Math.Max (Math.Min (top, Rows - Console.WindowHeight), 0);
  430. } else if (this.left > 0 || this.top > 0) {
  431. this.left = FakeConsole.WindowLeft = 0;
  432. this.top = FakeConsole.WindowTop = 0;
  433. }
  434. }
  435. void ProcessResize ()
  436. {
  437. ResizeScreen ();
  438. UpdateOffScreen ();
  439. TerminalResized?.Invoke ();
  440. }
  441. void ResizeScreen ()
  442. {
  443. if (!HeightAsBuffer) {
  444. if (Console.WindowHeight > 0) {
  445. // Can raise an exception while is still resizing.
  446. try {
  447. #pragma warning disable CA1416
  448. Console.CursorTop = 0;
  449. Console.CursorLeft = 0;
  450. Console.WindowTop = 0;
  451. Console.WindowLeft = 0;
  452. #pragma warning restore CA1416
  453. } catch (System.IO.IOException) {
  454. return;
  455. } catch (ArgumentOutOfRangeException) {
  456. return;
  457. }
  458. }
  459. } else {
  460. try {
  461. #pragma warning disable CA1416
  462. Console.WindowLeft = Math.Max (Math.Min (left, Cols - Console.WindowWidth), 0);
  463. Console.WindowTop = Math.Max (Math.Min (top, Rows - Console.WindowHeight), 0);
  464. #pragma warning restore CA1416
  465. } catch (Exception) {
  466. return;
  467. }
  468. }
  469. Clip = new Rect (0, 0, Cols, Rows);
  470. contents = new int [Rows, Cols, 3];
  471. dirtyLine = new bool [Rows];
  472. }
  473. void UpdateOffScreen ()
  474. {
  475. // Can raise an exception while is still resizing.
  476. try {
  477. for (int row = 0; row < rows; row++) {
  478. for (int c = 0; c < cols; c++) {
  479. contents [row, c, 0] = ' ';
  480. contents [row, c, 1] = (ushort)Colors.TopLevel.Normal;
  481. contents [row, c, 2] = 0;
  482. dirtyLine [row] = true;
  483. }
  484. }
  485. } catch (IndexOutOfRangeException) { }
  486. }
  487. public override bool GetColors (int value, out Color foreground, out Color background)
  488. {
  489. bool hasColor = false;
  490. foreground = default;
  491. background = default;
  492. IEnumerable<int> values = Enum.GetValues (typeof (ConsoleColor))
  493. .OfType<ConsoleColor> ()
  494. .Select (s => (int)s);
  495. if (values.Contains (value & 0xffff)) {
  496. hasColor = true;
  497. background = (Color)(ConsoleColor)(value & 0xffff);
  498. }
  499. if (values.Contains ((value >> 16) & 0xffff)) {
  500. hasColor = true;
  501. foreground = (Color)(ConsoleColor)((value >> 16) & 0xffff);
  502. }
  503. return hasColor;
  504. }
  505. #region Unused
  506. public override void UpdateCursor ()
  507. {
  508. //
  509. }
  510. public override void StartReportingMouseMoves ()
  511. {
  512. }
  513. public override void StopReportingMouseMoves ()
  514. {
  515. }
  516. public override void Suspend ()
  517. {
  518. }
  519. public override void SetColors (ConsoleColor foreground, ConsoleColor background)
  520. {
  521. }
  522. public override void SetColors (short foregroundColorId, short backgroundColorId)
  523. {
  524. throw new NotImplementedException ();
  525. }
  526. public override void CookMouse ()
  527. {
  528. }
  529. public override void UncookMouse ()
  530. {
  531. }
  532. #endregion
  533. #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
  534. }
  535. }