public void Replace(int start, int count, IEnumerable <ITextItem> _additems) { AncestorRelease(); items.RemoveRange(start, count); items.InsertRange(start, _additems); this.linecount = 1; this.skipcount = isskip ? 1 : 0; for (int i = 0; i < items.Count(); i++) { items[i].Parent = this; items[i].ID = i; items[i].Level = Level + 1; if (items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)items[i]; linecount += trim.GetEnterCount(); } if (items[i] is ITextZone) { ITextZone zone = (ITextZone)items[i]; linecount += zone.LineCount - 1; skipcount += zone.SkipCount; } } AncestorCapture(); }
public static bool GetByteSpaceCount(ITextZone zone, int start, ref int count) { for (int i = start; i >= 0; i--) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int enterid = trim.ToString().LastIndexOf('\n'); if (enterid >= 0) { string text = trim.ToString().Substring(enterid + 1); foreach (char ch in text) { count += TextChar.GetByteSpaceCount(ch); } return(true); } } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); if (GetByteSpaceCount(_zone, 0, ref count)) { return(true); } continue; } foreach (char ch in zone.Items[i].ToString()) { count += TextChar.GetByteSpaceCount(ch); } } return(false); }
public static bool GetPrevLength(ITextZone zone, int start, ref int count) { for (int i = start; i >= 0; i--) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int enterid = trim.ToString().LastIndexOf('\n'); if (enterid >= 0) { count += trim.ToString().Length - enterid - 1; return(true); } } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); if (GetPrevLength(_zone, _zone.Items.Count - 1, ref count)) { return(true); } continue; } count += zone.Items[i].ToString().Length; } return(false); }
public static bool GetNextLength(ITextZone zone, int start, ref int count) { for (int i = start; i < zone.Items.Count; i++) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int enterid = trim.ToString().IndexOf('\n'); if (enterid >= 0) { count += enterid; return(true); } } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); if (GetNextLength(_zone, 0, ref count)) { return(true); } continue; } count += zone.Items[i].ToString().Length; } return(false); }
public static ITextPosition MovePrevLine(ITextZone zone, int start, ref int lineoffset, ref int line, ref int column) { for (int i = start; i >= 0; i--) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int previndex = RefPrevLine(trim.ToString(), ref lineoffset, ref line, ref column); if (previndex >= 0) { return new TextPosition() { Item = trim, ItemIndex = previndex, Line = line, Column = column } } ; } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); if (_zone.LineCount <= lineoffset) { lineoffset -= _zone.LineCount - 1; line -= _zone.LineCount - 1; column = -100000; } else { return(MovePrevLine(_zone, _zone.Items.Count - 1, ref lineoffset, ref line, ref column)); } } } return(null); }
public static ITextPosition MoveNextLine(ITextZone zone, int start, ref int lineoffset, ref int line, ref int column) { for (int i = start; i < zone.Items.Count; i++) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int nextindex = RefNextLine(trim.ToString(), ref lineoffset, ref line, ref column); if (nextindex >= 0) { return new TextPosition() { Item = trim, ItemIndex = nextindex + 1, Line = line, Column = column } } ; } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); if (_zone.LineCount <= lineoffset) { lineoffset -= _zone.LineCount - 1; line += _zone.LineCount - 1; column = -100000; } else { return(MoveNextLine(_zone, 0, ref lineoffset, ref line, ref column)); } } } return(null); }
public static ITextPosition GetPrevLine(ITextZone zone, int start, int line) { for (int i = start; i >= 0; i--) { if (zone.Items[i] is ITextTrim) { ITextTrim trim = (ITextTrim)(zone.Items[i]); int enterid = trim.ToString().LastIndexOf('\n'); if (enterid >= 0) { return new TextPosition() { Item = trim, ItemIndex = enterid, Line = line, Column = -1 } } ; } if (zone.Items[i] is ITextZone) { ITextZone _zone = (ITextZone)(zone.Items[i]); ITextPosition result = GetPrevLine(_zone, _zone.Items.Count - 1, line); if (result != null) { return(result); } } } return(null); }
public TextLine(TextBoxCore _core, ITextKey _left, ITextTrim _enter) : base(_core, _left, null) { if (_enter != null) { Add(_enter); } Doc = _left?.Doc?.Parent; }
public bool HasEnterEnd() { for (int i = Items.Count - 1; i >= 0; i--) { ITextItem item = Items[i]; if (item is ITextTrim) { ITextTrim trim = (ITextTrim)item; return(trim.GetEnterCount() > 0); } if (item is ITextLine) { ITextLine line = (ITextLine)item; return(line.HasEnterEnd()); } return(false); } return(false); }
public void Add(ITextItem item) { AncestorRelease(); item.Parent = this; item.ID = items.Count(); item.Level = Level + 1; items.Add(item); if (item is ITextTrim) { ITextTrim trim = (ITextTrim)item; linecount += trim.GetEnterCount(); } if (item is ITextZone) { ITextZone zone = (ITextZone)item; linecount += zone.LineCount - 1; skipcount += zone.SkipCount; } AncestorCapture(); }
public void Remove(ITextItem item) { AncestorRelease(); for (int i = item.ID + 1; i < items.Count(); i++) { items[i].ID--; } items.Remove(item); item.Parent = null; item.ID = -1; item.Level = -1; if (item is ITextTrim) { ITextTrim trim = (ITextTrim)item; linecount -= trim.GetEnterCount(); } if (item is ITextZone) { ITextZone zone = (ITextZone)item; linecount -= zone.LineCount - 1; skipcount -= zone.SkipCount; } AncestorCapture(); }
public void Insert(int id, ITextItem item) { AncestorRelease(); item.Parent = this; item.ID = id; item.Level = Level + 1; for (int i = id; i < items.Count(); i++) { items[i].ID++; } items.Insert(id, item); if (item is ITextTrim) { ITextTrim trim = (ITextTrim)item; linecount += trim.GetEnterCount(); } if (item is ITextZone) { ITextZone zone = (ITextZone)item; linecount += zone.LineCount - 1; skipcount += zone.SkipCount; } AncestorCapture(); }