internal void ReplaceRegexAll(LineToIndexTable layoutlines, Regex regex, string pattern, bool groupReplace) { for (int i = 0; i < layoutlines.Count; i++) { int lineHeadIndex = layoutlines.GetIndexFromLineNumber(i), lineLength = layoutlines.GetLengthFromLineNumber(i); int left = lineHeadIndex, right = lineHeadIndex; string output; output = regex.Replace(layoutlines[i], (m) => { if (groupReplace) { return(m.Result(pattern)); } else { return(pattern); } }); using (this.rwlock.WriterLock()) { //空行は削除する必要はない if (lineHeadIndex < this.buf.Count) { this.buf.RemoveRange(lineHeadIndex, lineLength); } this.buf.InsertRange(lineHeadIndex, output); } this.Update(this, new DocumentUpdateEventArgs(UpdateType.Replace, lineHeadIndex, lineLength, output.Length, i)); } }
internal void ReplaceAll(LineToIndexTable layoutlines, string target, string pattern, bool ci = false) { TextSearch ts = new TextSearch(target, ci); char[] pattern_chars = pattern.ToCharArray(); for (int i = 0; i < layoutlines.Count; i++) { int lineHeadIndex = layoutlines.GetIndexFromLineNumber(i), lineLength = layoutlines.GetLengthFromLineNumber(i); int left = lineHeadIndex, right = lineHeadIndex; int newLineLength = lineLength; while ((right = ts.IndexOf(this.buf, left, lineHeadIndex + newLineLength)) != -1) { using (this.rwlock.WriterLock()) { this.buf.RemoveRange(right, target.Length); this.buf.InsertRange(right, pattern_chars); } left = right + pattern.Length; newLineLength += pattern.Length - target.Length; } this.Update(this, new DocumentUpdateEventArgs(UpdateType.Replace, lineHeadIndex, lineLength, newLineLength, i)); } }
public void DrawOneLine(Document doc, LineToIndexTable lti, int row, double x, double y, PreDrawOneLineHandler PreDrawOneLine) { int lineLength = lti.GetLengthFromLineNumber(row); if (lineLength == 0 || this.render == null || this.render.IsDisposed) { return; } MyTextLayout layout = (MyTextLayout)lti.GetLayout(row); if (PreDrawOneLine != null) { PreDrawOneLine(layout, lti, row, x, y); } if (layout.Markers != null) { foreach (Marker sel in layout.Markers) { if (sel.length == 0 || sel.start == -1) { continue; } Color4 color = new Color4() { Alpha = sel.color.A, Red = sel.color.R, Blue = sel.color.B, Green = sel.color.G }; if (sel.hilight == HilightType.Url) { color = this.Url; } this.DrawMarkerEffect(layout, sel.hilight, sel.start, sel.length, x, y, sel.isBoldLine, color); } } if (layout.Selects != null) { foreach (Selection sel in layout.Selects) { if (sel.length == 0 || sel.start == -1) { continue; } this.DrawMarkerEffect(layout, HilightType.Select, sel.start, sel.length, x, y, false); } } if (this.ShowFullSpace || this.ShowHalfSpace || this.ShowTab) { string str = lti[row]; D2D.GeometryRealization geo = null; for (int i = 0; i < lineLength; i++) { Point pos = new Point(0, 0); if (this.ShowTab && str[i] == '\t') { pos = layout.GetPostionFromIndex(i); geo = this._factory.CreateSymbol(ShowSymbol.Tab, this.format); } else if (this.ShowFullSpace && str[i] == ' ') { pos = layout.GetPostionFromIndex(i); geo = this._factory.CreateSymbol(ShowSymbol.FullSpace, this.format); } else if (this.ShowHalfSpace && str[i] == ' ') { pos = layout.GetPostionFromIndex(i); geo = this._factory.CreateSymbol(ShowSymbol.HalfSpace, this.format); } if (geo != null) { var old_trans = this.render.Transform; this.render.Transform = SharpDX.Matrix3x2.Translation(new Vector2((float)(pos.X + x), (float)(pos.Y + y))); this.render.DrawGeometryRealization(geo, this._factory.GetSolidColorBrush(this.ControlChar)); this.render.Transform = old_trans; geo = null; } } } layout.Draw(this.render, (float)x, (float)y, this._factory.GetSolidColorBrush(this.Foreground)); }