KTextEditor::FoldingInterface
#include <foldinginterface.h>
Public Types | |
enum | FoldingRangeFlag { Persistent = 0x1 , Folded = 0x2 } |
typedef QFlags< FoldingRangeFlag > | FoldingRangeFlags |
Signals | |
void | foldingRangesChanged () |
Public Slots | |
void | clear () |
Public Member Functions | |
FoldingInterface () | |
virtual | ~FoldingInterface () |
Creation, Folding and Unfolding | |
The following functions provide access and manipulation of the range's position. | |
qint64 | newFoldingRange (KTextEditor::Range range, FoldingRangeFlags flags=FoldingRangeFlags()) |
virtual bool | foldRange (qint64 id)=0 |
virtual bool | unfoldRange (qint64 id, bool remove=false)=0 |
virtual QList< QPair< qint64, FoldingRangeFlags > > | foldingRangesStartingOnLine (int line) const =0 |
virtual bool | lineContainsStartFoldingRanges (int line) const =0 |
virtual qint64 | foldLine (int line) const =0 |
virtual bool | unfoldLine (int line) const =0 |
Line Visibility | |
The following functions provide access and manipulation of the range's position. | |
virtual bool | isLineVisible (int line, qint64 *foldedRangeId=0) const =0 |
virtual void | ensureLineIsVisible (int line)=0 |
virtual int | visibleLines () const =0 |
virtual int | lineToVisibleLine (int line) const =0 |
virtual int | visibleLineToLine (int visibleLine) const =0 |
Detailed Description
KTextEditor interface for code folding of a KTextEditor::View.
The interface allows to arbitrary fold given regions of a buffer as long as they are well nested. Multiple instances of this class can exist for the same buffer.
Definition at line 24 of file foldinginterface.h.
Member Typedef Documentation
◆ FoldingRangeFlags
Definition at line 52 of file foldinginterface.h.
Member Enumeration Documentation
◆ FoldingRangeFlag
Folding state of a range.
Enumerator | |
---|---|
Persistent | Range is persistent, e.g. it should not auto-delete after unfolding! |
Folded | Range is folded away. |
Definition at line 41 of file foldinginterface.h.
Constructor & Destructor Documentation
◆ FoldingInterface()
KTextEditor::FoldingInterface::FoldingInterface | ( | ) |
Create folding object for given buffer.
- Parameters
-
buffer text buffer we want to provide folding info for
◆ ~FoldingInterface()
|
virtual |
Cleanup.
Member Function Documentation
◆ clear
|
slot |
Clear the complete folding.
This is automatically triggered if the buffer is cleared.
◆ ensureLineIsVisible()
|
pure virtual |
Ensure that a given line will be visible.
Potentially unfold recursively all folds hiding this line, else just returns.
- Parameters
-
line line to make visible
◆ foldingRangesChanged
|
signal |
If the folding state of existing ranges changes or ranges are added/removed, this signal is emitted.
◆ foldingRangesStartingOnLine()
|
pure virtual |
Queries which folding ranges start at the given line and returns the id + flags for all of them.
Very fast if nothing is folded, else binary search.
- Parameters
-
line line to query starting folding ranges
- Returns
- vector of id's + flags
◆ foldLine()
|
pure virtual |
Fold the first folding range starting on this line, if applicable.
- Parameters
-
line line to fold
- Returns
- id of folded range (>= 0) or -1, if no folding range starts at line
◆ foldRange()
|
pure virtual |
Fold the given range.
- Parameters
-
id id of the range to fold
- Returns
- success
◆ isLineVisible()
|
pure virtual |
Query if a given line is visible.
Very fast, if nothing is folded, else does binary search log(n) for n == number of folded ranges
- Parameters
-
line line to query foldedRangeId if the line is not visible and that pointer is not 0, will be filled with id of range hiding the line or -1
- Returns
- is that line visible?
◆ lineContainsStartFoldingRanges()
|
pure virtual |
Check whether on this line starts a folding range.
- Parameters
-
line line to query starting folding ranges
- Returns
- true, if a folding range starts, otherwise false
◆ lineToVisibleLine()
|
pure virtual |
Convert a text buffer line to a visible line number.
Very fast, if nothing is folded, else walks over all folded regions O(n) for n == number of folded ranges
- Parameters
-
line line index in the text buffer
- Returns
- index in visible lines
◆ newFoldingRange()
qint64 KTextEditor::FoldingInterface::newFoldingRange | ( | KTextEditor::Range | range, |
FoldingRangeFlags | flags = FoldingRangeFlags() ) |
Create a new folding range.
- Parameters
-
range folding range flags initial flags for the new folding range
- Returns
- on success, id of new range >= 0, else -1, we return no pointer as folding ranges might be auto-deleted internally! the ids are stable for one KTextEditor::FoldingInterface, e.g. you can rely in unit tests that you get 0,1,.... for successfully created ranges!
◆ unfoldLine()
|
pure virtual |
Unfolds all folding range starting on this line, if applicable.
- Parameters
-
line line to unfold
- Returns
- id of folded range (>= 0) or -1, if no folding range starts at line
◆ unfoldRange()
|
pure virtual |
Unfold the given range.
In addition it can be forced to remove the region, even if it is persistent.
- Parameters
-
id id of the range to unfold remove should the range be removed from the folding after unfolding? ranges that are not persistent auto-remove themself on unfolding
- Returns
- success
◆ visibleLines()
|
pure virtual |
Query number of visible lines.
Very fast, if nothing is folded, else walks over all folded regions O(n) for n == number of folded ranges
◆ visibleLineToLine()
|
pure virtual |
Convert a visible line number to a line number in the text buffer.
Very fast, if nothing is folded, else walks over all folded regions O(n) for n == number of folded ranges
- Parameters
-
visibleLine visible line index
- Returns
- index in text buffer lines
The documentation for this class was generated from the following file:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:11:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.