Exemple #1
0
        /// <summary>
        /// Creates a new styled text object that is the same as the current object, but with the text set to the given text instead.
        /// </summary>
        /// <param name="fragment">The text object to be used as a reference.</param>
        /// <param name="text">The text to be used for printing.</param>
        /// <returns>A new text object that is the same as the current object, but with the new text instead.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="fragment"/> is <c>null</c>.</exception>
        public static FabulousText Text(this FabulousText fragment, string text)
        {
            if (fragment == null)
            {
                throw new ArgumentNullException(nameof(fragment));
            }

            return(new FabulousText(fragment.ForegroundColor, fragment.BackgroundColor, fragment.Decorations, text, fragment.ConsoleReset));
        }
Exemple #2
0
        /// <summary>
        /// Creates a new styled text object that is the same as the current object, but with the background color set to the given color instead.
        /// </summary>
        /// <param name="fragment">The text object to be used as a reference.</param>
        /// <param name="backColor">The new color to use as a background color.</param>
        /// <returns>A new text object that is the same as the current object, but with the new background color.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="fragment"/> or <paramref name="backColor"/> is <c>null</c>.</exception>
        public static FabulousText Background(this FabulousText fragment, IColor backColor)
        {
            if (fragment == null)
            {
                throw new ArgumentNullException(nameof(fragment));
            }
            if (backColor == null)
            {
                throw new ArgumentNullException(nameof(backColor));
            }

            return(new FabulousText(fragment.ForegroundColor, backColor, fragment.Decorations, fragment.Text, fragment.ConsoleReset));
        }
 /// <summary>
 /// Creates a console writer that performs no styling.
 /// </summary>
 /// <param name="text">A piece of text to be printed.</param>
 public UnstyledConsoleWriter(FabulousText text)
     : this(new FabulousTextCollection(text))
 {
 }
Exemple #4
0
 /// <summary>
 /// Creates an ANSI string builder that is styled with 256 colors for a piece of styled text.
 /// </summary>
 /// <param name="text">A piece of text to be styled.</param>
 public AnsiEnhancedStringBuilder(FabulousText text)
     : this(new FabulousTextCollection(text))
 {
 }
 /// <summary>
 /// Creates a console writer that performs styling using <see cref="Console"/>.
 /// </summary>
 /// <param name="text">A piece of text to be printed.</param>
 public StandardConsoleWriter(FabulousText text)
     : this(new FabulousTextCollection(text))
 {
 }
 /// <summary>
 /// Creates an ANSI string builder that is styled with 24-bit color for a piece of styled text.
 /// </summary>
 /// <param name="text">A piece of text to be styled.</param>
 public AnsiFullStringBuilder(FabulousText text)
     : this(new FabulousTextCollection(text))
 {
 }