2019-12-09 17:25:54 +01:00
|
|
|
|
#nullable enable
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Swan {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A console terminal helper to create nicer output and receive input from the user
|
|
|
|
|
/// This class is thread-safe :).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static partial class Terminal {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes the specified text in the given color.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="text">The text.</param>
|
|
|
|
|
/// <param name="color">The color.</param>
|
|
|
|
|
/// <param name="writerFlags">The writer flags.</param>
|
2019-12-10 20:01:19 +01:00
|
|
|
|
// [Obsolete("NEED", false)]
|
2019-12-09 17:25:54 +01:00
|
|
|
|
public static void Write(String? text, ConsoleColor? color = null, TerminalWriters writerFlags = TerminalWriters.StandardOutput) {
|
|
|
|
|
if(text == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock(SyncLock) {
|
|
|
|
|
Byte[] buffer = OutputEncoding.GetBytes(text);
|
|
|
|
|
OutputContext context = new OutputContext {
|
|
|
|
|
OutputColor = color ?? Settings.DefaultColor,
|
|
|
|
|
OutputText = OutputEncoding.GetChars(buffer),
|
|
|
|
|
OutputWriters = writerFlags,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
EnqueueOutput(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|