Changeset View
Changeset View
Standalone View
Standalone View
src/view/kateviewhelpers.cpp
Show First 20 Lines • Show All 1611 Lines • ▼ Show 20 Line(s) | 1590 | { | |||
---|---|---|---|---|---|
1612 | 1612 | | |||
1613 | m_updatePositionToArea = true; | 1613 | m_updatePositionToArea = true; | ||
1614 | 1614 | | |||
1615 | QTimer::singleShot(0, this, SLOT(update())); | 1615 | QTimer::singleShot(0, this, SLOT(update())); | ||
1616 | } | 1616 | } | ||
1617 | 1617 | | |||
1618 | int KateIconBorder::lineNumberWidth() const | 1618 | int KateIconBorder::lineNumberWidth() const | ||
1619 | { | 1619 | { | ||
1620 | int width = 0; | ||||
1621 | // Avoid unneeded expensive calculations ;-) | ||||
1622 | if (m_lineNumbersOn) { | ||||
1620 | // width = (number of digits + 1) * char width | 1623 | // width = (number of digits + 1) * char width | ||
1621 | const int digits = (int) ceil(log10((double)(m_view->doc()->lines() + 1))); | 1624 | const int digits = (int) ceil(log10((double)(m_view->doc()->lines() + 1))); | ||
1622 | int width = m_lineNumbersOn ? (int)ceil((digits + 1) * m_maxCharWidth) : 0; | 1625 | width = (int)ceil((digits + 1) * m_maxCharWidth); | ||
1626 | } | ||||
1627 | | ||||
1623 | if ((width < 1) && m_dynWrapIndicatorsOn && m_view->config()->dynWordWrap()) { | 1628 | if ((width < 1) && m_dynWrapIndicatorsOn && m_view->config()->dynWordWrap()) { | ||
1624 | // FIXME Why 2x? because of above (number of digits + 1) | 1629 | // FIXME Why 2x? because of above (number of digits + 1) | ||
1625 | // -> looks to me like a hint for bad calculation elsewhere | 1630 | // -> looks to me like a hint for bad calculation elsewhere | ||
1626 | width = 2 * m_maxCharWidth; | 1631 | width = 2 * m_maxCharWidth; | ||
1627 | } | 1632 | } | ||
1628 | 1633 | | |||
1629 | return width; | 1634 | return width; | ||
1630 | } | 1635 | } | ||
▲ Show 20 Lines • Show All 284 Lines • ▼ Show 20 Line(s) | 1916 | { | |||
1915 | const uint currentLine = m_view->cursorPosition().line(); | 1920 | const uint currentLine = m_view->cursorPosition().line(); | ||
1916 | 1921 | | |||
1917 | // center the folding boxes | 1922 | // center the folding boxes | ||
1918 | int m_px = (h - 11) / 2; | 1923 | int m_px = (h - 11) / 2; | ||
1919 | if (m_px < 0) { | 1924 | if (m_px < 0) { | ||
1920 | m_px = 0; | 1925 | m_px = 0; | ||
1921 | } | 1926 | } | ||
1922 | 1927 | | |||
1923 | if (m_updatePositionToArea) { | 1928 | // Ensure we miss no change of the count of line number digits | ||
1924 | m_lineNumberAreaWidth = lineNumberWidth(); | 1929 | const int newNeededWidth = lineNumberWidth(); | ||
1930 | | ||||
1931 | if (m_updatePositionToArea || (newNeededWidth != m_lineNumberAreaWidth)) { | ||||
1932 | m_lineNumberAreaWidth = newNeededWidth; | ||||
1933 | m_updatePositionToArea = true; | ||||
1925 | m_positionToArea.clear(); | 1934 | m_positionToArea.clear(); | ||
1926 | } | 1935 | } | ||
1927 | 1936 | | |||
1928 | QPainter p(this); | 1937 | QPainter p(this); | ||
1929 | p.setRenderHints(QPainter::TextAntialiasing); | 1938 | p.setRenderHints(QPainter::TextAntialiasing); | ||
1930 | p.setFont(m_view->renderer()->config()->font()); // for line numbers | 1939 | p.setFont(m_view->renderer()->config()->font()); // for line numbers | ||
1931 | 1940 | | |||
1932 | KTextEditor::AnnotationModel *model = m_view->annotationModel() ? | 1941 | KTextEditor::AnnotationModel *model = m_view->annotationModel() ? | ||
▲ Show 20 Lines • Show All 1153 Lines • Show Last 20 Lines |