Пример #1
0
        void DrawLine(Rect lineRect, int row, int controlID)
        {
            var line = Line(row);

            DrawAdornments(line, lineRect);

            List <int> tabSizes;
            string     baseTextFormatted = Whitespace.FormatBaseText(line.Text, out tabSizes);
            string     renderText        = Whitespace.FormatRichText(line.RichText, tabSizes);

            LineStyle.Draw(lineRect, MissingEngineAPI.GUIContent_Temp(renderText), controlID);

            if (ShowCursor && row == CaretRow)
            {
                int graphicalCaretPos = Whitespace.ConvertToGraphicalCaretColumn(CaretColumn, line, tabSizes);
                LineStyle.DrawCursor(lineRect, MissingEngineAPI.GUIContent_Temp(baseTextFormatted), controlID, graphicalCaretPos);
            }
        }
Пример #2
0
        // Input data in render text values
        Rect GetTextSpanRect(Rect lineRect, string renderText, int startPosition, int length)
        {
            if (startPosition < 0)
            {
                startPosition = 0;
            }
            if (startPosition >= renderText.Length - 1)
            {
                startPosition = renderText.Length - 1;
            }
            if (startPosition + length >= renderText.Length)
            {
                length = Mathf.Max(1, renderText.Length - startPosition);
            }

            var start = LineStyle.GetCursorPixelPosition(lineRect, MissingEngineAPI.GUIContent_Temp(renderText), startPosition);
            var end   = LineStyle.GetCursorPixelPosition(lineRect, MissingEngineAPI.GUIContent_Temp(renderText), startPosition + length);

            return(new Rect(start.x, start.y, end.x - start.x, LineHeight));
        }
Пример #3
0
        private void CalculateWidth()
        {
            var digits = LineCount > 99 ? LineCount.ToString() : "99";

            _width = LineNumberStyle.CalcSize(MissingEngineAPI.GUIContent_Temp(digits)).x;
        }