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)));
        }
        /// <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));
        }
		CustomizedHighlightingColor AddPlainTextHighlightingColorToCustomColors()
		{
			var color = new CustomizedHighlightingColor() {
				Name = CustomizableHighlightingColorizer.DefaultTextAndBackground
			};
			Colors.Add(color);
			return color;
		}
Exemple #4
0
		public ColorableItems(
			string name,
			CustomizedHighlightingColor color,
			FontsAndColorsItems fontsAndColorsItems)
		{
			this.Name = name;
			this.color = color;
			this.fontsAndColorsItems = fontsAndColorsItems;
		}
		CustomizedHighlightingColor AddDefaultTextAndBackgroundColorToRules()
		{
			var highlightingColor = new CustomizedHighlightingColor();
			highlightingColor.Name = CustomizableHighlightingColorizer.DefaultTextAndBackground;
			
			fakeHighlightingRules.Colors.Add(highlightingColor);
			
			return highlightingColor;
		}
Exemple #6
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
        }
		void CreateColorableItems()
		{
			highlightingColor = new CustomizedHighlightingColor();
			
			fakeHighlightingRules = new FakeCustomizedHighlightingRules();
			fakeHighlightingRules.Colors.Add(highlightingColor);
			
			fontsAndColorsItems = new FontsAndColorsItems(fakeHighlightingRules);
			
			items = new ColorableItems("Name", highlightingColor, fontsAndColorsItems);
		}
        public static List <CustomizedHighlightingColor> LoadColors()
        {
            List <CustomizedHighlightingColor> list = new  List <CustomizedHighlightingColor>();  // PropertyService.Get("CustomizedHighlightingRules", new List<CustomizedHighlightingColor>());
            CustomizedHighlightingColor        cc   = new CustomizedHighlightingColor();

            cc.Background = Colors.Red;
            list.Add(cc);

            // Always make a copy of the list so that the original list cannot be modified without using SaveColors().
            return(new List <CustomizedHighlightingColor>(list));
        }
        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)));
        }
 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)));
 }