コード例 #1
0
ファイル: StyleRuns.cs プロジェクト: andyhebear/Continuum
 public StyleRuns(Boss boss, string path, int edit, StyleRun[] runs)
 {
     Boss = boss;
     Path = path;
     Edit = edit;
     Runs = runs;
 }
コード例 #2
0
ファイル: CurrentStyles.cs プロジェクト: andyhebear/Continuum
        private void DoApplyStyle(StyleRun run, int length)
        {
            NSRange range = new NSRange(run.Offset, run.Length);
            if (run.Offset + run.Length > length)	// this may happen if the text is edited while we are applying runs
                return;
            if (run.Length == 0)
                return;

            if (run.Type == "ParseError")			// HighlightError handles build errors
            {
                range = AdjustRangeForZeroWidthChars(m_controller.Text, range);
                m_storage.addAttribute_value_range(Externs.NSUnderlineStyleAttributeName, NSNumber.Create(2), range);
                m_storage.addAttribute_value_range(Externs.NSUnderlineColorAttributeName, ms_errorColor, range);
            }
            else
            {
                if (!ms_attributes.ContainsKey(run.Type))
                {
                    DoWriteError("Styles.rtf does not have a {0} element.", run.Type);

                    var dict = NSMutableDictionary.Create();
                    dict.addEntriesFromDictionary(ms_attributes["Default"]);
                    dict.setObject_forKey(NSString.Create(run.Type), NSString.Create("style name"));

                    ms_attributes[run.Type] = dict.Retain();
                }

                m_storage.addAttributes_range(ms_attributes[run.Type], range);
            }
        }
コード例 #3
0
ファイル: CurrentStyles.cs プロジェクト: andyhebear/Continuum
        // Note that we don't apply the runs at the start which match runs we have already
        // applied. This speeds things up a fair amount and also prevents the text from
        // jumping around when lines have different heights (the text view has to redo
        // formatting for every line we touch). It might also be able to skip matching runs
        // at the end, but that is harder because the offsets won't line up.
        public void Reset(int edit, StyleRun[] runs)
        {
            m_edit = edit;

            int matchCount = 0;
            int max = Math.Min(m_appliedRuns.Count, runs.Length);
            for (int i = 0; i < max && m_appliedRuns[i] == runs[i] && m_appliedRuns[i].Offset + m_appliedRuns[i].Length < m_editStart; ++i)
            {
                ++matchCount;
            }
            Log.WriteLine(TraceLevel.Verbose, "Styler", "skipping {0} runs at the start", matchCount);

            if (matchCount < m_appliedRuns.Count)
                m_appliedRuns.RemoveRange(matchCount, m_appliedRuns.Count - matchCount);

            m_currentRuns = new List<StyleRun>(runs.Length - matchCount);
            for (int i = matchCount; i < runs.Length; ++i)
                m_currentRuns.Add(runs[i]);
            Log.WriteLine(TraceLevel.Verbose, "Styler", "queuing {0} runs", m_currentRuns.Count);

            m_editStart = int.MaxValue;
        }