Пример #1
0
        public SelectionRangeInfo SplitSelectedText(VisualSelectionRange selectionRange)
        {
            SelectionRangeInfo newPoints = CurrentLine.Split(selectionRange);

            EnsureCurrentTextRun();
            return(newPoints);
        }
Пример #2
0
        internal void WriteInfo(VisualSelectionRange range)
        {
            if (range == null)
            {
                return;
            }

            WriteInfo(range.ToString());
        }
Пример #3
0
        public void RemoveSelectedTextRuns(VisualSelectionRange selectionRange)
        {
            int precutIndex = selectionRange.StartPoint.LineCharIndex;

            CurrentLine.Remove(selectionRange);
            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();
            EnsureCurrentTextRun(precutIndex);
        }
Пример #4
0
        protected Rectangle GetSelectionUpdateArea()
        {
            VisualSelectionRange selectionRange = _editSession.SelectionRange;

            if (selectionRange != null && selectionRange.IsValid)
            {
                return(_editSession.SelectionRange.GetSelectionUpdateArea());
            }
            else
            {
                return(Rectangle.Empty);
            }
        }
Пример #5
0
        public void StartSelect()
        {
            if (_textLineWriter != null)
            {
                _selectionRange = new VisualSelectionRange(GetCurrentPointInfo(), GetCurrentPointInfo());
            }
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                _dbugActivityRecorder.WriteInfo("TxLMan::StartSelect");
            }
#endif
        }
Пример #6
0
        public void RemoveSelectedTextRuns(VisualSelectionRange selectionRange)
        {
#if DEBUG
            //if (!CurrentLine.dbugHasOwner)
            //{

            //}
#endif
            int precutIndex = selectionRange.StartPoint.LineCharIndex;
            CurrentLine.Remove(selectionRange);
            InvalidateCurrentRun();

            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();
            SetCurrentCharIndex2(precutIndex);
        }
Пример #7
0
        public void CancelSelect()
        {
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                _dbugActivityRecorder.WriteInfo("TxLMan::CancelSelect");
            }
#endif
            if (_selectionRange != null)
            {
                //invalidate graphic area?

                _textLayer.ClientLineBubbleupInvalidateArea(_selectionRange.GetSelectionUpdateArea());
            }
            _selectionRange = null;
            SelectionCanceled?.Invoke(this, EventArgs.Empty);
        }
Пример #8
0
        public void DoTab()
        {
            if (!_isEditable)
            {
                return;
            }
            //
            if (_editSession.SelectionRange != null)
            {
                VisualSelectionRange visualSelectionRange = _editSession.SelectionRange;
                visualSelectionRange.SwapIfUnOrder();
                if (visualSelectionRange.IsValid && !visualSelectionRange.IsOnTheSameLine)
                {
                    InvalidateGraphicOfCurrentSelectionArea();
                    //
                    _editSession.DoTabOverSelectedRange();
                    return; //finish here
                }
            }
            //------------
            //do tab as usuall
            int insertAt = _editSession.CurrentLineCharIndex;

            for (int i = NumOfWhitespaceForSingleTab; i >= 0; --i)
            {
                _editSession.AddCharToCurrentLine(' ');
            }

            if (_textSurfaceEventListener != null)
            {
                TextSurfaceEventListener.NotifyStringAdded(_textSurfaceEventListener,
                                                           insertAt, new string(' ', NumOfWhitespaceForSingleTab));
            }

            InvalidateGraphicOfCurrentLineArea();
        }
