protected override string ProcessText(ITextComponentWrapper editableText, ICaret caret)
        {
            // truncate text to display within the bounds of text rect.
            Vector2 textRectExtents = editableText.DisplayRect.size;

            float width = 0;

            if (caret.GetIndex() > _drawEnd || (caret.GetIndex() == TextValue.Length && _drawStart > 0))
            {
                _drawEnd   = caret.GetIndex();
                _drawStart = _drawEnd - 1;
                while (width < textRectExtents.x && _drawStart >= 0)
                {
                    width += editableText.CharWidth(_drawStart--);
                }

                if (width >= textRectExtents.x)
                {
                    _drawStart++;
                }

                _drawStart++;
            }
            else
            {
                if (caret.GetIndex() < _drawStart)
                {
                    _drawStart = caret.GetIndex();
                }

                _drawEnd = _drawStart;
                while (width < textRectExtents.x && _drawEnd < TextValue.Length)
                {
                    width += editableText.CharWidth(_drawEnd++);
                }

                if (width >= textRectExtents.x)
                {
                    _drawEnd--;
                }
            }

            _drawStart = Mathf.Clamp(_drawStart, 0, TextValue.Length);
            _drawEnd   = Mathf.Clamp(_drawEnd, 0, TextValue.Length);
            return(TextValue.Substring(_drawStart, _drawEnd - _drawStart));
        }
        private Rect HightedLineRect(int startIndex, int endIndex, float height, ITextComponentWrapper text)
        {
            Vector2 start = text.CursorPositionAt(startIndex);
            Vector2 end   = text.CursorPositionAt(endIndex);
            // FIXME: add last char width according to caret moving direction.
            Rect rect = new Rect(start.x, start.y - height,
                                 Mathf.Abs(end.x + text.CharWidth(endIndex + _drawStart) - start.x), height);

            return(rect);
        }