public void Remove(int index, int count = 1) { if (index + count > builder.Length) { count = builder.Length - index; } if (count < 1) { return; } int start = index; int end = index + count; emojis.RemoveAll((o) => { return(o.pos >= start & o.pos <= end); }); for (int i = 0; i < emojis.Count; i++) { if (emojis[i].pos > index) { emojis[i].pos -= count; } } builder.Remove(index, count); m_str = builder.ToString(); f_str = EmojiMap.EmojiToFullString(m_str, emojis); }
public void Insert(int index, EmojiString emoji) { if (index > m_str.Length) { index = m_str.Length; } var list = emoji.emojis; for (int i = 0; i < list.Count; i++) { list[i].pos += index; } string str = emoji.FilterString; builder.Insert(index, str); int l = str.Length; for (int i = 0; i < emojis.Count; i++)//将后面的表情符位置往后移 { if (emojis[i].pos >= index) { emojis[i].pos += l; } } emojis.AddRange(list); emojis.Sort((a, b) => { return(a.pos > b.pos ? 1 : -1); }); m_str = builder.ToString(); f_str = EmojiMap.EmojiToFullString(m_str, emojis); }