• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • KTextEditor
  • FoldingInterface
Public Types | Public Slots | Signals | Public Member Functions | List of all members
KTextEditor::FoldingInterface Class Referenceabstract

#include <foldinginterface.h>

Public Types

enum  FoldingRangeFlag { Persistent = 0x1, Folded = 0x2 }
 

Public Slots

void clear ()
 

Signals

void foldingRangesChanged ()
 

Public Member Functions

 FoldingInterface ()
 
virtual ~FoldingInterface ()
 
 Q_DECLARE_FLAGS (FoldingRangeFlags, FoldingRangeFlag)
 
Creation, Folding and Unfolding

The following functions provide access and manipulation of the range's position.

qint64 newFoldingRange (const KTextEditor::Range &range, FoldingRangeFlags flags=FoldingRangeFlags())
 
virtual bool foldRange (qint64 id)=0
 
virtual bool unfoldRange (qint64 id, bool remove=false)=0
 
virtual QVector< 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 38 of file foldinginterface.h.

Member Enumeration Documentation

enum KTextEditor::FoldingInterface::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 55 of file foldinginterface.h.

Constructor & Destructor Documentation

KTextEditor::FoldingInterface::FoldingInterface ( )

Create folding object for given buffer.

Parameters
buffertext buffer we want to provide folding info for
virtual KTextEditor::FoldingInterface::~FoldingInterface ( )
virtual

Cleanup.

Member Function Documentation

void KTextEditor::FoldingInterface::clear ( )
slot

Clear the complete folding.

This is automatically triggered if the buffer is cleared.

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
void KTextEditor::FoldingInterface::foldingRangesChanged ( )
signal

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

virtual QVector<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
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
virtual bool KTextEditor::FoldingInterface::foldRange ( qint64  id)
pure virtual

Fold the given range.

Parameters
idid of the range to fold
Returns
success
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?
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
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
qint64 KTextEditor::FoldingInterface::newFoldingRange ( const 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!
KTextEditor::FoldingInterface::Q_DECLARE_FLAGS ( FoldingRangeFlags  ,
FoldingRangeFlag   
)
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
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
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

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:
  • foldinginterface.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:57:03 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal