KTextEditor

katelinelayout.h
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 <QExplicitlySharedDataPointer>
12#include <QSharedData>
13#include <QTextLayout>
14
15#include <optional>
16
17#include "katetextline.h"
18
19#include <ktexteditor/cursor.h>
20
21namespace KTextEditor
22{
23class DocumentPrivate;
24}
25class KateTextLayout;
26class KateRenderer;
27
28class KateLineLayout
29{
30public:
31 explicit KateLineLayout(KateRenderer &renderer);
32
33 void debugOutput() const;
34
35 void clear();
36 bool isValid() const;
37 bool isOutsideDocument() const;
38
39 bool isRightToLeft() const;
40
41 bool includesCursor(const KTextEditor::Cursor realCursor) const;
42
43 friend bool operator>(const KateLineLayout &r, const KTextEditor::Cursor c);
44 friend bool operator>=(const KateLineLayout &r, const KTextEditor::Cursor c);
45 friend bool operator<(const KateLineLayout &r, const KTextEditor::Cursor c);
46 friend bool operator<=(const KateLineLayout &r, const KTextEditor::Cursor c);
47
48 const Kate::TextLine &textLine(bool forceReload = false) const;
49 int length() const;
50
51 int line() const;
52 /**
53 * Only pass virtualLine if you know it (and thus we shouldn't try to look it up)
54 */
55 void setLine(int line, int virtualLine = -1);
56 KTextEditor::Cursor start() const;
57
58 int virtualLine() const;
59 void setVirtualLine(int virtualLine);
60
61 bool isDirty(int viewLine) const;
62 bool setDirty(int viewLine, bool dirty = true);
63
64 int width() const;
65 int widthOfLastLine();
66
67 int viewLineCount() const;
68 KateTextLayout viewLine(int viewLine);
69 int viewLineForColumn(int column) const;
70
71 bool startsInvisibleBlock() const;
72
73 const QTextLayout &layout() const
74 {
75 return m_layout;
76 }
77
78 // just used to generate a new layout together with endLayout
79 QTextLayout &modifiableLayout()
80 {
81 return m_layout;
82 }
83
84 void endLayout();
85 void invalidateLayout();
86
87 bool layoutDirty = true;
88 bool usePlainTextLine = false;
89
90 // This variable is used as follows:
91 // non-dynamic-wrapping mode: unused
92 // dynamic wrapping mode:
93 // first viewLine of a line: the X position of the first non-whitespace char
94 // subsequent viewLines: the X offset from the left of the display.
95 //
96 // this is used to provide a dynamic-wrapping-retains-indent feature.
97 int shiftX = 0;
98
99private:
100 // Disable copy
101 KateLineLayout(const KateLineLayout &copy);
102
103 KateRenderer &m_renderer;
104 mutable std::optional<Kate::TextLine> m_textLine;
105 int m_line;
106 int m_virtualLine;
107
108 QTextLayout m_layout;
109 QList<bool> m_dirtyList;
110};
111
112#endif
The Cursor represents a position in a Document.
Definition cursor.h:75
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.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 3 2025 12:00:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.