using System; namespace Spectre.Console { /// /// Contains extension methods for . /// public static class OverflowableExtensions { /// /// Folds any overflowing text. /// /// An object implementing . /// The overflowable object instance. /// The same instance so that multiple calls can be chained. public static T Fold(this T obj) where T : class, IOverflowable { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } return Overflow(obj, Console.Overflow.Fold); } /// /// Crops any overflowing text. /// /// An object implementing . /// The overflowable object instance. /// The same instance so that multiple calls can be chained. public static T Crop(this T obj) where T : class, IOverflowable { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } return Overflow(obj, Console.Overflow.Crop); } /// /// Crops any overflowing text and adds an ellipsis to the end. /// /// An object implementing . /// The overflowable object instance. /// The same instance so that multiple calls can be chained. public static T Ellipsis(this T obj) where T : class, IOverflowable { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } return Overflow(obj, Console.Overflow.Ellipsis); } /// /// Sets the overflow strategy. /// /// An object implementing . /// The overflowable object instance. /// The overflow strategy to use. /// The same instance so that multiple calls can be chained. public static T Overflow(this T obj, Overflow overflow) where T : class, IOverflowable { if (obj is null) { throw new ArgumentNullException(nameof(obj)); } obj.Overflow = overflow; return obj; } } }