CaretPosition.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // RichTextKit
  2. // Copyright © 2019-2020 Topten Software. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. // not use this product except in compliance with the License. You may obtain
  6. // a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. // License for the specific language governing permissions and limitations
  14. // under the License.
  15. using SkiaSharp;
  16. namespace Topten.RichTextKit
  17. {
  18. /// <summary>
  19. /// Stores state information about a caret position
  20. /// </summary>
  21. /// <remarks>
  22. /// The caret position is defined primarily by it's code point
  23. /// index however there are other attributes that can affect
  24. /// where it's displayed and how it moves. This structure
  25. /// encapsulates all the information about the caret required
  26. /// to position and move it correctly.
  27. /// </remarks>
  28. public struct CaretPosition
  29. {
  30. /// <summary>
  31. /// Initializes a CaretPosition
  32. /// </summary>
  33. /// <param name="codePointIndex">The code point index of the caret</param>
  34. /// <param name="altPosition">Whether the caret should be displayed in its alternative position</param>
  35. public CaretPosition(int codePointIndex, bool altPosition = false)
  36. {
  37. CodePointIndex = codePointIndex;
  38. AltPosition = altPosition;
  39. }
  40. /// <summary>
  41. /// The code point index of the caret insertion point
  42. /// </summary>
  43. public int CodePointIndex;
  44. /// <summary>
  45. /// True to display the caret at the end of the previous line
  46. /// rather than the start of the following line when the code
  47. /// point index is exactly on a line break.
  48. /// </summary>
  49. public bool AltPosition;
  50. }
  51. }