/// <summary> /// Retrieves range of characters in the line specified and adds them to the list /// given. /// </summary> public void GetRangeString(List <RichStringMembers> text, int start, int end) { StringBuilder sb; RichStringMembers lastString = default(RichStringMembers); if (text.Count > 0) { lastString = text[text.Count - 1]; } for (int ch = start; ch <= end; ch++) { GlyphFormat format = formattedGlyphs[ch].format; GlyphFormatMembers lastFormat = lastString.Item2; bool formatEqual = lastString.Item1 != null && lastFormat.Item1 == format.Data.Item1 && lastFormat.Item2 == format.Data.Item2 && lastFormat.Item3 == format.Data.Item3 && lastFormat.Item4 == format.Data.Item4; sb = formatEqual ? lastString.Item1 : builder.sbPool.Get(); sb.Append(chars[ch]); var nextString = new RichStringMembers(sb, format.Data); if (lastString.Item1 != nextString.Item1) { text.Add(nextString); } lastString = nextString; } }
protected void SetData(IList <RichStringMembers> text) { for (int n = 0; n < text.Count; n++) { GlyphFormatMembers format = text[n].Item2, empty = GlyphFormat.Empty.Data; bool formatEmpty = format.Item1 == empty.Item1 && format.Item2 == empty.Item2 && format.Item3 == empty.Item3 && format.Item4 == empty.Item4; if (formatEmpty) { text[n] = new RichStringMembers(text[n].Item1, Format.Data); } else if (n == 0) { Format = new GlyphFormat(text[0].Item2); } } lastTextData = text as List <RichStringMembers>; if (!GetIsTextEqual(lastTextData)) { Clear(); formatter.Append(text); AfterFullTextUpdate(); } }
protected void InsertData(IList <RichStringMembers> text, Vector2I start) { for (int n = 0; n < text.Count; n++) { GlyphFormatMembers format = text[n].Item2, empty = GlyphFormat.Empty.Data; bool formatEmpty = format.Item1 == empty.Item1 && format.Item2 == empty.Item2 && format.Item3 == empty.Item3 && format.Item4 == empty.Item4; if (formatEmpty) { text[n] = new RichStringMembers(text[n].Item1, Format.Data); } } formatter.Insert(text, start); AfterFullTextUpdate(); }
/// <summary> /// Builds a list of <see cref="Line.RichChar"/>s from RichString data. /// </summary> protected static void GetRichChars(RichStringMembers richString, Line charBuffer, bool allowSpecialChars) { StringBuilder text = richString.Item1; GlyphFormatMembers formatData = richString.Item2; Color lastColor = default(Color); Vector4 bbColor = default(Vector4); charBuffer.EnsureCapacity(charBuffer.Count + text.Length); for (int n = 0; n < text.Length; n++) { if (formatData.Item4 != lastColor) { lastColor = formatData.Item4; bbColor = QuadBoard.GetQuadBoardColor(formatData.Item4); } if (text[n] >= ' ' || allowSpecialChars && (text[n] == '\n' || text[n] == '\t')) { charBuffer.InsertNew(charBuffer.Chars.Count, text[n], new GlyphFormat(formatData), bbColor); } } }
/// <summary> /// Inserts a string starting on a given line at a given position. /// </summary> /// <param name="start">X = line; Y = ch</param> public override void Insert(RichStringMembers text, Vector2I start) => Insert(new RichStringMembers[] { text }, start);
/// <summary> /// Inserts a string starting on a given line at a given position. /// </summary> /// <param name="start">X = line; Y = ch</param> public abstract void Insert(RichStringMembers text, Vector2I start);
/// <summary> /// Appends text to the end of the document. /// </summary> public virtual void Append(RichStringMembers text) { Insert(text, GetAppendStartIndex()); }