ITextFormatter.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #nullable enable
  2. using System.Drawing;
  3. namespace Terminal.Gui.Text;
  4. /// <summary>
  5. /// Interface for text formatting. Separates formatting concerns from rendering.
  6. /// </summary>
  7. public interface ITextFormatter
  8. {
  9. /// <summary>Gets or sets the text to be formatted.</summary>
  10. string Text { get; set; }
  11. /// <summary>Gets or sets the size constraint for formatting.</summary>
  12. Size? ConstrainToSize { get; set; }
  13. /// <summary>Gets or sets the horizontal text alignment.</summary>
  14. Alignment Alignment { get; set; }
  15. /// <summary>Gets or sets the vertical text alignment.</summary>
  16. Alignment VerticalAlignment { get; set; }
  17. /// <summary>Gets or sets the text direction.</summary>
  18. TextDirection Direction { get; set; }
  19. /// <summary>Gets or sets whether word wrap is enabled.</summary>
  20. bool WordWrap { get; set; }
  21. /// <summary>Gets or sets whether multi-line text is allowed.</summary>
  22. bool MultiLine { get; set; }
  23. /// <summary>Gets or sets the HotKey specifier character.</summary>
  24. Rune HotKeySpecifier { get; set; }
  25. /// <summary>Gets or sets the tab width.</summary>
  26. int TabWidth { get; set; }
  27. /// <summary>Gets or sets whether trailing spaces are preserved in word-wrapped lines.</summary>
  28. bool PreserveTrailingSpaces { get; set; }
  29. /// <summary>
  30. /// Formats the text and returns the formatted result.
  31. /// </summary>
  32. /// <returns>The formatted text result containing lines, size, and metadata.</returns>
  33. FormattedText Format();
  34. /// <summary>
  35. /// Gets the size required to display the formatted text.
  36. /// </summary>
  37. /// <returns>The size required for the formatted text.</returns>
  38. Size GetFormattedSize();
  39. }