public void StartSelect()
        {
            if (_lineEditor != null)
            {
                _selectionRange = new VisualSelectionRange(_textLayer, GetCurrentPointInfo(), GetCurrentPointInfo());
            }
#if DEBUG
            if (dbugEnableTextManRecorder)
            {
                _dbugActivityRecorder.WriteInfo("TxLMan::StartSelect");
            }
#endif
        }
Beispiel #2
0
        public void SetCurrentCharIndex2(int newCharIndexPointTo)
        {
#if DEBUG
            if (dbugTextManRecorder != null)
            {
                dbugTextManRecorder.WriteInfo("TextLineReader::CharIndex_set=" + newCharIndexPointTo);
                dbugTextManRecorder.BeginContext();
            }
#endif
            if (newCharIndexPointTo < 0 || newCharIndexPointTo > _currentLine.CharCount())
            {
                throw new NotSupportedException("index out of range");
            }


            if (newCharIndexPointTo == 0)
            {
                caret_char_index = 0;
                _caretXPos       = 0;
                _rCharOffset     = 0;
                _rPixelOffset    = 0;
                _currentTextRun  = _currentLine.FirstRun;
            }
            else
            {
                caret_char_index = 0;
                _caretXPos       = 0;
                _rCharOffset     = 0;
                _rPixelOffset    = 0;
                _currentTextRun  = _currentLine.FirstRun;

                do
                {
                    if (_rCharOffset + _currentTextRun.CharacterCount >= newCharIndexPointTo)
                    {
                        caret_char_index = newCharIndexPointTo;
                        _caretXPos       = _rPixelOffset + _currentTextRun.GetRunWidth(caret_char_index - _rCharOffset);
#if DEBUG
                        if (dbugTextManRecorder != null)
                        {
                            dbugTextManRecorder.EndContext();
                        }
#endif

                        return;
                    }
                    //
                } while (MoveToNextTextRun());
                caret_char_index = _rCharOffset + _currentTextRun.CharacterCount;
                _caretXPos       = _rPixelOffset + _currentTextRun.Width;
                return;

                //                int diff = newCharIndexPointTo - caret_char_index;
                //                switch (diff)
                //                {
                //                    case 0:
                //                        {
                //                            return;
                //                        }

                //                    default:
                //                        {
                //                            if (diff > 0)
                //                            {
                //                                do
                //                                {
                //                                    if (_rCharOffset + _currentTextRun.CharacterCount >= newCharIndexPointTo)
                //                                    {
                //                                        caret_char_index = newCharIndexPointTo;
                //                                        _caretXPos = _rPixelOffset + _currentTextRun.GetRunWidth(caret_char_index - _rCharOffset);
                //#if DEBUG
                //                                        if (dbugTextManRecorder != null)
                //                                        {
                //                                            dbugTextManRecorder.EndContext();
                //                                        }
                //#endif

                //                                        return;
                //                                    }
                //                                    //
                //                                } while (MoveToNextTextRun());
                //                                caret_char_index = _rCharOffset + _currentTextRun.CharacterCount;
                //                                _caretXPos = _rPixelOffset + _currentTextRun.Width;
                //                                return;
                //                            }
                //                            else
                //                            {
                //                                do
                //                                {
                //                                    if (_rCharOffset - 1 < newCharIndexPointTo)
                //                                    {
                //                                        caret_char_index = newCharIndexPointTo;
                //                                        _caretXPos = _rPixelOffset + _currentTextRun.GetRunWidth(caret_char_index - _rCharOffset);
                //#if DEBUG
                //                                        if (dbugTextManRecorder != null)
                //                                        {
                //                                            dbugTextManRecorder.EndContext();
                //                                        }
                //#endif
                //                                        return;
                //                                    }
                //                                } while (MoveToPreviousTextRun());
                //                                caret_char_index = 0;
                //                                _caretXPos = 0;
                //                            }
                //                        }
                //                        break;
                //                }
            }
#if DEBUG
            if (dbugTextManRecorder != null)
            {
                dbugTextManRecorder.EndContext();
            }
#endif
        }