public HighlightRuleSet FindHighlightRuleSet(string name)
        {
            HighlightRuleSet highlightRuleSet;

            List <HighlightRuleSet> .Enumerator enumerator = this.rules.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    HighlightRuleSet current = enumerator.Current;
                    if (current.Name != name)
                    {
                        continue;
                    }
                    highlightRuleSet = current;
                    return(highlightRuleSet);
                }
                return(null);
            }
            finally
            {
                ((IDisposable)enumerator).Dispose();
            }
            return(highlightRuleSet);
        }
        protected virtual HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)
        {
            HighlightColor color = null;

            if (ruleSet != null)
            {
                if (ruleSet.Reference != null)
                {
                    color = ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength);
                }
                else
                {
                    color = (HighlightColor)ruleSet.KeyWords[document, currentSegment, currentOffset, currentLength];
                }
            }
            // highlight procedures name
            if (color == null && document.ExtraWordList != null)
            {
                if (activeSpan != null && activeSpan.Rule != null)
                {
                    return(color);
                }
                int    wordOffset = currentSegment.Offset + currentOffset;
                string word       = document.GetText(wordOffset, currentLength).ToLower();
                if (word.Length > 0 && document.ExtraWordList.WordExist(word))
                {
                    color = document.ExtraWordList.WordColor;
                }
            }
            return(color);
        }
Beispiel #3
0
 public void AddKeyword(string sWord, Color clr, bool fBold, bool fItalic)
 {
     if (m_oRuleSet == null)
     {
         m_oRuleSet = m_oEditor.Document.HighlightingStrategy.GetRuleSet(null);
     }
     if (m_oRuleSet != null)
     {
         m_oRuleSet.KeyWords[sWord] = new HighlightColor(clr, fBold, fItalic);
     }
 }
        public void AddRuleSet(HighlightRuleSet aRuleSet)
        {
            HighlightRuleSet highlightRuleSet = this.FindHighlightRuleSet(aRuleSet.Name);

            if (highlightRuleSet != null)
            {
                highlightRuleSet.MergeFrom(aRuleSet);
                return;
            }
            this.rules.Add(aRuleSet);
        }
        public void MergeFrom(HighlightRuleSet ruleSet)
        {
            for (int i = 0; i < (int)this.delimiters.Length; i++)
            {
                this.delimiters[i] |= ruleSet.delimiters[i];
            }
            ArrayList arrayLists = this.spans;

            this.spans = (ArrayList)ruleSet.spans.Clone();
            this.spans.AddRange(arrayLists);
        }
 protected virtual HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)
 {
     if (ruleSet == null)
     {
         return(null);
     }
     if (ruleSet.Reference != null)
     {
         return(ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength));
     }
     return((HighlightColor)ruleSet.KeyWords[document, currentSegment, currentOffset, currentLength]);
 }
 public void AddRuleSet(HighlightRuleSet aRuleSet)
 {
     HighlightRuleSet existing = FindHighlightRuleSet(aRuleSet.Name);
     if (existing != null)
     {
         existing.MergeFrom(aRuleSet);
     }
     else
     {
         Rules.Add(aRuleSet);
     }
 }
Beispiel #8
0
        public void AddRuleSet(HighlightRuleSet aRuleSet)
        {
            HighlightRuleSet existing = FindHighlightRuleSet(aRuleSet.Name);

            if (existing != null)
            {
                existing.MergeFrom(aRuleSet);
            }
            else
            {
                Rules.Add(aRuleSet);
            }
        }
		protected void ImportSettingsFrom(DefaultHighlightingStrategy source)
		{
			if (source == null)
				throw new ArgumentNullException("source");
			properties = source.properties;
			extensions = source.extensions;
			digitColor = source.digitColor;
			defaultRuleSet = source.defaultRuleSet;
			name = source.name;
			rules = source.rules;
			environmentColors = source.environmentColors;
			defaultTextColor = source.defaultTextColor;
		}
 protected void ImportSettingsFrom(DefaultHighlightingStrategy source)
 {
     if (source == null)
         throw new ArgumentNullException("source");
     Properties = source.Properties;
     Extensions = source.Extensions;
     DigitColor = source.DigitColor;
     defaultRuleSet = source.defaultRuleSet;
     Name = source.Name;
     Folding = source.Folding;
     Rules = source.Rules;
     DefaultTextColor = source.DefaultTextColor;
 }
Beispiel #11
0
        /// <summary>
        /// Merges spans etc. from the other rule set into this rule set.
        /// </summary>
        public void MergeFrom(HighlightRuleSet ruleSet)
        {
            for (int i = 0; i < delimiters.Length; i++)
            {
                delimiters[i] |= ruleSet.delimiters[i];
            }
            // insert merged spans in front of old spans
            ArrayList oldSpans = spans;

            spans = (ArrayList)ruleSet.spans.Clone();
            spans.AddRange(oldSpans);
            //keyWords.MergeFrom(ruleSet.keyWords);
            //prevMarkers.MergeFrom(ruleSet.prevMarkers);
            //nextMarkers.MergeFrom(ruleSet.nextMarkers);
        }
