LineBreak.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. //
  16. // Ported from: https://github.com/foliojs/linebreak
  17. using System.Diagnostics;
  18. namespace Topten.RichTextKit
  19. {
  20. /// <summary>
  21. /// Information about a potential line break position
  22. /// </summary>
  23. [DebuggerDisplay("{PositionMeasure}/{PositionWrap} @ {Required}")]
  24. internal struct LineBreak
  25. {
  26. /// <summary>
  27. /// Constructor
  28. /// </summary>
  29. /// <param name="positionMeasure">The code point index to measure to</param>
  30. /// <param name="positionWrap">The code point index to actually break the line at</param>
  31. /// <param name="required">True if this is a required line break; otherwise false</param>
  32. public LineBreak(int positionMeasure, int positionWrap, bool required = false)
  33. {
  34. this.PositionMeasure = positionMeasure;
  35. this.PositionWrap = positionWrap;
  36. this.Required = required;
  37. }
  38. /// <summary>
  39. /// The break position, before any trailing whitespace
  40. /// </summary>
  41. /// <remarks>
  42. /// This doesn't include trailing whitespace
  43. /// </remarks>
  44. public int PositionMeasure;
  45. /// <summary>
  46. /// The break position, after any trailing whitespace
  47. /// </summary>
  48. /// <remarks>
  49. /// This includes trailing whitespace
  50. /// </remarks>
  51. public int PositionWrap;
  52. /// <summary>
  53. /// True if there should be a forced line break here
  54. /// </summary>
  55. public bool Required;
  56. }
  57. }