1/*
2 SPDX-FileCopyrightText: 2002-2005 Hamish Rodda <rodda@kde.org>
3 SPDX-FileCopyrightText: 2003 Anakim Border <aborder@sources.sourceforge.net>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef _KATE_TEXTLAYOUT_H_
9#define _KATE_TEXTLAYOUT_H_
10
11#include <QTextLine>
12
13#include "katelinelayout.h"
14
15/**
16 * This class represents one visible line of text; with dynamic wrapping,
17 * many KateTextLayouts can be needed to represent one actual line of text
18 * (ie. one KateLineLayout)
19 */
20class KateTextLayout
21{
22 friend class KateLineLayout;
23 friend class KateLayoutCache;
24
25public:
26 bool isValid() const;
27 static KateTextLayout invalid();
28
29 int line() const;
30 int virtualLine() const;
31 /** Return the index of this visual line inside the document line
32 (KateLineLayout). */
33 int viewLine() const;
34
35 const QTextLine &lineLayout() const;
36 KateLineLayout *kateLineLayout() const;
37
38 int startCol() const;
39 KTextEditor::Cursor start() const;
40
41 /**
42 * Return the end column of this text line.
43 *
44 * \param indicateEOL set to true to return -1 if this layout is the
45 * end of the line, otherwise false to return the end column number
46 */
47 int endCol(bool indicateEOL = false) const;
48
49 /**
50 * Return the end position of this text line.
51 *
52 * \param indicateEOL set to true to return -1 if this layout is the
53 * end of the line, otherwise false to return the end column number
54 */
55 KTextEditor::Cursor end(bool indicateEOL = false) const;
56
57 int length() const;
58 bool isEmpty() const;
59
60 bool wrap() const;
61
62 bool isDirty() const;
63 bool setDirty(bool dirty = true);
64
65 int startX() const;
66 int endX() const;
67 int width() const;
68
69 int xOffset() const;
70
71 bool isRightToLeft() const;
72
73 bool includesCursor(const KTextEditor::Cursor realCursor) const;
74
75 friend bool operator>(const KateLineLayout &r, const KTextEditor::Cursor c);
76 friend bool operator>=(const KateLineLayout &r, const KTextEditor::Cursor c);
77 friend bool operator<(const KateLineLayout &r, const KTextEditor::Cursor c);
78 friend bool operator<=(const KateLineLayout &r, const KTextEditor::Cursor c);
79
80 void debugOutput() const;
81
82 explicit KateTextLayout(KateLineLayout *line = nullptr, int viewLine = 0);
83
84private:
85 KateLineLayout *m_lineLayout;
86 QTextLine m_textLayout;
87
88 int m_viewLine;
89 mutable int m_startX;
90 bool m_invalidDirty = true;
91};
92
93#endif
94

source code of ktexteditor/src/render/katetextlayout.h