KSyntaxHighlighting::FoldingRegion

Search for usage in LXR

KSyntaxHighlighting::FoldingRegion Class Reference

#include <foldingregion.h>

Public Types

enum  Type { None , Begin , End }
 

Public Member Functions

 FoldingRegion ()
 
int id () const
 
bool isValid () const
 
bool operator== (const FoldingRegion &other) const
 
FoldingRegion sibling () const
 
Type type () const
 

Detailed Description

Represents a begin or end of a folding region.

Since
5.28

Definition at line 18 of file foldingregion.h.

Member Enumeration Documentation

◆ Type

Defines whether a FoldingRegion starts or ends a folding region.

Enumerator
None 

Used internally as indicator for an invalid FoldingRegion.

Begin 

Indicates the start of a FoldingRegion.

End 

Indicates the end of a FoldingRegion.

Definition at line 24 of file foldingregion.h.

Constructor & Destructor Documentation

◆ FoldingRegion()

FoldingRegion::FoldingRegion ( )
default

Constructs an invalid folding region, meaning that isValid() returns false.

To obtain valid instances, see AbstractHighlighter::applyFolding().

Member Function Documentation

◆ id()

int FoldingRegion::id ( ) const

Returns a unique identifier for this folding region.

As example, the C/C++ highlighter starts and ends a folding region for scopes, e.g.:

void foo() { // '{' starts a folding region
if (bar()) { // '{' starts a (nested) folding region
} // '}' ends the (nested) folding region
} // '}' ends the outer folding region

In this example, all braces '{' and '}' have the same id(), meaning that if you want to find the matching closing region for the first opening brace, you need to do kind of a reference counting to find the correct closing brace.

Definition at line 30 of file foldingregion.cpp.

◆ isValid()

bool FoldingRegion::isValid ( ) const

Returns true if this is a valid folding region.

A valid FoldingRegion is defined by a type() other than Type::None.

Note
The FoldingRegions passed in AbstractHighlighter::applyFolding() are always valid.

Definition at line 25 of file foldingregion.cpp.

◆ operator==()

bool FoldingRegion::operator== ( const FoldingRegion & other) const

Compares two FoldingRegion instances for equality.

Definition at line 20 of file foldingregion.cpp.

◆ sibling()

FoldingRegion FoldingRegion::sibling ( ) const

Returns the matching start or end region.

Note
Will return invalid region for an invalid region.
Since
6.0

Definition at line 43 of file foldingregion.cpp.

◆ type()

FoldingRegion::Type FoldingRegion::type ( ) const

Returns whether this is the begin or end of a region.

Note
The FoldingRegions passed in AbstractHighlighter::applyFolding() are always valid, i.e. either Type::Begin or Type::End.

Definition at line 35 of file foldingregion.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.