/// <summary>
 /// Creates a new HighlightingColorizer instance.
 /// </summary>
 /// <param name="ruleSet">The root highlighting rule set.</param>
 public PythonConsoleHighlightingColorizer(HighlightingRuleSet ruleSet, TextDocument document)
     : base(ruleSet)
 {
     if (document == null)
         throw new ArgumentNullException("document");
     this.document = document;
 }
		public CustomizableHighlightingColorizer(HighlightingRuleSet ruleSet, IEnumerable<CustomizedHighlightingColor> customizations)
			: base(ruleSet)
		{
			if (customizations == null)
				throw new ArgumentNullException("customizations");
			this.customizations = customizations;
		}
Пример #3
0
 /// <summary>
 /// Creates a new HighlightingEngine instance.
 /// </summary>
 public HighlightingEngine(HighlightingRuleSet mainRuleSet)
 {
     if (mainRuleSet == null)
     {
         throw new ArgumentNullException("mainRuleSet");
     }
     this.mainRuleSet = mainRuleSet;
 }
Пример #4
0
 /// <summary>
 /// Creates a new HighlightingColorizer instance.
 /// </summary>
 /// <param name="ruleSet">The root highlighting rule set.</param>
 public HighlightingColorizer(HighlightingRuleSet ruleSet)
 {
     if (ruleSet == null)
     {
         throw new ArgumentNullException("ruleSet");
     }
     this.ruleSet = ruleSet;
 }
Пример #5
0
		/// <summary>
		/// Creates a new HighlightingColorizer instance.
		/// </summary>
		/// <param name="textView">The text view for which the highlighting should be provided.</param>
		/// <param name="ruleSet">The root highlighting rule set.</param>
		public HighlightingColorizer(TextView textView, HighlightingRuleSet ruleSet)
		{
			if (textView == null)
				throw new ArgumentNullException("textView");
			if (ruleSet == null)
				throw new ArgumentNullException("ruleSet");
			this.textView = textView;
			this.ruleSet = ruleSet;
			TextViewWeakEventManager.DocumentChanged.AddListener(textView, this);
			OnDocumentChanged();
		}
 /// <summary>
 /// Creates a new DocumentHighlighter instance.
 /// </summary>
 public DocumentHighlighter(TextDocument document, HighlightingRuleSet baseRuleSet)
 {
     if (document == null)
         throw new ArgumentNullException("document");
     if (baseRuleSet == null)
         throw new ArgumentNullException("baseRuleSet");
     this.document = document;
     this.baseRuleSet = baseRuleSet;
     WeakLineTracker.Register(document, this);
     InvalidateHighlighting();
 }
Пример #7
0
 /// <summary>
 /// Creates a new DocumentHighlighter instance.
 /// </summary>
 public DocumentHighlighter(TextDocument document, HighlightingRuleSet baseRuleSet)
 {
     if (document == null)
     {
         throw new ArgumentNullException("document");
     }
     if (baseRuleSet == null)
     {
         throw new ArgumentNullException("baseRuleSet");
     }
     this.document    = document;
     this.baseRuleSet = baseRuleSet;
     WeakLineTracker.Register(document, this);
     InvalidateHighlighting();
 }
Пример #8
0
 /// <summary>
 /// Creates a new HighlightingColorizer instance.
 /// </summary>
 /// <param name="textView">The text view for which the highlighting should be provided.</param>
 /// <param name="ruleSet">The root highlighting rule set.</param>
 public HighlightingColorizer(TextView textView, HighlightingRuleSet ruleSet)
 {
     if (textView == null)
     {
         throw new ArgumentNullException("textView");
     }
     if (ruleSet == null)
     {
         throw new ArgumentNullException("ruleSet");
     }
     this.textView = textView;
     this.ruleSet  = ruleSet;
     TextViewWeakEventManager.DocumentChanged.AddListener(textView, this);
     OnDocumentChanged();
 }
 public HighlightingDefinition(string name)
 {
     Name = name;
     MainRuleSet = new HighlightingRuleSet { Name = "Main" };
     AddRuleSet(MainRuleSet);
 }
Пример #10
0
        private HighlightingRuleSet GetRuleSetFromSyntax()
        {
            if (Syntax == null && Reference.IsBlank())
                return null;

            if (ruleSet == null)
            {
                if (Syntax != null)
                {
                    ruleSet = new HighlightingRuleSet();
                    Syntax.PopulateRuleSet(ruleSet);
                }
                else
                {
                    var lang = Controller.Current.Languages.GetLanguageByName(Reference);

                    if (!lang.HasSyntax)
                    {
                        Reference = null;
                        return null;
                    }

                    if (!lang.HaveInitializedChildren)
                    {
                        lang.InitializeChildren();
                    }

                    ruleSet = lang.Syntax.GetHighlighter().MainRuleSet;
                }
            }

            return ruleSet;
        }
Пример #11
0
		/// <summary>
		/// Creates a new HighlightingEngine instance.
		/// </summary>
		public HighlightingEngine(HighlightingRuleSet mainRuleSet)
		{
			if (mainRuleSet == null)
				throw new ArgumentNullException("mainRuleSet");
			this.mainRuleSet = mainRuleSet;
		}
 private void AddRuleSet(HighlightingRuleSet ruleSet)
 {
     if (ruleSet != null && !string.IsNullOrEmpty(ruleSet.Name) && !_namedRuleSets.ContainsKey(ruleSet.Name)) _namedRuleSets.Add(ruleSet.Name, ruleSet);
 }