Пример #9
0
        internal SelectionRangeInfo Split(VisualSelectionRange selectionRange)
        {
            selectionRange.SwapIfUnOrder();

            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.Run == endPoint.Run)
            {
                Run toBeCutTextRun = startPoint.Run;

                CopyRun leftPart   = toBeCutTextRun.LeftCopy(startPoint.RunLocalSelectedIndex);
                CopyRun middlePart = toBeCutTextRun.Copy(startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex);
                CopyRun rightPart  = toBeCutTextRun.Copy(endPoint.RunLocalSelectedIndex);

                EditableVisualPointInfo newStartRangePointInfo = null;
                EditableVisualPointInfo newEndRangePointInfo   = null;
                TextLineBox             line = this;

                if (startPoint.LineId != _currentLineNumber)
                {
                    line = _textFlowLayer.GetTextLine(startPoint.LineId);
                }

                line.LocalSuspendLineReArrange();

                if (leftPart != null)
                {
                    Run leftRun = line.AddBefore(toBeCutTextRun, leftPart);
                    newStartRangePointInfo = CreateTextPointInfo(
                        startPoint.LineId, startPoint.LineCharIndex, startPoint.X,
                        leftRun,
                        startPoint.TextRunCharOffset, startPoint.TextRunPixelOffset);
                }
                else
                {
                    //no left part,
                    //so we connect to prev text run

                    Run prevTxtRun = startPoint.Run.PrevRun;
                    if (prevTxtRun != null)
                    {
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId, startPoint.LineCharIndex, startPoint.X,
                            prevTxtRun,
                            startPoint.TextRunCharOffset - leftPart.CharacterCount,
                            startPoint.TextRunPixelOffset - prevTxtRun.Width);
                    }
                    else
                    {
                        //no prev run, we are at the begining of the line
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId,
                            startPoint.LineCharIndex,
                            0,
                            null,
                            0, 0);
                    }
                }

                if (rightPart != null)
                {
                    Run rightRun = line.AddAfter(toBeCutTextRun, rightPart);
                    newEndRangePointInfo =
                        CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            null, ///??
                            startPoint.TextRunCharOffset + middlePart.CharacterCount,
                            startPoint.TextRunPixelOffset + MeasureCopyRunLength(middlePart).Width);
                }
                else
                {
                    Run nextTxtRun = endPoint.Run.NextRun;
                    if (nextTxtRun != null)
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            null,  ///??
                            endPoint.TextRunPixelOffset + endPoint.Run.CharacterCount,
                            endPoint.TextRunPixelOffset + endPoint.Run.Width);
                    }
                    else
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            null,
                            endPoint.TextRunCharOffset,
                            endPoint.TextRunPixelOffset);
                    }
                }

                if (middlePart != null)
                {
                    line.AddAfter(toBeCutTextRun, middlePart);
                }
                else
                {
                    throw new NotSupportedException();
                }
                line.Remove(toBeCutTextRun);
                line.LocalResumeLineReArrange();
                return(new SelectionRangeInfo(newStartRangePointInfo, newEndRangePointInfo));
            }
            else
            {
                TextLineBox workingLine = this;
                if (startPoint.LineId != _currentLineNumber)
                {
                    workingLine = _textFlowLayer.GetTextLine(startPoint.LineId);
                }
                EditableVisualPointInfo newStartPoint = workingLine.Split(startPoint);
                workingLine = this;
                if (endPoint.LineId != _currentLineNumber)
                {
                    workingLine = _textFlowLayer.GetTextLine(endPoint.LineId);
                }

                EditableVisualPointInfo newEndPoint = workingLine.Split(endPoint);
                return(new SelectionRangeInfo(newStartPoint, newEndPoint));
            }
        }
