HexView.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. //
  2. // HexView.cs: A hexadecimal viewer
  3. //
  4. // TODO:
  5. // - Support searching and highlighting of the search result
  6. // - Bug showing the last line
  7. //
  8. using System;
  9. using System.Collections.Generic;
  10. using System.IO;
  11. using System.Text;
  12. namespace Terminal.Gui;
  13. /// <summary>
  14. /// An hex viewer and editor <see cref="View"/> over a <see cref="System.IO.Stream"/>
  15. /// </summary>
  16. /// <remarks>
  17. /// <para>
  18. /// <see cref="HexView"/> provides a hex editor on top of a seekable <see cref="Stream"/> with the left side showing an hex
  19. /// dump of the values in the <see cref="Stream"/> and the right side showing the contents (filtered to
  20. /// non-control sequence ASCII characters).
  21. /// </para>
  22. /// <para>
  23. /// Users can switch from one side to the other by using the tab key.
  24. /// </para>
  25. /// <para>
  26. /// To enable editing, set <see cref="AllowEdits"/> to true. When <see cref="AllowEdits"/> is true
  27. /// the user can make changes to the hexadecimal values of the <see cref="Stream"/>. Any changes are tracked
  28. /// in the <see cref="Edits"/> property (a <see cref="SortedDictionary{TKey, TValue}"/>) indicating
  29. /// the position where the changes were made and the new values. A convenience method, <see cref="ApplyEdits"/>
  30. /// will apply the edits to the <see cref="Stream"/>.
  31. /// </para>
  32. /// <para>
  33. /// Control the first byte shown by setting the <see cref="DisplayStart"/> property
  34. /// to an offset in the stream.
  35. /// </para>
  36. /// </remarks>
  37. public partial class HexView : View {
  38. SortedDictionary<long, byte> edits = new SortedDictionary<long, byte> ();
  39. Stream source;
  40. long displayStart, pos;
  41. bool firstNibble, leftSide;
  42. long position {
  43. get => pos;
  44. set {
  45. pos = value;
  46. OnPositionChanged ();
  47. }
  48. }
  49. /// <summary>
  50. /// Initializes a <see cref="HexView"/> class using <see cref="LayoutStyle.Computed"/> layout.
  51. /// </summary>
  52. /// <param name="source">The <see cref="Stream"/> to view and edit as hex, this <see cref="Stream"/> must support seeking, or an exception will be thrown.</param>
  53. public HexView (Stream source) : base ()
  54. {
  55. Source = source;
  56. CanFocus = true;
  57. leftSide = true;
  58. firstNibble = true;
  59. // Things this view knows how to do
  60. AddCommand (Command.Left, () => MoveLeft ());
  61. AddCommand (Command.Right, () => MoveRight ());
  62. AddCommand (Command.LineDown, () => MoveDown (bytesPerLine));
  63. AddCommand (Command.LineUp, () => MoveUp (bytesPerLine));
  64. AddCommand (Command.ToggleChecked, () => ToggleSide ());
  65. AddCommand (Command.PageUp, () => MoveUp (bytesPerLine * Frame.Height));
  66. AddCommand (Command.PageDown, () => MoveDown (bytesPerLine * Frame.Height));
  67. AddCommand (Command.TopHome, () => MoveHome ());
  68. AddCommand (Command.BottomEnd, () => MoveEnd ());
  69. AddCommand (Command.StartOfLine, () => MoveStartOfLine ());
  70. AddCommand (Command.EndOfLine, () => MoveEndOfLine ());
  71. AddCommand (Command.StartOfPage, () => MoveUp (bytesPerLine * ((int)(position - displayStart) / bytesPerLine)));
  72. AddCommand (Command.EndOfPage, () => MoveDown (bytesPerLine * (Frame.Height - 1 - (int)(position - displayStart) / bytesPerLine)));
  73. // Default keybindings for this view
  74. KeyBindings.Add (KeyCode.CursorLeft, Command.Left);
  75. KeyBindings.Add (KeyCode.CursorRight, Command.Right);
  76. KeyBindings.Add (KeyCode.CursorDown, Command.LineDown);
  77. KeyBindings.Add (KeyCode.CursorUp, Command.LineUp);
  78. KeyBindings.Add (KeyCode.Enter, Command.ToggleChecked);
  79. KeyBindings.Add ('v' + KeyCode.AltMask, Command.PageUp);
  80. KeyBindings.Add (KeyCode.PageUp, Command.PageUp);
  81. KeyBindings.Add (KeyCode.V | KeyCode.CtrlMask, Command.PageDown);
  82. KeyBindings.Add (KeyCode.PageDown, Command.PageDown);
  83. KeyBindings.Add (KeyCode.Home, Command.TopHome);
  84. KeyBindings.Add (KeyCode.End, Command.BottomEnd);
  85. KeyBindings.Add (KeyCode.CursorLeft | KeyCode.CtrlMask, Command.StartOfLine);
  86. KeyBindings.Add (KeyCode.CursorRight | KeyCode.CtrlMask, Command.EndOfLine);
  87. KeyBindings.Add (KeyCode.CursorUp | KeyCode.CtrlMask, Command.StartOfPage);
  88. KeyBindings.Add (KeyCode.CursorDown | KeyCode.CtrlMask, Command.EndOfPage);
  89. LayoutComplete += HexView_LayoutComplete;
  90. }
  91. private void HexView_LayoutComplete (object sender, LayoutEventArgs e)
  92. {
  93. // Small buffers will just show the position, with the bsize field value (4 bytes)
  94. bytesPerLine = bsize;
  95. if (Bounds.Width - displayWidth > 17) {
  96. bytesPerLine = bsize * ((Bounds.Width - displayWidth) / 18);
  97. }
  98. }
  99. /// <summary>
  100. /// Initializes a <see cref="HexView"/> class using <see cref="LayoutStyle.Computed"/> layout.
  101. /// </summary>
  102. public HexView () : this (source: new MemoryStream ()) { }
  103. /// <summary>
  104. /// Event to be invoked when an edit is made on the <see cref="Stream"/>.
  105. /// </summary>
  106. public event EventHandler<HexViewEditEventArgs> Edited;
  107. /// <summary>
  108. /// Event to be invoked when the position and cursor position changes.
  109. /// </summary>
  110. public event EventHandler<HexViewEventArgs> PositionChanged;
  111. /// <summary>
  112. /// Sets or gets the <see cref="Stream"/> the <see cref="HexView"/> is operating on; the stream must support seeking (<see cref="Stream.CanSeek"/> == true).
  113. /// </summary>
  114. /// <value>The source.</value>
  115. public Stream Source {
  116. get => source;
  117. set {
  118. if (value == null) {
  119. throw new ArgumentNullException ("source");
  120. }
  121. if (!value.CanSeek) {
  122. throw new ArgumentException ("The source stream must be seekable (CanSeek property)", "source");
  123. }
  124. source = value;
  125. if (displayStart > source.Length) {
  126. DisplayStart = 0;
  127. }
  128. if (position > source.Length) {
  129. position = 0;
  130. }
  131. SetNeedsDisplay ();
  132. }
  133. }
  134. internal void SetDisplayStart (long value)
  135. {
  136. if (value > 0 && value >= source.Length) {
  137. displayStart = source.Length - 1;
  138. } else if (value < 0) {
  139. displayStart = 0;
  140. } else {
  141. displayStart = value;
  142. }
  143. SetNeedsDisplay ();
  144. }
  145. /// <summary>
  146. /// Sets or gets the offset into the <see cref="Stream"/> that will displayed at the top of the <see cref="HexView"/>
  147. /// </summary>
  148. /// <value>The display start.</value>
  149. public long DisplayStart {
  150. get => displayStart;
  151. set {
  152. position = value;
  153. SetDisplayStart (value);
  154. }
  155. }
  156. const int displayWidth = 9;
  157. const int bsize = 4;
  158. int bpl;
  159. int bytesPerLine {
  160. get => bpl;
  161. set {
  162. bpl = value;
  163. OnPositionChanged ();
  164. }
  165. }
  166. //
  167. // This is used to support editing of the buffer on a peer List<>,
  168. // the offset corresponds to an offset relative to DisplayStart, and
  169. // the buffer contains the contents of a screenful of data, so the
  170. // offset is relative to the buffer.
  171. //
  172. //
  173. byte GetData (byte [] buffer, int offset, out bool edited)
  174. {
  175. long pos = DisplayStart + offset;
  176. if (edits.TryGetValue (pos, out byte v)) {
  177. edited = true;
  178. return v;
  179. }
  180. edited = false;
  181. return buffer [offset];
  182. }
  183. ///<inheritdoc/>
  184. public override void OnDrawContent (Rect contentArea)
  185. {
  186. Attribute currentAttribute;
  187. var current = ColorScheme.Focus;
  188. Driver.SetAttribute (current);
  189. Move (0, 0);
  190. // BUGBUG: Bounds!!!!
  191. var frame = Frame;
  192. int nblocks = bytesPerLine / bsize;
  193. byte [] data = new byte [nblocks * bsize * frame.Height];
  194. Source.Position = displayStart;
  195. int n = source.Read (data, 0, data.Length);
  196. var activeColor = ColorScheme.HotNormal;
  197. var trackingColor = ColorScheme.HotFocus;
  198. for (int line = 0; line < frame.Height; line++) {
  199. var lineRect = new Rect (0, line, frame.Width, 1);
  200. if (!Bounds.Contains (lineRect)) {
  201. continue;
  202. }
  203. Move (0, line);
  204. Driver.SetAttribute (ColorScheme.HotNormal);
  205. Driver.AddStr (string.Format ("{0:x8} ", displayStart + line * nblocks * bsize));
  206. currentAttribute = ColorScheme.HotNormal;
  207. SetAttribute (GetNormalColor ());
  208. for (int block = 0; block < nblocks; block++) {
  209. for (int b = 0; b < bsize; b++) {
  210. int offset = line * nblocks * bsize + block * bsize + b;
  211. byte value = GetData (data, offset, out bool edited);
  212. if (offset + displayStart == position || edited) {
  213. SetAttribute (leftSide ? activeColor : trackingColor);
  214. } else {
  215. SetAttribute (GetNormalColor ());
  216. }
  217. Driver.AddStr (offset >= n && !edited ? " " : string.Format ("{0:x2}", value));
  218. SetAttribute (GetNormalColor ());
  219. Driver.AddRune ((Rune)' ');
  220. }
  221. Driver.AddStr (block + 1 == nblocks ? " " : "| ");
  222. }
  223. for (int bitem = 0; bitem < nblocks * bsize; bitem++) {
  224. int offset = line * nblocks * bsize + bitem;
  225. byte b = GetData (data, offset, out bool edited);
  226. Rune c;
  227. if (offset >= n && !edited) {
  228. c = (Rune)' ';
  229. } else {
  230. if (b < 32) {
  231. c = (Rune)'.';
  232. } else if (b > 127) {
  233. c = (Rune)'.';
  234. } else {
  235. Rune.DecodeFromUtf8 (new ReadOnlySpan<byte> (ref b), out c, out _);
  236. }
  237. }
  238. if (offset + displayStart == position || edited) {
  239. SetAttribute (leftSide ? trackingColor : activeColor);
  240. } else {
  241. SetAttribute (GetNormalColor ());
  242. }
  243. Driver.AddRune (c);
  244. }
  245. }
  246. void SetAttribute (Attribute attribute)
  247. {
  248. if (currentAttribute != attribute) {
  249. currentAttribute = attribute;
  250. Driver.SetAttribute (attribute);
  251. }
  252. }
  253. }
  254. ///<inheritdoc/>
  255. public override void PositionCursor ()
  256. {
  257. int delta = (int)(position - displayStart);
  258. int line = delta / bytesPerLine;
  259. int item = delta % bytesPerLine;
  260. int block = item / bsize;
  261. int column = item % bsize * 3;
  262. if (leftSide) {
  263. Move (displayWidth + block * 14 + column + (firstNibble ? 0 : 1), line);
  264. } else {
  265. Move (displayWidth + bytesPerLine / bsize * 14 + item - 1, line);
  266. }
  267. }
  268. void RedisplayLine (long pos)
  269. {
  270. int delta = (int)(pos - DisplayStart);
  271. int line = delta / bytesPerLine;
  272. // BUGBUG: Bounds!
  273. SetNeedsDisplay (new Rect (0, line, Frame.Width, 1));
  274. }
  275. bool MoveEndOfLine ()
  276. {
  277. position = Math.Min (position / bytesPerLine * bytesPerLine + bytesPerLine - 1, source.Length);
  278. SetNeedsDisplay ();
  279. return true;
  280. }
  281. bool MoveStartOfLine ()
  282. {
  283. position = position / bytesPerLine * bytesPerLine;
  284. SetNeedsDisplay ();
  285. return true;
  286. }
  287. bool MoveEnd ()
  288. {
  289. position = source.Length;
  290. // BUGBUG: Bounds!
  291. if (position >= DisplayStart + bytesPerLine * Frame.Height) {
  292. SetDisplayStart (position);
  293. SetNeedsDisplay ();
  294. } else {
  295. RedisplayLine (position);
  296. }
  297. return true;
  298. }
  299. bool MoveHome ()
  300. {
  301. DisplayStart = 0;
  302. SetNeedsDisplay ();
  303. return true;
  304. }
  305. bool ToggleSide ()
  306. {
  307. leftSide = !leftSide;
  308. RedisplayLine (position);
  309. firstNibble = true;
  310. return true;
  311. }
  312. bool MoveLeft ()
  313. {
  314. RedisplayLine (position);
  315. if (leftSide) {
  316. if (!firstNibble) {
  317. firstNibble = true;
  318. return true;
  319. }
  320. firstNibble = false;
  321. }
  322. if (position == 0) {
  323. return true;
  324. }
  325. if (position - 1 < DisplayStart) {
  326. SetDisplayStart (displayStart - bytesPerLine);
  327. SetNeedsDisplay ();
  328. } else {
  329. RedisplayLine (position);
  330. }
  331. position--;
  332. return true;
  333. }
  334. bool MoveRight ()
  335. {
  336. RedisplayLine (position);
  337. if (leftSide) {
  338. if (firstNibble) {
  339. firstNibble = false;
  340. return true;
  341. } else {
  342. firstNibble = true;
  343. }
  344. }
  345. if (position < source.Length) {
  346. position++;
  347. }
  348. // BUGBUG: Bounds!
  349. if (position >= DisplayStart + bytesPerLine * Frame.Height) {
  350. SetDisplayStart (DisplayStart + bytesPerLine);
  351. SetNeedsDisplay ();
  352. } else {
  353. RedisplayLine (position);
  354. }
  355. return true;
  356. }
  357. bool MoveUp (int bytes)
  358. {
  359. RedisplayLine (position);
  360. if (position - bytes > -1) {
  361. position -= bytes;
  362. }
  363. if (position < DisplayStart) {
  364. SetDisplayStart (DisplayStart - bytes);
  365. SetNeedsDisplay ();
  366. } else {
  367. RedisplayLine (position);
  368. }
  369. return true;
  370. }
  371. bool MoveDown (int bytes)
  372. {
  373. // BUGBUG: Bounds!
  374. RedisplayLine (position);
  375. if (position + bytes < source.Length) {
  376. position += bytes;
  377. } else if (bytes == bytesPerLine * Frame.Height && source.Length >= DisplayStart + bytesPerLine * Frame.Height
  378. || bytes <= bytesPerLine * Frame.Height - bytesPerLine && source.Length <= DisplayStart + bytesPerLine * Frame.Height) {
  379. long p = position;
  380. while (p + bytesPerLine < source.Length) {
  381. p += bytesPerLine;
  382. }
  383. position = p;
  384. }
  385. if (position >= DisplayStart + bytesPerLine * Frame.Height) {
  386. SetDisplayStart (DisplayStart + bytes);
  387. SetNeedsDisplay ();
  388. } else {
  389. RedisplayLine (position);
  390. }
  391. return true;
  392. }
  393. /// <inheritdoc/>
  394. public override bool OnProcessKeyDown (Key keyEvent)
  395. {
  396. if (!AllowEdits) {
  397. return false;
  398. }
  399. // Ignore control characters and other special keys
  400. if (keyEvent.KeyCode < KeyCode.Space || keyEvent.KeyCode > KeyCode.CharMask) {
  401. return false;
  402. }
  403. if (leftSide) {
  404. int value;
  405. char k = (char)keyEvent.KeyCode;
  406. if (k >= 'A' && k <= 'F') {
  407. value = k - 'A' + 10;
  408. } else if (k >= 'a' && k <= 'f') {
  409. value = k - 'a' + 10;
  410. } else if (k >= '0' && k <= '9') {
  411. value = k - '0';
  412. } else {
  413. return false;
  414. }
  415. byte b;
  416. if (!edits.TryGetValue (position, out b)) {
  417. source.Position = position;
  418. b = (byte)source.ReadByte ();
  419. }
  420. RedisplayLine (position);
  421. if (firstNibble) {
  422. firstNibble = false;
  423. b = (byte)(b & 0xf | value << bsize);
  424. edits [position] = b;
  425. OnEdited (new HexViewEditEventArgs (position, edits [position]));
  426. } else {
  427. b = (byte)(b & 0xf0 | value);
  428. edits [position] = b;
  429. OnEdited (new HexViewEditEventArgs (position, edits [position]));
  430. MoveRight ();
  431. }
  432. return true;
  433. } else {
  434. return false;
  435. }
  436. }
  437. /// <summary>
  438. /// Method used to invoke the <see cref="Edited"/> event passing the <see cref="KeyValuePair{TKey, TValue}"/>.
  439. /// </summary>
  440. /// <param name="e">The key value pair.</param>
  441. public virtual void OnEdited (HexViewEditEventArgs e)
  442. {
  443. Edited?.Invoke (this, e);
  444. }
  445. /// <summary>
  446. /// Method used to invoke the <see cref="PositionChanged"/> event passing the <see cref="HexViewEventArgs"/> arguments.
  447. /// </summary>
  448. public virtual void OnPositionChanged ()
  449. {
  450. PositionChanged?.Invoke (this, new HexViewEventArgs (Position, CursorPosition, BytesPerLine));
  451. }
  452. /// <inheritdoc/>
  453. public override bool MouseEvent (MouseEvent me)
  454. {
  455. // BUGBUG: Test this with a border! Assumes Frame == Bounds!
  456. if (!me.Flags.HasFlag (MouseFlags.Button1Clicked) && !me.Flags.HasFlag (MouseFlags.Button1DoubleClicked)
  457. && !me.Flags.HasFlag (MouseFlags.WheeledDown) && !me.Flags.HasFlag (MouseFlags.WheeledUp)) {
  458. return false;
  459. }
  460. if (!HasFocus) {
  461. SetFocus ();
  462. }
  463. if (me.Flags == MouseFlags.WheeledDown) {
  464. DisplayStart = Math.Min (DisplayStart + bytesPerLine, source.Length);
  465. return true;
  466. }
  467. if (me.Flags == MouseFlags.WheeledUp) {
  468. DisplayStart = Math.Max (DisplayStart - bytesPerLine, 0);
  469. return true;
  470. }
  471. if (me.X < displayWidth) {
  472. return true;
  473. }
  474. int nblocks = bytesPerLine / bsize;
  475. int blocksSize = nblocks * 14;
  476. int blocksRightOffset = displayWidth + blocksSize - 1;
  477. if (me.X > blocksRightOffset + bytesPerLine - 1) {
  478. return true;
  479. }
  480. leftSide = me.X >= blocksRightOffset;
  481. long lineStart = me.Y * bytesPerLine + displayStart;
  482. int x = me.X - displayWidth + 1;
  483. int block = x / 14;
  484. x -= block * 2;
  485. int empty = x % 3;
  486. int item = x / 3;
  487. if (!leftSide && item > 0 && (empty == 0 || x == block * 14 + 14 - 1 - block * 2)) {
  488. return true;
  489. }
  490. firstNibble = true;
  491. if (leftSide) {
  492. position = Math.Min (lineStart + me.X - blocksRightOffset, source.Length);
  493. } else {
  494. position = Math.Min (lineStart + item, source.Length);
  495. }
  496. if (me.Flags == MouseFlags.Button1DoubleClicked) {
  497. leftSide = !leftSide;
  498. if (leftSide) {
  499. firstNibble = empty == 1;
  500. } else {
  501. firstNibble = true;
  502. }
  503. }
  504. SetNeedsDisplay ();
  505. return true;
  506. }
  507. /// <summary>
  508. /// Gets or sets whether this <see cref="HexView"/> allow editing of the <see cref="Stream"/>
  509. /// of the underlying <see cref="Stream"/>.
  510. /// </summary>
  511. /// <value><c>true</c> if allow edits; otherwise, <c>false</c>.</value>
  512. public bool AllowEdits { get; set; } = true;
  513. /// <summary>
  514. /// Gets a <see cref="SortedDictionary{TKey, TValue}"/> describing the edits done to the <see cref="HexView"/>.
  515. /// Each Key indicates an offset where an edit was made and the Value is the changed byte.
  516. /// </summary>
  517. /// <value>The edits.</value>
  518. public IReadOnlyDictionary<long, byte> Edits => edits;
  519. /// <summary>
  520. /// Gets the current character position starting at one, related to the <see cref="Stream"/>.
  521. /// </summary>
  522. public long Position => position + 1;
  523. /// <summary>
  524. /// Gets the current cursor position starting at one for both, line and column.
  525. /// </summary>
  526. public Point CursorPosition {
  527. get {
  528. if (!IsInitialized) {
  529. return new Point (0, 0);
  530. }
  531. int delta = (int)position;
  532. int line = delta / bytesPerLine + 1;
  533. int item = delta % bytesPerLine + 1;
  534. return new Point (item, line);
  535. }
  536. }
  537. /// <summary>
  538. /// The bytes length per line.
  539. /// </summary>
  540. public int BytesPerLine => bytesPerLine;
  541. /// <summary>
  542. /// This method applies and edits made to the <see cref="Stream"/> and resets the
  543. /// contents of the <see cref="Edits"/> property.
  544. /// </summary>
  545. /// <param name="stream">If provided also applies the changes to the passed <see cref="Stream"/></param>.
  546. public void ApplyEdits (Stream stream = null)
  547. {
  548. foreach (var kv in edits) {
  549. source.Position = kv.Key;
  550. source.WriteByte (kv.Value);
  551. source.Flush ();
  552. if (stream != null) {
  553. stream.Position = kv.Key;
  554. stream.WriteByte (kv.Value);
  555. stream.Flush ();
  556. }
  557. }
  558. edits = new SortedDictionary<long, byte> ();
  559. SetNeedsDisplay ();
  560. }
  561. /// <summary>
  562. /// This method discards the edits made to the <see cref="Stream"/> by resetting the
  563. /// contents of the <see cref="Edits"/> property.
  564. /// </summary>
  565. public void DiscardEdits ()
  566. {
  567. edits = new SortedDictionary<long, byte> ();
  568. }
  569. CursorVisibility desiredCursorVisibility = CursorVisibility.Default;
  570. /// <summary>
  571. /// Get / Set the wished cursor when the field is focused
  572. /// </summary>
  573. public CursorVisibility DesiredCursorVisibility {
  574. get => desiredCursorVisibility;
  575. set {
  576. if (desiredCursorVisibility != value && HasFocus) {
  577. Application.Driver.SetCursorVisibility (value);
  578. }
  579. desiredCursorVisibility = value;
  580. }
  581. }
  582. ///<inheritdoc/>
  583. public override bool OnEnter (View view)
  584. {
  585. Application.Driver.SetCursorVisibility (DesiredCursorVisibility);
  586. return base.OnEnter (view);
  587. }
  588. }