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
14#include <optional>
15
16#include "katetextline.h"
17
18#include <ktexteditor/cursor.h>
19
20class QTextLayout;
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 QTextLayout *layout() const;
74 void setLayout(QTextLayout *layout);
75 void invalidateLayout();
76
77 bool layoutDirty = true;
78 bool usePlainTextLine = false;
79
80 // This variable is used as follows:
81 // non-dynamic-wrapping mode: unused
82 // dynamic wrapping mode:
83 // first viewLine of a line: the X position of the first non-whitespace char
84 // subsequent viewLines: the X offset from the left of the display.
85 //
86 // this is used to provide a dynamic-wrapping-retains-indent feature.
87 int shiftX = 0;
88
89private:
90 // Disable copy
91 KateLineLayout(const KateLineLayout &copy);
92
93 KateRenderer &m_renderer;
94 mutable std::optional<Kate::TextLine> m_textLine;
95 int m_line;
96 int m_virtualLine;
97
98 std::unique_ptr<QTextLayout> m_layout;
99 QList<bool> m_dirtyList;
100};
101
102#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-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.