Beispiel #1
0
 public bool CanAcceptThisChar(char c)
 {
     //TODO: review here, enable this feature or not
     //some char can't be a start char on blank line
     if (CurrentLine.IsBlankLine &&
         !TextFlowEditSession.CanCaretStopOnThisChar(c))
     {
         return(false);
     }
     return(true);
 }
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 (!TextFlowEditSession.CanCaretStopOnThisChar(c))
                {
                    return;
                }
                //

                //1. new
                var run = new TextRun(this.CurrentSpanStyle, new char[] { c });
                CurrentLine.AddLast(run);
                SetCurrentTextRun(run);
            }
            else
            {
                Run run = CurrentTextRun;
                if (run != null)
                {
                    if (run.IsInsertable)
                    {
                        run.InsertAfter(CurrentTextRunCharIndex, c);
                    }
                    else
                    {
                        AddTextSpan(new TextRun(CurrentSpanStyle, new char[] { c }));
                        return;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();
            SetCurrentCharStepRight();
        }