public static IAnsiConsole CreateAnsiConsole(this IConsole console) => AnsiConsole.Create(new AnsiConsoleSettings { Ansi = AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect, Out = new AnsiConsoleOutput(console.Output) });
/// <summary> /// Initializes a new instance of the <see cref="TestConsole"/> class. /// </summary> public TestConsole() { _writer = new StringWriter(); _cursor = new NoopCursor(); Input = new TestConsoleInput(); EmitAnsiSequences = false; _console = AnsiConsole.Create(new AnsiConsoleSettings { Ansi = AnsiSupport.Yes, ColorSystem = (ColorSystemSupport)ColorSystem.TrueColor, Out = new AnsiConsoleOutput(_writer), Interactive = InteractionSupport.No, ExclusivityMode = new NoopExclusivityMode(), Enrichment = new ProfileEnrichment { UseDefaultEnrichers = false, }, }); _console.Profile.Width = 80; _console.Profile.Height = 24; _console.Profile.Capabilities.Ansi = true; _console.Profile.Capabilities.Unicode = true; }
internal static IServiceCollection GetServices() { var services = new ServiceCollection(); // services.AddSingleton<ExecEngine.CommandRunner>(provider => new ExecEngine.CommandRunner("python") { Name = "python"}); services.AddSingleton <AppInfoService>(); services.AddBuildServices().AddUnPak().AddMessaging(); // services.AddSingleton<BuildService>(GetBuildService); services.AddSingleton <FileNameService>(); services.AddSingleton <ParserService>(); services.AddSingleton <IParserService>(p => p.GetRequiredService <ParserService>()); services.AddSingleton <IAnsiConsole>(p => { return(AnsiConsole.Create( new AnsiConsoleSettings { Ansi = Spectre.Console.AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect })); }); services.AddLogging(logging => { var level = GetLogLevel(); logging.SetMinimumLevel(LogLevel.Trace); logging.AddInlineSpectreConsole(c => { c.LogLevel = level; }); AddFileLogging(logging, level); }); services.Scan(scan => scan.FromAssemblyOf <Identifier>() .AddClasses(classes => classes.AssignableTo(typeof(AceCore.Parsers.IIdentifierParser))).AsImplementedInterfaces().WithSingletonLifetime() ); return(services); }
internal ConsoleRunner(ReportInput[] inputs, FileInfo outputFile) { _errorConsole = AnsiConsole.Create(new AnsiConsoleSettings { Out = Console.Error }); _standardConsole = AnsiConsole.Create(new AnsiConsoleSettings { Out = Console.Out }); _inputs = inputs; _outputFile = outputFile; }
public void Should_Create_Console_With_Requested_ColorSystem(ColorSystemSupport requested, ColorSystem expected) { // Given, When var console = AnsiConsole.Create(new AnsiConsoleSettings { ColorSystem = requested, Out = new AnsiConsoleOutput(new StringWriter()), }); // Then console.Profile.Capabilities.ColorSystem.ShouldBe(expected); }
public AnsiConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes, int width = 80) { _writer = new StringWriter(); Console = new ConsoleWithWidth( AnsiConsole.Create(new AnsiConsoleSettings { Ansi = ansi, ColorSystem = (ColorSystemSupport)system, Out = _writer, }), width); }
public MarkupConsoleFixture(ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes, int width = 80) { _writer = new StringWriter(); _console = AnsiConsole.Create(new AnsiConsoleSettings { Ansi = ansi, ColorSystem = (ColorSystemSupport)system, Out = _writer, LinkIdentityGenerator = new TestLinkIdentityGenerator(), }); Width = width; }
public static IAnsiConsole CreateConsole(this IConsoleSettings settings) { if (settings is null) { throw new ArgumentNullException(nameof(settings)); } return(AnsiConsole.Create(new AnsiConsoleSettings { Out = settings.Out, Ansi = settings.Ansi.GetAnsiSupport(), ColorSystem = settings.Colors.GetColorSystem(), })); }
private ConsoleHelper() { _output = new StringBuilder(); _originalConsole = AnsiConsole.Console; _originalTextWriter = Console.Out; _assertionScope = new AssertionScope(); _assertionScope.AddReportable("output", () => _output.ToString()); AnsiConsole.Console = AnsiConsole.Create(new AnsiConsoleSettings { Out = new RedirectedOutput(_output) }); Console.SetOut(new StringWriter(_output)); }
public SpectreInlineLogger(string name, SpectreConsoleLoggerConfiguration config) { _name = name; _config = config; var settings = config.ConsoleSettings ?? new AnsiConsoleSettings { Ansi = AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect }; _console = AnsiConsole.Create(settings); if (config.ConsoleConfiguration != null) { config.ConsoleConfiguration.Invoke(_console); } }
public string FormatTree(Tree debugTree) { using var stringBuffer = new StringWriter(); _ansiConsoleSettings.Out = stringBuffer; var ansiConsole = AnsiConsole.Create(_ansiConsoleSettings); var consoleTree = new SpectreTree(debugTree.Root.DebugElement.Element.GetType().Name); foreach (var rootNode in debugTree.Nodes) { FormatTreeNode(rootNode, consoleTree); } ansiConsole.Render(consoleTree); return(stringBuffer.ToString()); }
public ConsoleWriter() { Console.OutputEncoding = Encoding.UTF8; this.console = AnsiConsole.Create(new AnsiConsoleSettings { Ansi = AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect, Out = StandardOut = Console.Out, }); this.errorConsole = AnsiConsole.Create(new AnsiConsoleSettings { Ansi = AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect, Out = StandardError = Console.Error, }); }
public static IAnsiConsole CreateAnsiConsole(this IConsole console) { var ansiConsole = AnsiConsole.Create( new AnsiConsoleSettings { Ansi = AnsiSupport.Detect, ColorSystem = ColorSystemSupport.Detect, Out = console.Output } ); // HACK: https://github.com/spectresystems/spectre.console/pull/318 ansiConsole.Profile.Encoding = console.Output.Encoding; return(ansiConsole); }
public FakeAnsiConsole( ColorSystem system, AnsiSupport ansi = AnsiSupport.Yes, InteractionSupport interaction = InteractionSupport.Yes, int width = 80) { _writer = new StringWriter(); _console = AnsiConsole.Create(new AnsiConsoleSettings { Ansi = ansi, ColorSystem = (ColorSystemSupport)system, Interactive = interaction, Out = _writer, LinkIdentityGenerator = new FakeLinkIdentityGenerator(1024), }); Width = width; Input = new FakeConsoleInput(); }