void AddDummyLine() { LineToIndexTableData dummyLine = null; if (this.Lines.Count == 0) { dummyLine = new LineToIndexTableData(); this.Lines.Add(dummyLine); return; } int lastLineRow = this.Lines.Count > 0 ? this.Lines.Count - 1 : 0; int lastLineHeadIndex = this.GetIndexFromLineNumber(lastLineRow); int lastLineLength = this.GetLengthFromLineNumber(lastLineRow); if (lastLineLength != 0 && this.Document[Document.Length - 1] == Document.NewLine) { int realIndex = lastLineHeadIndex + lastLineLength; if (lastLineRow >= this.stepRow) { realIndex -= this.stepLength; } dummyLine = new LineToIndexTableData(realIndex, 0, true, false, null); this.Lines.Add(dummyLine); } }
/// <summary> /// 行番号に対応する文字列を返します /// </summary> /// <param name="n"></param> /// <returns></returns> public string this[int n] { get { LineToIndexTableData data = this.Lines[n]; string str = this.Document.ToString(this.GetLineHeadIndex(n), data.Length); return(str); } }
/// <summary> /// すべて削除します /// </summary> internal void Clear() { this.ClearLayoutCache(); this.ClearFolding(); this.Lines.Clear(); LineToIndexTableData dummy = new LineToIndexTableData(); this.Lines.Add(dummy); this.stepRow = STEP_ROW_IS_NONE; this.stepLength = 0; Debug.WriteLine("Clear"); }
private void HilightLine(LineToIndexTable lti, int row) { //シンタックスハイライトを行う List <SyntaxInfo> syntax = new List <SyntaxInfo>(); string str = lti[row]; int level = this.Hilighter.DoHilight(str, str.Length, (s) => { if (s.type == TokenType.None || s.type == TokenType.Control) { return; } if (str[s.index + s.length - 1] == Document.NewLine) { s.length--; } syntax.Add(new SyntaxInfo(s.index, s.length, s.type)); }); LineToIndexTableData lineData = lti.GetRaw(row); lineData.Syntax = syntax.ToArray(); }
IList <LineToIndexTableData> CreateLineList(int index, int length, int lineLimitLength = -1) { int startIndex = index; int endIndex = index + length - 1; List <LineToIndexTableData> output = new List <LineToIndexTableData>(); foreach (Tuple <int, int> range in this.ForEachLines(startIndex, endIndex, lineLimitLength)) { int lineHeadIndex = range.Item1; int lineLength = range.Item2; char c = this.Document[lineHeadIndex + lineLength - 1]; bool hasNewLine = c == Document.NewLine; LineToIndexTableData result = new LineToIndexTableData(lineHeadIndex, lineLength, hasNewLine, this.IsFrozneDirtyFlag == false, null); output.Add(result); } if (output.Count > 0) { output.Last().LineEnd = true; } return(output); }
ITextLayout CreateLayout(int row) { ITextLayout layout; LineToIndexTableData lineData = this.Lines[row]; if (lineData.Length == 0) { layout = this.render.CreateLaytout("", null, null, null, this.WrapWidth); } else { int lineHeadIndex = this.GetLineHeadIndex(row); string content = this.Document.ToString(lineHeadIndex, lineData.Length); if (this.CreateingLayout != null) { this.CreateingLayout(this, new CreateLayoutEventArgs(lineHeadIndex, lineData.Length, content)); } var userMarkerRange = from id in this.Document.Markers.IDs from s in this.Document.Markers.Get(id, lineHeadIndex, lineData.Length) let n = Util.ConvertAbsIndexToRelIndex(s, lineHeadIndex, lineData.Length) select n; var watchdogMarkerRange = from s in this.Document.MarkerPatternSet.GetMarkers(new CreateLayoutEventArgs(lineHeadIndex, lineData.Length, content)) let n = Util.ConvertAbsIndexToRelIndex(s, lineHeadIndex, lineData.Length) select n; var markerRange = watchdogMarkerRange.Concat(userMarkerRange); var selectRange = from s in this.Document.Selections.Get(lineHeadIndex, lineData.Length) let n = Util.ConvertAbsIndexToRelIndex(s, lineHeadIndex, lineData.Length) select n; layout = this.render.CreateLaytout(content, lineData.Syntax, markerRange, selectRange, this.WrapWidth); } return(layout); }