2
0

DimFunc.cs 904 B

1234567891011121314151617181920212223
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Represents a function <see cref="Gui.Dim"/> object that computes the dimension by executing the provided function.
  5. /// </summary>
  6. /// <remarks>
  7. /// This is a low-level API that is typically used internally by the layout system. Use the various static
  8. /// methods on the <see cref="Gui.Dim"/> class to create <see cref="Gui.Dim"/> objects instead.
  9. /// </remarks>
  10. /// <param name="Fn">The function that computes the dimension. If this function throws <see cref="LayoutException"/>... </param>
  11. public record DimFunc (Func<int> Fn) : Dim
  12. {
  13. /// <summary>
  14. /// Gets the function that computes the dimension.
  15. /// </summary>
  16. public Func<int> Fn { get; } = Fn;
  17. /// <inheritdoc/>
  18. public override string ToString () { return $"DimFunc({Fn ()})"; }
  19. internal override int GetAnchor (int size) { return Fn (); }
  20. }