Пример #10
0
        internal void Remove(VisualSelectionRange selectionRange)
        {
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.Run != null)
            {
                if (startPoint.Run == endPoint.Run)
                {
                    Run removedRun = startPoint.Run;
                    Run.InnerRemove(removedRun,
                                    startPoint.RunLocalSelectedIndex,
                                    endPoint.LineCharIndex - startPoint.LineCharIndex, false);
                    if (removedRun.CharacterCount == 0)
                    {
                        if (startPoint.LineId == _currentLineNumber)
                        {
                            this.Remove(removedRun);
                        }
                        else
                        {
                            TextLineBox line = _textFlowLayer.GetTextLine(startPoint.LineId);
                            line.Remove(removedRun);
                        }
                    }
                }
                else
                {
                    GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine);

                    EditableVisualPointInfo newStartPoint = startLine.Split(startPoint);
                    EditableVisualPointInfo newStopPoint  = stopLine.Split(endPoint);

                    if (startLine == stopLine)
                    {
                        if (newStartPoint.Run != null)
                        {
                            LinkedList <Run> tobeRemoveRuns = new LinkedList <Run>();
                            if (newStartPoint.LineCharIndex == 0)
                            {
                                foreach (Run t in _textFlowLayer.TextRunForward(
                                             newStartPoint.Run,
                                             newStopPoint.Run))
                                {
                                    tobeRemoveRuns.AddLast(t);
                                }
                            }
                            else
                            {
                                foreach (Run t in _textFlowLayer.TextRunForward(
                                             newStartPoint.Run.NextRun,
                                             newStopPoint.Run))
                                {
                                    tobeRemoveRuns.AddLast(t);
                                }
                            }
                            startLine.LocalSuspendLineReArrange();
                            foreach (Run t in tobeRemoveRuns)
                            {
                                startLine.Remove(t);
                            }
                            startLine.LocalResumeLineReArrange();
                        }
                        else
                        {
                            //this may be the blank line
                            startLine.Clear();
#if DEBUG
                            //TODO: review here again
                            //System.Diagnostics.Debug.WriteLine("EditableTextLine_adv1");
#endif
                        }
                    }
                    else
                    {
                        int startLineId = newStartPoint.LineId;
                        int stopLineId  = newStopPoint.LineId;
                        if (newStopPoint.LineCharIndex > 0)
                        {
                            stopLine.RemoveLeft(newStopPoint.Run);
                        }
                        for (int i = stopLineId - 1; i > startLineId; i--)
                        {
                            TextLineBox line = _textFlowLayer.GetTextLine(i);
                            line.Clear();
                            line.JoinWithNextLine();
                        }
                        if (newStartPoint.LineCharIndex == 0)
                        {
                            startLine.RemoveRight(newStartPoint.Run);
                        }
                        else
                        {
                            Run nextRun = (newStartPoint.Run).NextRun;
                            if (nextRun != null)
                            {
                                startLine.RemoveRight(nextRun);
                            }
                        }
                        startLine.JoinWithNextLine();
                    }
                }
            }
            else
            {
                GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine);
                EditableVisualPointInfo newStartPoint = startLine.Split(startPoint);
                EditableVisualPointInfo newStopPoint  = stopLine.Split(endPoint);
                if (startLine == stopLine)
                {
                    if (newStartPoint.Run != null)
                    {
                        LinkedList <Run> tobeRemoveRuns = new LinkedList <Run>();
                        if (newStartPoint.LineCharIndex == -1)
                        {
                            foreach (Run t in _textFlowLayer.TextRunForward(
                                         newStartPoint.Run,
                                         newStopPoint.Run))
                            {
                                tobeRemoveRuns.AddLast(t);
                            }
                        }
                        else
                        {
                            foreach (Run t in _textFlowLayer.TextRunForward(
                                         newStartPoint.Run.NextRun,
                                         newStopPoint.Run))
                            {
                                tobeRemoveRuns.AddLast(t);
                            }
                        }
                        foreach (Run t in tobeRemoveRuns)
                        {
                            startLine.Remove(t);
                        }
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
                else
                {
                    int startLineId = newStartPoint.LineId;
                    int stopLineId  = newStopPoint.LineId;
                    if (newStopPoint.LineCharIndex > -1)
                    {
                        stopLine.RemoveLeft(newStopPoint.Run);
                    }
                    for (int i = stopLineId - 1; i > startLineId; i--)
                    {
                        TextLineBox line = _textFlowLayer.GetTextLine(i);
                        line.Clear();
                        line.JoinWithNextLine();
                    }
                    if (newStartPoint.LineCharIndex == -1)
                    {
                        //TODO: review here again
                        //at this point newStartPoint.TextRun should always null
                        if (newStartPoint.Run != null)
                        {
                            startLine.RemoveRight(newStartPoint.Run);
                        }
                    }
                    else
                    {
                        //at this point newStartPoint.TextRun should always null
                        //TODO newStartPoint.TextRun == null???
                        if (newStartPoint.Run != null)
                        {
                            Run nextRun = newStartPoint.Run.NextRun;
                            if (nextRun != null)
                            {
                                startLine.RemoveRight(nextRun);
                            }
                        }
                    }
                    startLine.JoinWithNextLine();
                }
            }
        }
