public void DeleteCurrentChar()
        {
            if (CurrentParagraph.Length == 1)
            {
                // Delete current line
                if (CurrentParagraphIndex < Paragraphs.Count - 1)
                {
                    Paragraphs.RemoveAt(CurrentParagraphIndex);
                }
            }
            else if (CursorPosition == CurrentParagraph.Length - 1)
            {
                if (CurrentParagraphIndex < Paragraphs.Count - 1)
                {
                    // merge with next line
                    Paragraph cp = CurrentParagraph;
                    Paragraph np = Paragraphs [CurrentParagraphIndex + 1];
                    cp.Glyphs.RemoveLast();
                    foreach (GlyphChar g in np.Glyphs)
                    {
                        cp.Glyphs.AddLast(g);
                    }
                    cp.NeedsWordWrap = true;
                    cp.WordWrap(BreakWidth);
                    Paragraphs.Remove(np);
                }
            }
            else
            {
                // remove current character from current position
                CurrentParagraph.RemoveChar(CursorPosition);
            }

            //Paragraphs.OnUpdateAsync (CurrentParagraphIndex, BreakWidth);
            Paragraphs.OnUpdate(CurrentParagraphIndex, BreakWidth, false, 250);
            CurrentParagraphIndex = CurrentParagraphIndex.Clamp(0, Paragraphs.Count - 1);
        }
        public void InsertLineBreak()
        {
            if (CursorPosition >= CurrentParagraph.Length - 1)
            {
                if (CurrentParagraphIndex >= Paragraphs.Count - 1)
                {
                    // most common case: Writing at the edge
                    Paragraphs.AddLast(new Paragraph(Paragraphs.Count, BreakWidth, String.Empty, Font, Flags));
                    MoveNextChar();
                }
                else
                {
                    MoveNextChar();
                    Paragraph current = CurrentParagraph;
                    Paragraph para    = new Paragraph(CurrentParagraphIndex, BreakWidth, "\n", Font, Flags);
                    para.LineOffset = current.LineOffset;
                    para.Height     = LineHeight;
                    Paragraphs.Insert(CurrentParagraphIndex, para);
                    //current = CurrentParagraph;
                }
            }
            else if (CursorPosition == 0)
            {
                Paragraph current = CurrentParagraph;
                Paragraph para    = new Paragraph(CurrentParagraphIndex, BreakWidth, "\n", Font, Flags);
                para.LineOffset = current.LineOffset;
                para.Height     = LineHeight;
                para.Top        = current.Top;
                Paragraphs.Insert(CurrentParagraphIndex, para);
                CurrentParagraphIndex++;
            }
            else
            {
                Paragraph      para = new Paragraph(CurrentParagraphIndex + 1, BreakWidth);
                Paragraph      cp   = CurrentParagraph;
                GlyphList.Node np   = cp.Glyphs.Head;
                for (int i = 0; i < CursorPosition - 1; i++)
                {
                    np = np.Next;
                }
                GlyphList.Node npTail = np;

                np = np.Next;
                while (np != null)
                {
                    para.Glyphs.AddLast(np.Value);
                    np = np.Next;
                }
                para.NeedsWordWrap = true;

                // cut np..
                npTail.Next = null;
                cp.Glyphs.ResetCurrent();
                cp.AppendChar('\n', Font, Flags);
                Paragraphs.Insert(++CurrentParagraphIndex, para);
            }

            CurrentParagraphIndex = CurrentParagraphIndex.Clamp(0, Paragraphs.Count - 1);
            CursorPosition        = 0;
            ResetCursorColoumns();
            //Paragraphs.OnUpdateAsync (CurrentParagraphIndex - 1, BreakWidth);
            Paragraphs.OnUpdate(CurrentParagraphIndex - 1, BreakWidth, false, 250);
        }