コード例 #1
0
		protected void ImportSettingsFrom(DefaultHighlightingStrategy source) {
			if (source == null)
				throw new ArgumentNullException("source");
			mProperties = source.mProperties;
			extensions = source.extensions;
			mDigitColor = source.mDigitColor;
			mDefaultRuleSet = source.mDefaultRuleSet;
			mName = source.mName;
			mRules = source.mRules;
			mEnvironmentColors = source.mEnvironmentColors;
			defaultTextColor = source.defaultTextColor;
		}
コード例 #2
0
        public void AddRuleSet(HighlightRuleSet aRuleSet)
        {
            HighlightRuleSet existing = FindHighlightRuleSet(aRuleSet.Name);

            if (existing != null)
            {
                existing.MergeFrom(aRuleSet);
            }
            else
            {
                mRules.Add(aRuleSet);
            }
        }
コード例 #3
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);
        }
コード例 #4
0
 protected void ImportSettingsFrom(DefaultHighlightingStrategy source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     mProperties        = source.mProperties;
     extensions         = source.extensions;
     mDigitColor        = source.mDigitColor;
     mDefaultRuleSet    = source.mDefaultRuleSet;
     mName              = source.mName;
     mRules             = source.mRules;
     mEnvironmentColors = source.mEnvironmentColors;
     defaultTextColor   = source.defaultTextColor;
 }
コード例 #5
0
 protected virtual 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);
 }
コード例 #6
0
        void ResolveRuleSetReferences()
        {
            foreach (HighlightRuleSet ruleSet in Rules)
            {
                if (ruleSet.Name == null)
                {
                    mDefaultRuleSet = 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 (mDefaultRuleSet == null)
            {
                throw new HighlightingDefinitionInvalidException("No default RuleSet is defined for mode definition " + this.Name);
            }
        }
コード例 #7
0
ファイル: HighlightRuleSet.cs プロジェクト: GodLesZ/svn-dump
		/// <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);
		}
コード例 #8
0
		void UpdateSpanStateVariables() {
			inSpan = (currentSpanStack != null && !currentSpanStack.IsEmpty);
			activeSpan = inSpan ? currentSpanStack.Peek() : null;
			activeRuleSet = GetRuleSet(activeSpan);
		}
コード例 #9
0
		protected virtual 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;
		}
コード例 #10
0
		void ResolveRuleSetReferences() {
			foreach (HighlightRuleSet ruleSet in Rules) {
				if (ruleSet.Name == null) {
					mDefaultRuleSet = 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 (mDefaultRuleSet == null) {
				throw new HighlightingDefinitionInvalidException("No default RuleSet is defined for mode definition " + this.Name);
			}
		}
コード例 #11
0
		public void AddRuleSet(HighlightRuleSet aRuleSet) {
			HighlightRuleSet existing = FindHighlightRuleSet(aRuleSet.Name);
			if (existing != null) {
				existing.MergeFrom(aRuleSet);
			} else {
				mRules.Add(aRuleSet);
			}
		}
コード例 #12
0
 void UpdateSpanStateVariables()
 {
     inSpan        = (currentSpanStack != null && !currentSpanStack.IsEmpty);
     activeSpan    = inSpan ? currentSpanStack.Peek() : null;
     activeRuleSet = GetRuleSet(activeSpan);
 }