Beispiel #12
0
 protected void ImportSettingsFrom(DefaultHighlightingStrategy source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     Properties       = source.Properties;
     Extensions       = source.Extensions;
     DigitColor       = source.DigitColor;
     defaultRuleSet   = source.defaultRuleSet;
     Name             = source.Name;
     Folding          = source.Folding;
     Rules            = source.Rules;
     DefaultTextColor = source.DefaultTextColor;
 }
Beispiel #13
0
 protected void ImportSettingsFrom(DarkHighlightingStrategy source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     properties        = source.properties;
     extensions        = source.extensions;
     digitColor        = source.digitColor;
     defaultRuleSet    = source.defaultRuleSet;
     name              = source.name;
     rules             = source.rules;
     environmentColors = source.environmentColors;
     defaultTextColor  = source.defaultTextColor;
 }
        /// <summary>
        ///     Merges spans etc. from the other rule set into this rule set.
        /// </summary>
        public void MergeFrom(HighlightRuleSet ruleSet)
        {
            for (var i = 0; i < Delimiters.Length; i++)
            {
                Delimiters[i] |= ruleSet.Delimiters[i];
            }
            // insert merged spans in front of old spans
            var oldSpans = Spans;

            Spans = ruleSet.Spans.ToList();
            Spans.AddRange(oldSpans);
            //keyWords.MergeFrom(ruleSet.keyWords);
            //prevMarkers.MergeFrom(ruleSet.prevMarkers);
            //nextMarkers.MergeFrom(ruleSet.nextMarkers);
        }
        private void UpdateSpanStateVariables()
        {
            Span span;

            this.inSpan = (this.currentSpanStack == null ? false : !this.currentSpanStack.IsEmpty);
            if (this.inSpan)
            {
                span = this.currentSpanStack.Peek();
            }
            else
            {
                span = null;
            }
            this.activeSpan    = span;
            this.activeRuleSet = this.GetRuleSet(this.activeSpan);
        }
        private void ResolveRuleSetReferences()
        {
            foreach (HighlightRuleSet ruleSet in Rules)
            {
                if (ruleSet.Name == null)
                {
                    defaultRuleSet = ruleSet;
                }

                foreach (Span aSpan in ruleSet.Spans)
                {
                    if (aSpan.Rule != null)
                    {
                        bool found = false;

                        foreach (HighlightRuleSet refSet in Rules)
                        {
                            if (refSet.Name == aSpan.Rule)
                            {
                                found         = true;
                                aSpan.RuleSet = refSet;
                                break;
                            }
                        }

                        if (!found)
                        {
                            aSpan.RuleSet = null;
                            throw new HighlightingDefinitionInvalidException("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + Name);
                        }
                    }
                    else
                    {
                        aSpan.RuleSet = null;
                    }
                }
            }

            if (defaultRuleSet == null)
            {
                throw new HighlightingDefinitionInvalidException("No default RuleSet is defined for mode definition " + Name);
            }
        }
Beispiel #17
0
        void ResolveRuleSetReferences()
        {
            foreach (HighlightRuleSet ruleSet in Rules)
            {
                if (ruleSet.Name == null)
                {
                    defaultRuleSet = ruleSet;
                }

                foreach (Span aSpan in ruleSet.Spans)
                {
                    if (aSpan.Rule != null)
                    {
                        bool found = false;
                        foreach (HighlightRuleSet refSet in Rules)
                        {
                            if (refSet.Name == aSpan.Rule)
                            {
                                found         = true;
                                aSpan.RuleSet = refSet;
                                break;
                            }
                        }
                        if (!found)
                        {
                            MessageBox.Show("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                            aSpan.RuleSet = null;
                        }
                    }
                    else
                    {
                        aSpan.RuleSet = null;
                    }
                }
            }

            if (defaultRuleSet == null)
            {
                MessageBox.Show("No default RuleSet is defined for mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            }
        }
 private void ResolveRuleSetReferences()
 {
     foreach (HighlightRuleSet rule in this.Rules)
     {
         if (rule.Name == null)
         {
             this.defaultRuleSet = rule;
         }
         foreach (Span span in rule.Spans)
         {
             if (span.Rule == null)
             {
                 span.RuleSet = null;
             }
             else
             {
                 bool flag = false;
                 foreach (HighlightRuleSet highlightRuleSet in this.Rules)
                 {
                     if (highlightRuleSet.Name != span.Rule)
                     {
                         continue;
                     }
                     flag         = true;
                     span.RuleSet = highlightRuleSet;
                     break;
                 }
                 if (flag)
                 {
                     continue;
                 }
                 span.RuleSet = null;
                 throw new HighlightingDefinitionInvalidException(string.Concat("The RuleSet ", span.Rule, " could not be found in mode definition ", this.Name));
             }
         }
     }
     if (this.defaultRuleSet == null)
     {
         throw new HighlightingDefinitionInvalidException(string.Concat("No default RuleSet is defined for mode definition ", this.Name));
     }
 }
		/// <summary>
		/// Merges spans etc. from the other rule set into this rule set.
		/// </summary>
		public void MergeFrom(HighlightRuleSet ruleSet)
		{
			for (int i = 0; i < delimiters.Length; i++) {
				delimiters[i] |= ruleSet.delimiters[i];
			}
			// insert merged spans in front of old spans
			ArrayList oldSpans = spans;
			spans = (ArrayList)ruleSet.spans.Clone();
			spans.AddRange(oldSpans);
			//keyWords.MergeFrom(ruleSet.keyWords);
			//prevMarkers.MergeFrom(ruleSet.prevMarkers);
			//nextMarkers.MergeFrom(ruleSet.nextMarkers);
		}
		void UpdateSpanStateVariables() 
		{
			inSpan = (currentSpanStack != null && currentSpanStack.Count > 0);
			activeSpan = inSpan ? (Span)currentSpanStack.Peek() : null;
			activeRuleSet = GetRuleSet(activeSpan);
		}
		HighlightColor GetColor(HighlightRuleSet ruleSet, IDocument document, LineSegment currentSegment, int currentOffset, int currentLength)
		{
			if (ruleSet != null) {
				if (ruleSet.Reference != null) {
					return ruleSet.Highlighter.GetColor(document, currentSegment, currentOffset, currentLength);
				} else {
					return (HighlightColor)ruleSet.KeyWords[document,  currentSegment, currentOffset, currentLength];
				}				
			}
			return null;
		}
		void ResolveRuleSetReferences() 
		{
			foreach (HighlightRuleSet ruleSet in Rules) {
				if (ruleSet.Name == null) {
					defaultRuleSet = ruleSet;
				}
				
				foreach (Span aSpan in ruleSet.Spans) {
					if (aSpan.Rule != null) {
						bool found = false;
						foreach (HighlightRuleSet refSet in Rules) {
							if (refSet.Name == aSpan.Rule) {
								found = true;
								aSpan.RuleSet = refSet;
								break;
							}
						}
						if (!found) {
							MessageBox.Show("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
							aSpan.RuleSet = null;
						}
					} else {
						aSpan.RuleSet = null;
					}
				}
			}
			
			if (defaultRuleSet == null) {
				MessageBox.Show("No default RuleSet is defined for mode definition " + this.Name, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
			}
		}
		public void AddRuleSet(HighlightRuleSet aRuleSet)
		{
			rules.Add(aRuleSet);
		}
		void UpdateSpanStateVariables()
		{
			inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty);
			activeSpan = inSpan ? currentSpanStack.Peek() : null;
			activeRuleSet = GetRuleSet(activeSpan);
		}
		void ResolveRuleSetReferences()
		{
			foreach (HighlightRuleSet ruleSet in Rules) {
				if (ruleSet.Name == null) {
					defaultRuleSet = ruleSet;
				}
				
				foreach (Span aSpan in ruleSet.Spans) {
					if (aSpan.Rule != null) {
						bool found = false;
						foreach (HighlightRuleSet refSet in Rules) {
							if (refSet.Name == aSpan.Rule) {
								found = true;
								aSpan.RuleSet = refSet;
								break;
							}
						}
						if (!found) {
							aSpan.RuleSet = null;
							throw new HighlightingDefinitionInvalidException("The RuleSet " + aSpan.Rule + " could not be found in mode definition " + this.Name);
						}
					} else {
						aSpan.RuleSet = null;
					}
				}
			}
			
			if (defaultRuleSet == null) {
				throw new HighlightingDefinitionInvalidException("No default RuleSet is defined for mode definition " + this.Name);
			}
		}
Beispiel #26
0
 void UpdateSpanStateVariables()
 {
     _inSpan        = (_currentSpanStack != null && !_currentSpanStack.IsEmpty);
     _activeSpan    = _inSpan ? _currentSpanStack.Peek() : null;
     _activeRuleSet = GetRuleSet(_activeSpan);
 }
Beispiel #27
0
 void UpdateSpanStateVariables()
 {
     inSpan        = (currentSpanStack != null && !currentSpanStack.IsEmpty);
     activeSpan    = inSpan ? currentSpanStack.Peek() : null;
     activeRuleSet = GetRuleSet(activeSpan);
 }
Beispiel #28
0
 public void AddRuleSet(HighlightRuleSet aRuleSet)
 {
     rules.Add(aRuleSet);
 }
Beispiel #29
0
 void UpdateSpanStateVariables()
 {
     inSpan        = (currentSpanStack != null && currentSpanStack.Count > 0);
     activeSpan    = inSpan ? (Span)currentSpanStack.Peek() : null;
     activeRuleSet = GetRuleSet(activeSpan);
 }
Beispiel #30
0
 public void AddKeyword(string sWord, Color clr, bool fBold, bool fItalic)
 {
     if (m_oRuleSet == null)
         m_oRuleSet = m_oEditor.Document.HighlightingStrategy.GetRuleSet(null);
     if (m_oRuleSet != null)
         m_oRuleSet.KeyWords[sWord] = new HighlightColor(clr, fBold, fItalic);
 }