Beispiel #1
0
 /// <summary>
 ///     Writes the specified <see cref="ConsoleColoredString"/> followed by a newline to the console.</summary>
 /// <param name="value">
 ///     The string to print to the console.</param>
 /// <param name="stdErr">
 ///     <c>true</c> to print to Standard Error instead of Standard Output.</param>
 /// <param name="align">
 ///     Horizontal alignment of the string within the remaining space of the current line. If the string does not fit,
 ///     it will be printed as if left-aligned.</param>
 public static void WriteLine(ConsoleColoredString value, bool stdErr = false, HorizontalTextAlignment align = HorizontalTextAlignment.Left)
 {
     var output = stdErr ? Console.Error : Console.Out;
     if (value != null)
     {
         var cursorLeft = 0;
         try { cursorLeft = Console.CursorLeft; }
         catch { }
         var width = WrapToWidth() - cursorLeft;
         if (align == HorizontalTextAlignment.Center && width > value.Length)
             output.Write(new string(' ', (width - value.Length) / 2));
         else if (align == HorizontalTextAlignment.Right && width > value.Length)
             output.Write(new string(' ', width - value.Length));
         value.writeTo(output);
     }
     output.WriteLine();
 }
Beispiel #2
0
 /// <summary>Writes the specified <see cref="ConsoleColoredString"/> to the console.</summary>
 public static void Write(ConsoleColoredString value, bool stdErr = false)
 {
     if (value != null)
         value.writeTo(stdErr ? Console.Error : Console.Out);
 }