public AnsiConsoleRenderer(TextWriter @out, Capabilities capabilities, ILinkIdentityGenerator?linkHasher)
        {
            _out = @out ?? throw new ArgumentNullException(nameof(@out));

            Capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
            Encoding     = _out.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8;

            _ansiBuilder = new AnsiBuilder(Capabilities, linkHasher);
        }
示例#2
0
        public AnsiBackend(TextWriter @out, Capabilities capabilities, ILinkIdentityGenerator?linkHasher)
        {
            _out = @out ?? throw new ArgumentNullException(nameof(@out));

            Capabilities = capabilities ?? throw new ArgumentNullException(nameof(capabilities));
            Encoding     = _out.IsStandardOut() ? System.Console.OutputEncoding : Encoding.UTF8;
            Pipeline     = new RenderPipeline();

            _ansiBuilder = new AnsiBuilder(Capabilities, linkHasher);
            _cursor      = new AnsiCursor(this);
            _input       = new ConsoleInput();
            _lock        = new object();
        }
示例#3
0
        public void Write(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var parts = text.NormalizeLineEndings().Split(new[] { '\n' });

            foreach (var(_, _, last, part) in parts.Enumerate())
            {
                if (!string.IsNullOrEmpty(part))
                {
                    _out.Write(AnsiBuilder.GetAnsi(_system, part, Decoration, Foreground, Background));
                }

                if (!last)
                {
                    _out.Write(Environment.NewLine);
                }
            }
        }