Pages
API Documentation
On this page

KSyntaxHighlighting::FoldingRegion Class

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)

List of all members, including inherited members

Public Types

Public Functions

Detailed Description

Member Type Documentation

enum FoldingRegion::Type

Defines whether a FoldingRegion starts or ends a folding region.

Constant
KSyntaxHighlighting::FoldingRegion::None 0
KSyntaxHighlighting::FoldingRegion::Begin 1
KSyntaxHighlighting::FoldingRegion::End 2

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 Qt 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.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.