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);
        }
        private Rect CalculateCaretDrawRect(
            ITextComponentWrapper text,
            Vector2 offset,
            int relativeIndex)
        {
            Vector2 localCursorPos = text.CursorPositionAt(relativeIndex);
            int     line           = text.GetLineByCharIndex(relativeIndex);
            float   height         = text.LineHeight(line);

            return(new Rect(localCursorPos.x + offset.x,
                            localCursorPos.y - height + offset.y, 1,
                            height));
        }
        private Rect CalculateCaretDrawRect(
            ITextComponentWrapper text,
            Vector2 offset,
            int index,
            int selectionIndex)
        {
            Vector2 localCursorPos    = text.CursorPositionAt(index);
            Vector2 localSelectionPos = text.CursorPositionAt(selectionIndex);
            float   height            = text.LineHeight(0);

            if (index > selectionIndex)
            {
                Vector2 temp = localSelectionPos;
                localSelectionPos = localCursorPos;
                localCursorPos    = temp;
            }

            return(new Rect(localCursorPos.x + offset.x,
                            localCursorPos.y - height + offset.y,
                            index != selectionIndex ? Mathf.Abs(localSelectionPos.x - localCursorPos.x) : 1,
                            height));
        }