public IHighlighter CreateHighlighter(IDocument document)
        {
            if (document.FileName == null)
            {
                return(new MultiHighlighter(document));
            }
            var def = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(document.FileName));

            if (def == null)
            {
                return(new MultiHighlighter(document));
            }
            List <IHighlighter> highlighters = new List <IHighlighter>();
            var textDocument     = document as TextDocument;
            var readOnlyDocument = document as ReadOnlyDocument;

            if (textDocument != null)
            {
                highlighters.Add(new DocumentHighlighter(textDocument, def));
            }
            else if (readOnlyDocument != null)
            {
                highlighters.Add(new DocumentHighlighter(readOnlyDocument, def));
            }
            // add additional highlighters
            highlighters.AddRange(SD.AddInTree.BuildItems <IHighlighter>(HighlighterDoozer.AddInPath, document, false));
            var multiHighlighter = new MultiHighlighter(document, highlighters.ToArray());

            return(new CustomizingHighlighter(multiHighlighter, CustomizedHighlightingColor.FetchCustomizations(def.Name)));
        }
Esempio n. 2
0
        /// <summary>
        /// Copies editor options and default element customizations.
        /// Does not copy the syntax highlighting.
        /// </summary>
        public static void CopySettingsFrom(this TextEditor editor, TextEditor source)
        {
            editor.Options = source.Options;
            string language = source.SyntaxHighlighting != null ? source.SyntaxHighlighting.Name : null;

            CustomizingHighlighter.ApplyCustomizationsToDefaultElements(editor, CustomizedHighlightingColor.FetchCustomizations(language));
            HighlightingOptions.ApplyToRendering(editor, CustomizedHighlightingColor.FetchCustomizations(language));
        }
Esempio n. 3
0
        public void CopyEditorSettings(TextEditor source)
        {
            string language = source.SyntaxHighlighting != null ? source.SyntaxHighlighting.Name : null;

            editor.TextArea.TextView.LineTransformers.RemoveWhere(x => x is HighlightingColorizer);
            editor.TextArea.TextView.LineTransformers.Insert(0, new CustomizableHighlightingColorizer(source.SyntaxHighlighting.MainRuleSet, CustomizedHighlightingColor.FetchCustomizations(language)));
            CustomizableHighlightingColorizer.ApplyCustomizationsToDefaultElements(editor, CustomizedHighlightingColor.FetchCustomizations(language));
            HighlightingOptions.ApplyToRendering(editor, CustomizedHighlightingColor.FetchCustomizations(language));
            editor.TextArea.TextView.Redraw();             // manually redraw if default elements didn't change but customized highlightings did
        }
        public void UpdateCustomizedHighlighting()
        {
            string language       = this.SyntaxHighlighting != null ? this.SyntaxHighlighting.Name : null;
            var    customizations = CustomizedHighlightingColor.FetchCustomizations(language);

            CustomizingHighlighter.ApplyCustomizationsToDefaultElements(this, customizations);
            BracketHighlightRenderer.ApplyCustomizationsToRendering(this.bracketRenderer, customizations);
            HighlightingOptions.ApplyToRendering(this, customizations);
            this.TextArea.TextView.Redraw();             // manually redraw if default elements didn't change but customized highlightings did
        }
        public void CopyEditorSettingsAndHighlighting(TextEditor source)
        {
            editor.CopySettingsFrom(source);
            string language = source.SyntaxHighlighting != null ? source.SyntaxHighlighting.Name : null;

            editor.TextArea.TextView.LineTransformers.RemoveAll(x => x is HighlightingColorizer);
            var customizedHighlighter = new CustomizingHighlighter(
                new DocumentHighlighter(editor.Document, source.SyntaxHighlighting),
                CustomizedHighlightingColor.FetchCustomizations(language)
                );

            editor.TextArea.TextView.LineTransformers.Insert(0, new HighlightingColorizer(customizedHighlighter));
        }
        public HighlightingColor GetNamedColor(string name)
        {
            TextEditor editor = textEditor.GetService(typeof(TextEditor)) as TextEditor;

            if (editor == null)
            {
                return(null);
            }
            var highlighting = editor.SyntaxHighlighting;

            if (highlighting == null)
            {
                return(null);
            }
            return(CustomizableHighlightingColorizer.CustomizeColor(name, CustomizedHighlightingColor.FetchCustomizations(highlighting.Name)));
        }
Esempio n. 7
0
 static IEnumerable <CustomizedHighlightingColor> FetchCustomizations(string languageName)
 {
     return(CustomizedHighlightingColor.FetchCustomizations(languageName));
 }
        public ISyntaxHighlighter CreateHighlighter(IDocument document, string fileName)
        {
            var def = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName));
            var doc = document.GetService(typeof(TextDocument)) as TextDocument;

            if (def == null || doc == null)
            {
                return(null);
            }
            var baseHighlighter = new DocumentHighlighter(doc, def.MainRuleSet);
            var highlighter     = new CustomizableHighlightingColorizer.CustomizingHighlighter(CustomizedHighlightingColor.FetchCustomizations(def.Name), baseHighlighter);

            return(new DocumentSyntaxHighlighter(document, highlighter, def.Name));
        }
 public HighlightingColor GetNamedColor(string name)
 {
     return(CustomizableHighlightingColorizer.CustomizeColor(name, CustomizedHighlightingColor.FetchCustomizations(highlightingName)));
 }