Exemplo n.º 1
0
        /// <summary>
        /// Roslyn can be a little bit slow to warm up, which can cause lag when the
        /// user first starts typing / evaluating code. Do the warm up in a background
        /// thread beforehand to improve the user experience.
        /// </summary>
        private Task BackgroundInitializationAsync()
        {
            const string initializationCode = @"using System; Console.WriteLine(""Hello""); ""World""";

            return(Task.WhenAll(
                       replServices.HighlightAsync(Guid.Empty, initializationCode),
                       replServices.CompleteCodeAsync(Guid.Empty, initializationCode, initializationCode.Length),
                       replServices.AppendEvaluationAsync(Guid.Empty, initializationCode, new NullLogger())
                       ));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Roslyn can be a little bit slow to warm up, which can cause lag when the
        /// user first starts typing / evaluating code. Do the warm up in a background
        /// thread beforehand to improve the user experience.
        /// </summary>
        private Task BackgroundInitializationAsync()
        {
            const string initializationCode = @"using System; Console.WriteLine(""Hello""); ""World""";

            return(Task.WhenAll(
                       services.HighlightAsync(0, initializationCode),
                       services.CompleteCodeAsync(0, initializationCode),
                       services.EvaluateAsync(0, initializationCode)
                       ));
        }
Exemplo n.º 3
0
        protected override void ColorizeLine(DocumentLine line)
        {
            if (line.Length == 0)
            {
                return;
            }

            string text  = CurrentContext.Document.GetText(line);
            var    spans = replServices
                           .HighlightAsync(lineNumber, text)
                           .Result;

            foreach (var span in spans)
            {
                base.ChangeLinePart(line.Offset + span.Start, line.Offset + span.End, part =>
                {
                    part.TextRunProperties.SetForegroundBrush(new SolidColorBrush(span.Color));
                });
            }
        }
Exemplo n.º 4
0
        protected async override Task ColorizeLineAsync(DocumentLine line, DocumentContext context, IList <VisualLineElement> elements)
        {
            if (line.Length == 0)
            {
                return;
            }

            string text  = context.CurrentContext.Document.GetText(line);
            var    spans = await replServices.HighlightAsync(lineNumber, text);

            int offset = line.Offset;

            foreach (var span in spans)
            {
                base.ChangeLinePart(offset + span.Start, offset + span.End, elements, context, part =>
                {
                    part.TextRunProperties.SetForegroundBrush(new SolidColorBrush(span.Color));
                });
            }
        }