Beispiel #1
0
        private void SetupSyntaxHighlighting()
        {
            var colorizer = new MarkdownHighlightingColorizer();
            var blockBackgroundRenderer = new BlockBackgroundRenderer();

            TextChanged += (s, e) =>
            {
                try
                {
                    AbstractSyntaxTree = GenerateAbstractSyntaxTree(Text);
                    colorizer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
                    blockBackgroundRenderer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
                    // The block nature of markdown causes edge cases in the syntax hightlighting.
                    // This is the nuclear option but it doesn't seem to cause issues.
                    EditBox.TextArea.TextView.Redraw();
                }
                catch (Exception ex)
                {
                    // See #159
                    Notify.Alert($"Abstract Syntax Tree generation failed: {ex.ToString()}");
                }
            };

            ThemeChanged += (s, e) =>
            {
                colorizer.OnThemeChanged(e.Theme);
                blockBackgroundRenderer.OnThemeChanged(e.Theme);
            };

            EditBox.TextArea.TextView.LineTransformers.Add(colorizer);
            EditBox.TextArea.TextView.BackgroundRenderers.Add(blockBackgroundRenderer);
        }
Beispiel #2
0
 private void TextChanged()
 {
     if (Text != null)
     {
         AbstractSyntaxTree         = GenerateAbstractSyntaxTree(Text);
         folding.AbstractSyntaxTree = AbstractSyntaxTree;
         folding.Text = Text;
         colorizer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
         blockRenderer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
         issueRenderer.Issues = AbstractSyntaxTree.Document.Issues;
     }
     else
     {
         AbstractSyntaxTree = null;
     }
 }
Beispiel #3
0
        private void SetupSyntaxHighlighting()
        {
            var colorizer = new MarkdownHighlightingColorizer();
            var blockBackgroundRenderer = new BlockBackgroundRenderer();

            TextChanged += (s, e) =>
            {
                AbstractSyntaxTree = Markdown.GenerateAbstractSyntaxTree(Text);
                colorizer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
                blockBackgroundRenderer.UpdateAbstractSyntaxTree(AbstractSyntaxTree);
            };
            ThemeChanged += (s, e) =>
            {
                colorizer.OnThemeChanged(e.Theme);
                blockBackgroundRenderer.OnThemeChanged(e.Theme);
            };
            EditBox.TextArea.TextView.LineTransformers.Add(colorizer);
            EditBox.TextArea.TextView.BackgroundRenderers.Add(blockBackgroundRenderer);
        }