Beispiel #1
0
 EditableRun MakeTextRun(int sourceIndex, int length)
 {
     if (length > 0)
     {
         EditableRun newTextRun = null;
         char[]      newContent = new char[length];
         Array.Copy(_mybuffer, sourceIndex, newContent, 0, length);
         newTextRun             = new EditableTextRun(this.Root, newContent, this.SpanStyle);
         newTextRun.IsLineBreak = this.IsLineBreak;
         newTextRun.UpdateRunWidth();
         return(newTextRun);
     }
     else
     {
         throw new Exception("string must be null or zero length");
     }
 }
Beispiel #2
0
        public void AddCharacter(char c)
        {
            if (CurrentLine.IsBlankLine)
            {
                //TODO: review here, enable this feature or not
                //some char can't be a start char on blank line

                if (!InternalTextLayerController.CanCaretStopOnThisChar(c))
                {
                    return;
                }
                //

                //1. new
                EditableRun t = new EditableTextRun(this.RootGfx,
                                                    c,
                                                    this.CurrentSpanStyle);
                var owner = this.FlowLayer.OwnerRenderElement;
                CurrentLine.AddLast(t);
                SetCurrentTextRun(t);
            }
            else
            {
                EditableRun cRun = CurrentTextRun;
                if (cRun != null)
                {
                    if (cRun.IsInsertable)
                    {
                        cRun.InsertAfter(CurrentTextRunCharIndex, c);
                    }
                    else
                    {
                        AddTextSpan(new EditableTextRun(this.RootGfx, c, this.CurrentSpanStyle));
                        return;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();
            SetCurrentCharStepRight();
        }
Beispiel #3
0
        public void SplitToNewLine()
        {
            EditableRun lineBreakRun = new EditableTextRun(this.RootGfx, '\n', this.CurrentSpanStyle);
            EditableRun currentRun   = CurrentTextRun;

            if (CurrentLine.IsBlankLine)
            {
                CurrentLine.AddLast(lineBreakRun);
            }
            else
            {
                if (CharIndex == -1)
                {
                    CurrentLine.AddFirst(lineBreakRun);
                    SetCurrentTextRun(null);
                }
                else
                {
                    EditableRun rightSplitedPart = EditableRun.InnerRemove(currentRun,
                                                                           CurrentTextRunCharIndex + 1, true);
                    if (rightSplitedPart != null)
                    {
                        CurrentLine.AddAfter(currentRun, rightSplitedPart);
                    }
                    CurrentLine.AddAfter(currentRun, lineBreakRun);
                    if (currentRun.CharacterCount == 0)
                    {
                        CurrentLine.Remove(currentRun);
                    }
                }
            }


            this.TextLayer.TopDownReCalculateContentSize();
            EnsureCurrentTextRun();
        }
Beispiel #4
0
 public static void UnsafeGetRawCharBuffer(EditableTextRun textRun, out char[] rawCharBuffer)
 {
     rawCharBuffer = textRun._mybuffer;
 }