Пример #11
0
        internal void DrawChildContentLcdEffectText(DrawBoard d, UpdateArea updateArea, VisualSelectionRange selRange)
        {
            List <TextLineBox> lines = _lines;
            int  renderAreaTop       = updateArea.Top;
            int  renderAreaBottom    = updateArea.Bottom;
            bool foundFirstLine      = false;
            int  j = lines.Count;

            int enter_canvasX = d.OriginX;
            int enter_canvasY = d.OriginY;

            Rectangle currentClip    = d.CurrentClipRect;
            Color     prev_colorHint = d.TextBackgroundColorHint;


            for (int i = 0; i < j; ++i)
            {
                //draw textline, along with visual selection range

                TextLineBox line    = lines[i];
                int         linetop = line.Top;

                if (!foundFirstLine)
                {
                    if (linetop + line.ActualLineHeight < renderAreaTop)
                    {
                        continue;
                    }
                    else
                    {
                        foundFirstLine = true;
                    }
                }
                else
                {
                    if (linetop > renderAreaBottom)
                    {
                        if (VisualLineOverlapped)
                        {
                            //more check
                            if (i < j - 1)
                            {
                                //check next line
                                TextLineBox lowerLine = lines[i + 1];
                                if (lowerLine.Top - lowerLine.OverlappedTop > linetop)
                                {
                                    break;
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                updateArea.OffsetY(-linetop); //offset

                switch (selRange.GetLineClip(i, out int clipLeft, out int clipWidth))
                {
Пример #12
0
 //
 public void CopySelectedTextRuns(VisualSelectionRange selectionRange, List <EditableRun> output)
 {
     _currentLine.Copy(selectionRange, output);
 }
Пример #13
0
 public EditableVisualPointInfo[] SplitSelectedText(VisualSelectionRange selectionRange)
 {
     EditableVisualPointInfo[] newPoints = CurrentLine.Split(selectionRange);
     EnsureCurrentTextRun();
     return(newPoints);
 }
Пример #14
0
        public void Copy(VisualSelectionRange selectionRange, List <EditableRun> output)
        {
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.TextRun != null)
            {
                if (startPoint.TextRun == endPoint.TextRun)
                {
                    EditableRun elem =
                        startPoint.TextRun.Copy(
                            startPoint.RunLocalSelectedIndex,
                            endPoint.LineCharIndex - startPoint.LineCharIndex);
                    if (elem != null)
                    {
                        output.Add(elem);
                    }
                }
                else
                {
                    EditableTextLine startLine = null;
                    EditableTextLine stopLine  = null;
                    if (startPoint.LineId == _currentLineNumber)
                    {
                        startLine = this;
                    }
                    else
                    {
                        startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                    }
                    if (endPoint.LineId == _currentLineNumber)
                    {
                        stopLine = this;
                    }
                    else
                    {
                        stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                    }
                    if (startLine == stopLine)
                    {
                        EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }
                        if (startPoint.TextRun.NextTextRun != endPoint.TextRun)
                        {
                            foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun))
                            {
                                output.Add(t.Clone());
                            }
                        }

                        EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(endPoint.RunLocalSelectedIndex);
                        if (preCutTextRun != null)
                        {
                            output.Add(preCutTextRun);
                        }
                    }
                    else
                    {
                        int startLineId = startPoint.LineId;
                        int stopLineId  = endPoint.LineId;
                        startLine.RightCopy(startPoint, output);
                        for (int i = startLineId + 1; i < stopLineId; i++)
                        {
                            output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                            EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                            line.Copy(output);
                        }
                        if (endPoint.LineCharIndex > -1)
                        {
                            output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                            stopLine.LeftCopy(endPoint, output);
                        }
                    }
                }
            }
            else
            {
                EditableTextLine startLine = null;
                EditableTextLine stopLine  = null;
                if (startPoint.LineId == _currentLineNumber)
                {
                    startLine = this;
                }
                else
                {
                    startLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }

                if (endPoint.LineId == _currentLineNumber)
                {
                    stopLine = this;
                }
                else
                {
                    stopLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                }


                if (startLine == stopLine)
                {
                    if (startPoint.LineCharIndex == -1)
                    {
                        foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun, endPoint.TextRun.PrevTextRun))
                        {
                            output.Add(t.Clone());
                        }
                        EditableRun postCutTextRun = endPoint.TextRun.Copy(endPoint.RunLocalSelectedIndex + 1);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }
                    }
                    else
                    {
                        EditableRun postCutTextRun = startPoint.TextRun.Copy(startPoint.RunLocalSelectedIndex + 1);
                        if (postCutTextRun != null)
                        {
                            output.Add(postCutTextRun);
                        }

                        foreach (EditableRun t in EditableFlowLayer.TextRunForward(startPoint.TextRun.NextTextRun, endPoint.TextRun.PrevTextRun))
                        {
                            output.Add(t.Clone());
                        }

                        EditableRun preCutTextRun = endPoint.TextRun.LeftCopy(startPoint.RunLocalSelectedIndex);
                        if (preCutTextRun != null)
                        {
                            output.Add(preCutTextRun);
                        }
                    }
                }
                else
                {
                    int startLineId = startPoint.LineId;
                    int stopLineId  = endPoint.LineId;
                    startLine.RightCopy(startPoint, output);
                    for (int i = startLineId + 1; i < stopLineId; i++)
                    {
                        output.Add(new EditableTextRun(this.Root, '\n', this.CurrentTextSpanStyle));
                        EditableTextLine line = EditableFlowLayer.GetTextLine(i);
                        line.Copy(output);
                    }
                    stopLine.LeftCopy(endPoint, output);
                }
            }
        }
Пример #15
0
        internal EditableVisualPointInfo[] Split(VisualSelectionRange selectionRange)
        {
            selectionRange.SwapIfUnOrder();
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.TextRun == endPoint.TextRun)
            {
                EditableRun             toBeCutTextRun         = startPoint.TextRun;
                EditableRun             preCutTextRun          = (EditableRun)toBeCutTextRun.LeftCopy(startPoint.RunLocalSelectedIndex);
                EditableRun             middleCutTextRun       = (EditableRun)toBeCutTextRun.Copy(startPoint.RunLocalSelectedIndex, endPoint.LineCharIndex - startPoint.LineCharIndex);
                EditableRun             postCutTextRun         = (EditableRun)toBeCutTextRun.Copy(endPoint.RunLocalSelectedIndex);
                EditableVisualPointInfo newStartRangePointInfo = null;
                EditableVisualPointInfo newEndRangePointInfo   = null;
                EditableTextLine        line = this;
                if (startPoint.LineId != _currentLineNumber)
                {
                    line = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }
                line.LocalSuspendLineReArrange();
                if (preCutTextRun != null)
                {
                    line.AddBefore(toBeCutTextRun, preCutTextRun);
                    newStartRangePointInfo = CreateTextPointInfo(
                        startPoint.LineId, startPoint.LineCharIndex, startPoint.X,
                        preCutTextRun, startPoint.TextRunCharOffset, startPoint.TextRunPixelOffset);
                }
                else
                {
                    EditableRun prevTxtRun = GetPrevTextRun((EditableRun)startPoint.TextRun);
                    if (prevTxtRun != null)
                    {
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId, startPoint.LineCharIndex, startPoint.X, prevTxtRun, startPoint.TextRunCharOffset - preCutTextRun.CharacterCount,
                            startPoint.TextRunPixelOffset - prevTxtRun.Width);
                    }
                    else
                    {
                        newStartRangePointInfo = CreateTextPointInfo(
                            startPoint.LineId,
                            startPoint.LineCharIndex,
                            0,
                            null,
                            0, 0);
                    }
                }

                if (postCutTextRun != null)
                {
                    line.AddAfter(toBeCutTextRun, postCutTextRun);
                    newEndRangePointInfo =
                        CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            middleCutTextRun,
                            startPoint.TextRunCharOffset + middleCutTextRun.CharacterCount,
                            startPoint.TextRunPixelOffset + middleCutTextRun.Width);
                }
                else
                {
                    EditableRun nextTxtRun = GetNextTextRun((EditableRun)endPoint.TextRun);
                    if (nextTxtRun != null)
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            nextTxtRun,
                            endPoint.TextRunPixelOffset + endPoint.TextRun.CharacterCount,
                            endPoint.TextRunPixelOffset + endPoint.TextRun.Width);
                    }
                    else
                    {
                        newEndRangePointInfo = CreateTextPointInfo(
                            endPoint.LineId,
                            endPoint.LineCharIndex,
                            endPoint.X,
                            middleCutTextRun,
                            endPoint.TextRunCharOffset,
                            endPoint.TextRunPixelOffset);
                    }
                }

                if (middleCutTextRun != null)
                {
                    line.AddAfter(toBeCutTextRun, middleCutTextRun);
                }
                else
                {
                    throw new NotSupportedException();
                }
                line.Remove(toBeCutTextRun);
                line.LocalResumeLineReArrange();
                return(new EditableVisualPointInfo[] { newStartRangePointInfo, newEndRangePointInfo });
            }
            else
            {
                EditableTextLine workingLine = this;
                if (startPoint.LineId != _currentLineNumber)
                {
                    workingLine = EditableFlowLayer.GetTextLine(startPoint.LineId);
                }
                EditableVisualPointInfo newStartPoint = workingLine.Split(startPoint);
                workingLine = this;
                if (endPoint.LineId != _currentLineNumber)
                {
                    workingLine = EditableFlowLayer.GetTextLine(endPoint.LineId);
                }
                EditableVisualPointInfo newEndPoint = workingLine.Split(endPoint);
                return(new EditableVisualPointInfo[] { newStartPoint, newEndPoint });
            }
        }
