KTextEditor::FoldingInterface

Search for usage in LXR

KTextEditor::FoldingInterface Class Referenceabstract

#include <foldinginterface.h>

Public Types

enum  FoldingRangeFlag { Persistent = 0x1 , Folded = 0x2 }
 
typedef QFlags< FoldingRangeFlagFoldingRangeFlags
 

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

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
buffertext buffer we want to provide folding info for

◆ ~FoldingInterface()

virtual KTextEditor::FoldingInterface::~FoldingInterface ( )
virtual

Cleanup.

Member Function Documentation

◆ clear

void KTextEditor::FoldingInterface::clear ( )
slot

Clear the complete folding.

This is automatically triggered if the buffer is cleared.

◆ ensureLineIsVisible()

virtual void KTextEditor::FoldingInterface::ensureLineIsVisible ( int line)
pure virtual

Ensure that a given line will be visible.

Potentially unfold recursively all folds hiding this line, else just returns.

Parameters
lineline to make visible

◆ foldingRangesChanged

void KTextEditor::FoldingInterface::foldingRangesChanged ( )
signal

If the folding state of existing ranges changes or ranges are added/removed, this signal is emitted.

◆ foldingRangesStartingOnLine()

virtual QList< QPair< qint64, FoldingRangeFlags > > KTextEditor::FoldingInterface::foldingRangesStartingOnLine ( int line) const
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
lineline to query starting folding ranges
Returns
vector of id's + flags

◆ foldLine()

virtual qint64 KTextEditor::FoldingInterface::foldLine ( int line) const
pure virtual

Fold the first folding range starting on this line, if applicable.

Parameters
lineline to fold
Returns
id of folded range (>= 0) or -1, if no folding range starts at line

◆ foldRange()

virtual bool KTextEditor::FoldingInterface::foldRange ( qint64 id)
pure virtual

Fold the given range.

Parameters
idid of the range to fold
Returns
success

◆ isLineVisible()

virtual bool KTextEditor::FoldingInterface::isLineVisible ( int line,
qint64 * foldedRangeId = 0 ) const
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
lineline to query
foldedRangeIdif 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()

virtual bool KTextEditor::FoldingInterface::lineContainsStartFoldingRanges ( int line) const
pure virtual

Check whether on this line starts a folding range.

Parameters
lineline to query starting folding ranges
Returns
true, if a folding range starts, otherwise false

◆ lineToVisibleLine()

virtual int KTextEditor::FoldingInterface::lineToVisibleLine ( int line) const
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
lineline 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
rangefolding range
flagsinitial 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()

virtual bool KTextEditor::FoldingInterface::unfoldLine ( int line) const
pure virtual

Unfolds all folding range starting on this line, if applicable.

Parameters
lineline to unfold
Returns
id of folded range (>= 0) or -1, if no folding range starts at line

◆ unfoldRange()

virtual bool KTextEditor::FoldingInterface::unfoldRange ( qint64 id,
bool remove = false )
pure virtual

Unfold the given range.

In addition it can be forced to remove the region, even if it is persistent.

Parameters
idid of the range to unfold
removeshould the range be removed from the folding after unfolding? ranges that are not persistent auto-remove themself on unfolding
Returns
success

◆ visibleLines()

virtual int KTextEditor::FoldingInterface::visibleLines ( ) const
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()

virtual int KTextEditor::FoldingInterface::visibleLineToLine ( int visibleLine) const
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
visibleLinevisible line index
Returns
index in text buffer lines

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
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.