8#include "katelinelayout.h"
9#include "katetextfolding.h"
10#include "katetextlayout.h"
14#include "katepartdebug.h"
16#include "katedocument.h"
17#include "katerenderer.h"
20 : m_renderer(renderer)
26void KateLineLayout::clear()
33 m_layout.clearLayout();
39 return realCursor.
line() == line();
42const Kate::TextLine &KateLineLayout::textLine(
bool reloadForce)
const
44 if (reloadForce || !m_textLine) {
46 if (m_line >= 0 && m_line < m_renderer.doc()->lines()) {
47 m_textLine = usePlainTextLine ? m_renderer.doc()->plainKateTextLine(m_line) : m_renderer.doc()->kateTextLine(m_line);
56int KateLineLayout::line()
const
61void KateLineLayout::setLine(
int line,
int virtualLine)
64 m_virtualLine = (virtualLine == -1) ? m_renderer.folding().lineToVisibleLine(line) : virtualLine;
68int KateLineLayout::virtualLine()
const
73void KateLineLayout::setVirtualLine(
int virtualLine)
75 m_virtualLine = virtualLine;
78bool KateLineLayout::startsInvisibleBlock()
const
84 return (virtualLine() + 1) != m_renderer.folding().lineToVisibleLine(line() + 1);
87bool KateLineLayout::isValid()
const
89 return line() != -1 && layout().lineCount() > 0 && (textLine(), m_textLine);
92void KateLineLayout::endLayout()
95 layoutDirty = m_layout.lineCount() <= 0;
97 if (m_layout.lineCount() > 0) {
98 for (
int i = 0; i < qMax(1, m_layout.lineCount()); ++i) {
99 m_dirtyList.append(
true);
104void KateLineLayout::invalidateLayout()
110bool KateLineLayout::isDirty(
int viewLine)
const
112 Q_ASSERT(isValid() && viewLine >= 0 && viewLine < viewLineCount());
113 return m_dirtyList[viewLine];
116bool KateLineLayout::setDirty(
int viewLine,
bool dirty)
118 Q_ASSERT(isValid() && viewLine >= 0 && viewLine < viewLineCount());
119 m_dirtyList[viewLine] = dirty;
125 return KTextEditor::Cursor(line(), 0);
128int KateLineLayout::length()
const
130 return textLine().length();
133int KateLineLayout::viewLineCount()
const
135 return m_layout.lineCount();
141 viewLine += viewLineCount();
144 Q_ASSERT(viewLine >= 0 && viewLine < viewLineCount());
145 return KateTextLayout(
this, viewLine);
148int KateLineLayout::width()
const
152 for (
int i = 0; i < m_layout.lineCount(); ++i) {
153 width = qMax((
int)m_layout.lineAt(i).naturalTextWidth(), width);
159int KateLineLayout::widthOfLastLine()
161 const KateTextLayout &lastLine = viewLine(viewLineCount() - 1);
162 return lastLine.width() + lastLine.xOffset();
165bool KateLineLayout::isOutsideDocument()
const
167 return line() < 0 || line() >= m_renderer.doc()->lines();
170void KateLineLayout::debugOutput()
const
172 qCDebug(LOG_KTE) <<
"KateLineLayout: " <<
this <<
" valid " << isValid() <<
" line " << line() <<
" length " << length() <<
" width " << width()
173 <<
" viewLineCount " << viewLineCount();
176int KateLineLayout::viewLineForColumn(
int column)
const
180 for (; i < m_layout.lineCount() - 1; ++i) {
181 len += m_layout.lineAt(i).textLength();
189bool KateLineLayout::isRightToLeft()
const
The Cursor represents a position in a Document.
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
Handles all of the work of rendering the text (used for the views and printing)
This class represents one visible line of text; with dynamic wrapping, many KateTextLayouts can be ne...
Class representing a single text line.