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_LINELAYOUT_H_ |
9 | #define _KATE_LINELAYOUT_H_ |
10 | |
11 | #include <QTextLayout> |
12 | |
13 | #include <ktexteditor/cursor.h> |
14 | |
15 | namespace KTextEditor |
16 | { |
17 | class DocumentPrivate; |
18 | } |
19 | namespace Kate |
20 | { |
21 | class TextFolding; |
22 | } |
23 | class KateTextLayout; |
24 | class KateRenderer; |
25 | |
26 | class KateLineLayout |
27 | { |
28 | public: |
29 | explicit KateLineLayout(); |
30 | |
31 | void debugOutput() const; |
32 | |
33 | void clear(); |
34 | bool isValid() const; |
35 | |
36 | bool isRightToLeft() const; |
37 | |
38 | bool includesCursor(const KTextEditor::Cursor realCursor) const; |
39 | |
40 | friend bool operator>(const KateLineLayout &r, const KTextEditor::Cursor c); |
41 | friend bool operator>=(const KateLineLayout &r, const KTextEditor::Cursor c); |
42 | friend bool operator<(const KateLineLayout &r, const KTextEditor::Cursor c); |
43 | friend bool operator<=(const KateLineLayout &r, const KTextEditor::Cursor c); |
44 | |
45 | int line() const; |
46 | /** |
47 | * Only pass virtualLine if you know it (and thus we shouldn't try to look it up) |
48 | */ |
49 | void setLine(Kate::TextFolding &folding, int line, int virtualLine = -1); |
50 | KTextEditor::Cursor start() const; |
51 | |
52 | int virtualLine() const; |
53 | void setVirtualLine(int virtualLine); |
54 | |
55 | bool isDirty(int viewLine) const; |
56 | bool setDirty(int viewLine, bool dirty = true); |
57 | |
58 | int width() const; |
59 | int widthOfLastLine(); |
60 | |
61 | int viewLineCount() const; |
62 | KateTextLayout viewLine(int viewLine); |
63 | int viewLineForColumn(int column) const; |
64 | |
65 | bool startsInvisibleBlock(Kate::TextFolding &folding) const; |
66 | |
67 | const QTextLayout &layout() const |
68 | { |
69 | return m_layout; |
70 | } |
71 | |
72 | // just used to generate a new layout together with endLayout |
73 | QTextLayout &modifiableLayout() |
74 | { |
75 | return m_layout; |
76 | } |
77 | |
78 | void endLayout(); |
79 | void invalidateLayout(); |
80 | |
81 | bool layoutDirty = true; |
82 | |
83 | // This variable is used as follows: |
84 | // non-dynamic-wrapping mode: unused |
85 | // dynamic wrapping mode: |
86 | // first viewLine of a line: the X position of the first non-whitespace char |
87 | // subsequent viewLines: the X offset from the left of the display. |
88 | // |
89 | // this is used to provide a dynamic-wrapping-retains-indent feature. |
90 | int shiftX = 0; |
91 | |
92 | private: |
93 | // Disable copy |
94 | KateLineLayout(const KateLineLayout ©); |
95 | |
96 | int m_line; |
97 | int m_virtualLine; |
98 | |
99 | QTextLayout m_layout; |
100 | QList<bool> m_dirtyList; |
101 | }; |
102 | |
103 | #endif |
104 | |