KSyntaxHighlighting::FoldingRegion Class

class KSyntaxHighlighting::FoldingRegion

Represents a begin or end of a folding region. More...

Header: #include <KSyntaxHighlighting/FoldingRegion>
CMake: find_package(KF6 REQUIRED COMPONENTS KSyntaxHighlighting)
target_link_libraries(mytarget PRIVATE KF6::KSyntaxHighlighting)
Since: 5.28

Public Types

enum Type { None, Begin, End }

Public Functions

FoldingRegion()
int id() const
bool isValid() const
(since 6.0) KSyntaxHighlighting::FoldingRegion sibling() const
KSyntaxHighlighting::FoldingRegion::Type type() const
bool operator==(const KSyntaxHighlighting::FoldingRegion &other) const

Detailed Description

Member Type Documentation

enum FoldingRegion::Type

Defines whether a FoldingRegion starts or ends a folding region.

ConstantValue
KSyntaxHighlighting::FoldingRegion::None0
KSyntaxHighlighting::FoldingRegion::Begin1
KSyntaxHighlighting::FoldingRegion::End2

Member Function Documentation

FoldingRegion::FoldingRegion()

Constructs an invalid folding region, meaning that isValid() returns false. To obtain valid instances, see AbstractHighlighter::applyFolding().

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.

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 FoldingRegion%s passed in AbstractHighlighter::applyFolding() are always valid.

[since 6.0] KSyntaxHighlighting::FoldingRegion FoldingRegion::sibling() const

Returns the matching start or end region.

Note: Will return invalid region for an invalid region.

This function was introduced in 6.0.

KSyntaxHighlighting::FoldingRegion::Type FoldingRegion::type() const

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

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

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

Compares two FoldingRegion instances for equality.