Cell.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// Represents a single row/column in a Terminal.Gui rendering surface (e.g. <see cref="LineCanvas"/> and
  4. /// <see cref="ConsoleDriver"/>).
  5. /// </summary>
  6. public record struct Cell ()
  7. {
  8. /// <summary>The attributes to use when drawing the Glyph.</summary>
  9. public Attribute? Attribute { get; set; } = null;
  10. /// <summary>
  11. /// Gets or sets a value indicating whether this <see cref="T:Terminal.Gui.Cell"/> has been modified since the
  12. /// last time it was drawn.
  13. /// </summary>
  14. public bool IsDirty { get; set; } = false;
  15. private Rune _rune = default;
  16. /// <summary>The character to display. If <see cref="Rune"/> is <see langword="null"/>, then <see cref="Rune"/> is ignored.</summary>
  17. public Rune Rune
  18. {
  19. get => _rune;
  20. set
  21. {
  22. CombiningMarks.Clear ();
  23. _rune = value;
  24. }
  25. }
  26. /// <summary>
  27. /// The combining marks for <see cref="Rune"/> that when combined makes this Cell a combining sequence. If
  28. /// <see cref="CombiningMarks"/> empty, then <see cref="CombiningMarks"/> is ignored.
  29. /// </summary>
  30. /// <remarks>
  31. /// Only valid in the rare case where <see cref="Rune"/> is a combining sequence that could not be normalized to a
  32. /// single Rune.
  33. /// </remarks>
  34. internal List<Rune> CombiningMarks { get; } = new ();
  35. /// <inheritdoc/>
  36. public override string ToString () { return $"[{Rune}, {Attribute}]"; }
  37. }