Пример #13
0
 public TextViewDocumentHighlighter(TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet)
     : base(document, baseRuleSet)
 {
     Debug.Assert(textView != null);
     this.textView = textView;
 }
Пример #14
0
 public HighlightingColorizer(TextView textView, HighlightingRuleSet ruleSet)
     : this(ruleSet)
 {
 }
Пример #15
0
        public void PopulateRuleSet(HighlightingRuleSet ruleSet)
        {
            // rules
            if (Rules != null)
            {
                foreach (var rule in Rules)
                    ruleSet.Rules.Add(rule.GetRule());
            }

            // spans
            if (Spans != null)
            {
                foreach (var span in Spans)
                    ruleSet.Spans.Add(span.GetSpan());
            }
        }
Пример #16
0
 public TextViewDocumentHighlighter(HighlightingColorizer colorizer, TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet)
     : base(document, baseRuleSet)
 {
     Debug.Assert(colorizer != null);
     Debug.Assert(textView != null);
     this.colorizer = colorizer;
     this.textView  = textView;
 }
Пример #17
0
 public TextViewDocumentHighlighter(HighlightingColorizer colorizer, TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet)
     : base(document, baseRuleSet)
 {
     Debug.Assert(colorizer != null);
     Debug.Assert(textView != null);
     this.colorizer = colorizer;
     this.textView = textView;
 }
			public TextViewDocumentHighlighter(TextView textView, TextDocument document, HighlightingRuleSet baseRuleSet)
				: base(document, baseRuleSet)
			{
				Debug.Assert(textView != null);
				this.textView = textView;
			}
Пример #19
0
        void HighlightLineInternal(DocumentLine line)
        {
            lineStartOffset = line.Offset;
            lineText        = line.Text;
            position        = 0;
            ResetColorStack();
            HighlightingRuleSet currentRuleSet    = this.CurrentRuleSet;
            Stack <Match[]>     storedMatchArrays = new Stack <Match[]>();

            Match[] matches      = AllocateMatchArray(currentRuleSet.Spans.Count);
            Match   endSpanMatch = null;

            while (true)
            {
                for (int i = 0; i < matches.Length; i++)
                {
                    if (matches[i] == null || (matches[i].Success && matches[i].Index < position))
                    {
                        matches[i] = currentRuleSet.Spans[i].StartExpression.Match(lineText, position);
                    }
                }
                if (endSpanMatch == null && !spanStack.IsEmpty)
                {
                    endSpanMatch = spanStack.Peek().EndExpression.Match(lineText, position);
                }

                Match firstMatch = Minimum(matches, endSpanMatch);
                if (firstMatch == null)
                {
                    break;
                }

                HighlightNonSpans(firstMatch.Index);

                Debug.Assert(position == firstMatch.Index);

                if (firstMatch == endSpanMatch)
                {
                    PopColor();                     // pop SpanColor
                    HighlightingSpan poppedSpan = spanStack.Peek();
                    PushColor(poppedSpan.EndColor);
                    position = firstMatch.Index + firstMatch.Length;
                    PopColor();                     // pop EndColor
                    spanStack      = spanStack.Pop();
                    currentRuleSet = this.CurrentRuleSet;
                    //FreeMatchArray(matches);
                    if (storedMatchArrays.Count > 0)
                    {
                        matches = storedMatchArrays.Pop();
                        int index = currentRuleSet.Spans.IndexOf(poppedSpan);
                        Debug.Assert(index >= 0 && index < matches.Length);
                        if (matches[index].Index == position)
                        {
                            throw new InvalidOperationException(
                                      "A highlighting span matched 0 characters, which would cause an endlees loop.\n" +
                                      "Change the highlighting definition so that either the start or the end regex matches at least one character.\n" +
                                      "Start regex: " + poppedSpan.StartExpression + "\n" +
                                      "End regex: " + poppedSpan.EndExpression);
                        }
                    }
                    else
                    {
                        matches = AllocateMatchArray(currentRuleSet.Spans.Count);
                    }
                }
                else
                {
                    int index = Array.IndexOf(matches, firstMatch);
                    Debug.Assert(index >= 0);
                    HighlightingSpan newSpan = currentRuleSet.Spans[index];
                    spanStack      = spanStack.Push(newSpan);
                    currentRuleSet = this.CurrentRuleSet;
                    storedMatchArrays.Push(matches);
                    matches = AllocateMatchArray(currentRuleSet.Spans.Count);
                    PushColor(newSpan.StartColor);
                    position = firstMatch.Index + firstMatch.Length;
                    PopColor();
                    PushColor(newSpan.SpanColor);
                }
                endSpanMatch = null;
            }
            HighlightNonSpans(line.Length);

            PopAllColors();
        }
		public HighlightingColorizer(TextView textView, HighlightingRuleSet ruleSet)
			: this(ruleSet)
		{
		}
		/// <summary>
		/// Creates a new HighlightingColorizer instance.
		/// </summary>
		/// <param name="ruleSet">The root highlighting rule set.</param>
		public HighlightingColorizer(HighlightingRuleSet ruleSet)
		{
			if (ruleSet == null)
				throw new ArgumentNullException("ruleSet");
			this.ruleSet = ruleSet;
		}
Пример #22
0
 public HighlightingDefinition(string name)
 {
     _name = name;
     _rules = new HighlightingRuleSet();
 }
Пример #23
0
 public MixedHighlightingColorizer(HighlightingRuleSet ruleSet, TextEditor textEditor) : base(ruleSet)
 {
     this.textEditor = textEditor;
 }