Пример #16
0
        public void Copy(VisualSelectionRange selectionRange, TextRangeCopy output)
        {
            EditableVisualPointInfo startPoint = selectionRange.StartPoint;
            EditableVisualPointInfo endPoint   = selectionRange.EndPoint;

            if (startPoint.Run != null)
            {
                if (startPoint.Run == endPoint.Run)
                {
                    CopyRun elem =
                        startPoint.Run.Copy(
                            startPoint.RunLocalSelectedIndex,
                            endPoint.LineCharIndex - startPoint.LineCharIndex);
                    if (elem != null)
                    {
                        output.AppendRun(elem);
                    }
                }
                else
                {
                    GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine);

                    if (startLine == stopLine)
                    {
                        CopyRun rightPart = startPoint.Run.Copy(startPoint.RunLocalSelectedIndex);
                        if (rightPart != null)
                        {
                            output.AppendRun(rightPart);
                        }
                        if (startPoint.Run.NextRun != endPoint.Run)
                        {
                            foreach (Run run in _textFlowLayer.TextRunForward(
                                         startPoint.Run.NextRun,
                                         endPoint.Run.PrevRun))
                            {
                                output.AppendRun(run);
                            }
                        }

                        CopyRun leftPart = endPoint.Run.LeftCopy(endPoint.RunLocalSelectedIndex);
                        if (leftPart != null)
                        {
                            output.AppendRun(leftPart);
                        }
                    }
                    else
                    {
                        int startLineId = startPoint.LineId;
                        int stopLineId  = endPoint.LineId;
                        startLine.RightCopy(startPoint, output);
                        for (int i = startLineId + 1; i < stopLineId; i++)
                        {
                            //begine new line
                            output.AppendNewLine();
                            TextLineBox line = _textFlowLayer.GetTextLine(i);
                            line.Copy(output);
                        }
                        if (endPoint.LineCharIndex > -1)
                        {
                            output.AppendNewLine();
                            stopLine.LeftCopy(endPoint, output);
                        }
                    }
                }
            }
            else
            {
                GetStartAndStopLine(startPoint, endPoint, out TextLineBox startLine, out TextLineBox stopLine);

                if (startLine == stopLine)
                {
                    if (startPoint.LineCharIndex == -1)
                    {
                        foreach (Run t in _textFlowLayer.TextRunForward(
                                     startPoint.Run,
                                     endPoint.Run.PrevRun))
                        {
                            output.AppendRun(t);
                        }
                        CopyRun postCutTextRun = endPoint.Run.Copy(endPoint.RunLocalSelectedIndex + 1);
                        if (postCutTextRun != null)
                        {
                            output.AppendRun(postCutTextRun);
                        }
                    }
                    else
                    {
                        CopyRun rightPart = startPoint.Run.Copy(startPoint.RunLocalSelectedIndex + 1);
                        if (rightPart != null)
                        {
                            output.AppendRun(rightPart);
                        }

                        foreach (Run t in _textFlowLayer.TextRunForward(
                                     startPoint.Run.NextRun,
                                     endPoint.Run.PrevRun))
                        {
                            output.AppendRun(t.CreateCopy());
                        }

                        CopyRun leftPart = endPoint.Run.LeftCopy(startPoint.RunLocalSelectedIndex);
                        if (leftPart != null)
                        {
                            output.AppendRun(leftPart);
                        }
                    }
                }
                else
                {
                    int startLineId = startPoint.LineId;
                    int stopLineId  = endPoint.LineId;
                    startLine.RightCopy(startPoint, output);
                    for (int i = startLineId + 1; i < stopLineId; i++)
                    {
                        output.AppendNewLine();
                        TextLineBox line = _textFlowLayer.GetTextLine(i);
                        line.Copy(output);
                    }
                    stopLine.LeftCopy(endPoint, output);
                }
            }
        }
Пример #17
0
 public virtual void VisitSelectionRange(VisualSelectionRange selRange)
 {
 }
Пример #18
0
 //
 public void CopySelectedTextRuns(VisualSelectionRange selectionRange, TextRangeCopy output) => _currentLine.Copy(selectionRange, output);