mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 13:28:16 +08:00
Add output abstraction and reorganize profile
* Moves ColorSystem from Profile to Capabilities * Renames Tty to IsTerminal * Adds IAnsiConsoleOutput to make output more flexible Closes #343 Closes #359 Closes #369
This commit is contained in:

committed by
Phil Scott

parent
bc9f610258
commit
3e2eea730b
@ -29,7 +29,7 @@ namespace Spectre.Console
|
||||
{
|
||||
codes = codes.Concat(
|
||||
AnsiColorBuilder.GetAnsiCodes(
|
||||
_profile.ColorSystem,
|
||||
_profile.Capabilities.ColorSystem,
|
||||
style.Foreground,
|
||||
true));
|
||||
}
|
||||
@ -39,7 +39,7 @@ namespace Spectre.Console
|
||||
{
|
||||
codes = codes.Concat(
|
||||
AnsiColorBuilder.GetAnsiCodes(
|
||||
_profile.ColorSystem,
|
||||
_profile.Capabilities.ColorSystem,
|
||||
style.Background,
|
||||
false));
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ namespace Spectre.Console
|
||||
|
||||
if (builder.Length > 0)
|
||||
{
|
||||
_console.Profile.Out.Write(builder.ToString());
|
||||
_console.Profile.Out.Flush();
|
||||
_console.Profile.Out.Writer.Write(builder.ToString());
|
||||
_console.Profile.Out.Writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace Spectre.Console
|
||||
SetStyle(segment.Style);
|
||||
}
|
||||
|
||||
_console.Profile.Out.Write(segment.Text.NormalizeNewLines(native: true));
|
||||
_console.Profile.Out.Writer.Write(segment.Text.NormalizeNewLines(native: true));
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,13 +55,13 @@ namespace Spectre.Console
|
||||
System.Console.ResetColor();
|
||||
|
||||
var background = Color.ToConsoleColor(style.Background);
|
||||
if (_console.Profile.ColorSystem != ColorSystem.NoColors && (int)background != -1)
|
||||
if (_console.Profile.Capabilities.ColorSystem != ColorSystem.NoColors && (int)background != -1)
|
||||
{
|
||||
System.Console.BackgroundColor = background;
|
||||
}
|
||||
|
||||
var foreground = Color.ToConsoleColor(style.Foreground);
|
||||
if (_console.Profile.ColorSystem != ColorSystem.NoColors && (int)foreground != -1)
|
||||
if (_console.Profile.Capabilities.ColorSystem != ColorSystem.NoColors && (int)foreground != -1)
|
||||
{
|
||||
System.Console.ForegroundColor = foreground;
|
||||
}
|
||||
|
Reference in New Issue
Block a user