/// <summary> /// Analyzes the text using each of the analyzers and returns /// their results as a series of runs. /// </summary> public void GenerateResults(TextAnalyzer textAnalyzer, out Run[] runs, out LineBreakpoint[] breakpoints) { // Initially start out with one result that covers the entire range. // This result will be subdivided by the analysis processes. LinkedRun initialRun = new LinkedRun() { nextRunIndex = 0, textStart = 0, textLength = text_.Length, bidiLevel = (readingDirection_ == ReadingDirection.RightToLeft) ? 1 : 0 }; runs_ = new List<LinkedRun>(); runs_.Add(initialRun); breakpoints_ = new List<LineBreakpoint>(); textAnalyzer.AnalyzeLineBreakpoints(this, 0, text_.Length, this); textAnalyzer.AnalyzeBidi(this, 0, text_.Length, this); textAnalyzer.AnalyzeScript(this, 0, text_.Length, this); textAnalyzer.AnalyzeNumberSubstitution(this, 0, text_.Length, this); //Call each of the analyzers in sequence, recording their results. breakpoints = new LineBreakpoint[breakpoints_.Count]; breakpoints_.CopyTo(breakpoints); // Resequence the resulting runs in order before returning to caller. runs = new Run[runs_.Count]; int nextRunIndex = 0; for (int i = 0; i < runs_.Count; i++) { runs[i] = runs_[nextRunIndex].AsRun; nextRunIndex = runs_[nextRunIndex].nextRunIndex; } }
private void SplitCurrentRun(int splitPosition) { // Splits the current run and adjusts the run values accordingly. int runTextStart = runs_[currentRunIndex_].textStart; if (splitPosition <= runTextStart) { return; // no change } LinkedRun frontHalf = runs_[currentRunIndex_]; LinkedRun backHalf = frontHalf; // Adjust runs' text positions and lengths. int splitPoint = splitPosition - runTextStart; backHalf.textStart += splitPoint; backHalf.textLength -= splitPoint; runs_.Add(backHalf); frontHalf.textLength = splitPoint; frontHalf.nextRunIndex = runs_.Count - 1; runs_[currentRunIndex_] = frontHalf; currentRunIndex_ = runs_.Count - 1; }
/// <summary> /// Analyzes the text using each of the analyzers and returns /// their results as a series of runs. /// </summary> public void GenerateResults(TextAnalyzer textAnalyzer, out Run[] runs, out LineBreakpoint[] breakpoints) { // Initially start out with one result that covers the entire range. // This result will be subdivided by the analysis processes. LinkedRun initialRun = new LinkedRun() { nextRunIndex = 0, textStart = 0, textLength = text_.Length, bidiLevel = (readingDirection_ == ReadingDirection.RightToLeft) ? 1 : 0 }; runs_ = new List <LinkedRun>(); runs_.Add(initialRun); breakpoints_ = new List <LineBreakpoint>(); textAnalyzer.AnalyzeLineBreakpoints(this, 0, text_.Length, this); textAnalyzer.AnalyzeBidi(this, 0, text_.Length, this); textAnalyzer.AnalyzeScript(this, 0, text_.Length, this); textAnalyzer.AnalyzeNumberSubstitution(this, 0, text_.Length, this); //Call each of the analyzers in sequence, recording their results. breakpoints = new LineBreakpoint[breakpoints_.Count]; breakpoints_.CopyTo(breakpoints); // Resequence the resulting runs in order before returning to caller. runs = new Run[runs_.Count]; int nextRunIndex = 0; for (int i = 0; i < runs_.Count; i++) { runs[i] = runs_[nextRunIndex].AsRun; nextRunIndex = runs_[nextRunIndex].nextRunIndex; } }
public void SetNumberSubstitution(int textPosition, int textLength, NumberSubstitution numberSubstitution) { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { int nextRunIndex = FetchNextRunIndex(ref textLength); LinkedRun run = runs_[nextRunIndex]; run.isNumberSubstituted = (numberSubstitution != null); runs_[nextRunIndex] = run; } }
public void SetBidiLevel(int textPosition, int textLength, byte explicitLevel, byte resolvedLevel) { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { int nextRunIndex = FetchNextRunIndex(ref textLength); LinkedRun run = runs_[nextRunIndex]; run.bidiLevel = resolvedLevel; runs_[nextRunIndex] = run; } }
public void SetScriptAnalysis(int textPosition, int textLength, ScriptAnalysis scriptAnalysis) { SetCurrentRun(textPosition); SplitCurrentRun(textPosition); while (textLength > 0) { int nextRunIndex = FetchNextRunIndex(ref textLength); LinkedRun run = runs_[nextRunIndex]; run.script = scriptAnalysis; runs_[nextRunIndex] = run; } }