RaspberryIO_26/Swan.Tiny/Terminal.Output.cs
2019-12-10 20:20:45 +01:00

35 lines
1.0 KiB
C#

#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>
// [Obsolete("NEED", false)]
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);
}
}
}
}