KTextEditor::LineRange
#include <KTextEditor/LineRange>
Public Member Functions | |
constexpr | LineRange () noexcept=default |
constexpr | LineRange (int start, int end) noexcept |
constexpr LineRange | encompass (LineRange range) const noexcept |
constexpr LineRange | intersect (LineRange range) const noexcept |
constexpr bool | isValid () const noexcept |
QString | toString () const |
Position | |
The following functions provide access to, and manipulation of, the range's position. | |
constexpr int | start () const noexcept |
constexpr int | end () const noexcept |
void | setRange (LineRange range) noexcept |
void | setRange (int start, int end) noexcept |
void | setBothLines (int line) noexcept |
void | setStart (int start) noexcept |
void | setEnd (int end) noexcept |
bool | expandToRange (LineRange range) noexcept |
bool | confineToRange (LineRange range) noexcept |
constexpr bool | onSingleLine () const noexcept |
constexpr int | numberOfLines () const noexcept |
Comparison | |
The following functions perform checks against this range in comparison to other lines and ranges. | |
constexpr bool | contains (LineRange range) const noexcept |
constexpr bool | containsLine (int line) const noexcept |
constexpr bool | overlaps (LineRange range) const noexcept |
constexpr bool | overlapsLine (int line) const noexcept |
Static Public Member Functions | |
static LineRange | fromString (QStringView str) noexcept |
static constexpr LineRange | invalid () noexcept |
Detailed Description
An object representing lines from a start line to an end line.
A LineRange is a basic class which represents a range of lines, from a start() line to an end() line.
For simplicity and convenience, ranges always maintain their start() line to be before or equal to their end() line. Attempting to set either the start or end of the range beyond the respective end or start will result in both values being set to the specified line. In the constructor, the start and end will be swapped if necessary.
- See also
- Range
- Since
- 5.79
Definition at line 40 of file linerange.h.
Constructor & Destructor Documentation
◆ LineRange() [1/2]
|
constexprdefaultnoexcept |
Default constructor.
Creates a valid line range with both start and end line set to 0.
◆ LineRange() [2/2]
|
inlineconstexprnoexcept |
Constructor which creates a range from start to end.
If start is after end, they will be swapped.
- Parameters
-
start start line end end line
Definition at line 56 of file linerange.h.
Member Function Documentation
◆ confineToRange()
|
inlinenoexcept |
Confine this range if necessary to fit within range
.
- Parameters
-
range range which should contain this range
- Returns
- true if confinement occurred, false otherwise
Definition at line 221 of file linerange.h.
◆ contains()
|
inlineconstexprnoexcept |
Check whether the this range wholly encompasses range.
- Parameters
-
range range to check
- Returns
- true, if this range contains range, otherwise false
Definition at line 276 of file linerange.h.
◆ containsLine()
|
inlineconstexprnoexcept |
Returns true if this range wholly encompasses line
.
- Parameters
-
line line to check
- Returns
- true if the line is wholly encompassed by this range, otherwise false.
Definition at line 288 of file linerange.h.
◆ encompass()
Returns the smallest range which encompasses this line range and the supplied range.
- Parameters
-
range other range to encompass
- Returns
- the smallest range which contains this range and the supplied range.
Definition at line 341 of file linerange.h.
◆ end()
|
inlineconstexprnoexcept |
Get the end line of this line range.
This will always be >= start().
- Returns
- the end line of this line range.
Definition at line 115 of file linerange.h.
◆ expandToRange()
|
inlinenoexcept |
Expand this line range if necessary to contain range
.
- Parameters
-
range range which this range should contain
- Returns
- true if expansion occurred, false otherwise
Definition at line 197 of file linerange.h.
◆ fromString()
|
staticnoexcept |
Returns a LineRange created from the string str
containing the format "[start line, end line]".
In case the string cannot be parsed, an LineRange::invalid() is returned.
- See also
- toString()
Definition at line 94 of file utils/range.cpp.
◆ intersect()
Intersects this line range with another, returning the shared lines of the two line ranges.
- Parameters
-
range other line range to intersect with this
- Returns
- the intersection of this range and the supplied range.
Definition at line 327 of file linerange.h.
◆ invalid()
|
inlinestaticconstexprnoexcept |
Returns an invalid line range.
Definition at line 73 of file linerange.h.
◆ isValid()
|
inlineconstexprnoexcept |
Validity check.
In the base class, returns true unless the line range starts before (0,0).
Definition at line 65 of file linerange.h.
◆ numberOfLines()
|
inlineconstexprnoexcept |
◆ onSingleLine()
|
inlineconstexprnoexcept |
Check whether this line range is on one line.
- Returns
- true if both the start and end line are equal, otherwise false
Definition at line 243 of file linerange.h.
◆ overlaps()
|
inlineconstexprnoexcept |
Check whether the this range overlaps with range.
- Parameters
-
range range to check against
- Returns
- true, if this range overlaps with range, otherwise false
Definition at line 300 of file linerange.h.
◆ overlapsLine()
|
inlineconstexprnoexcept |
Check whether the range overlaps at least part of line.
- Parameters
-
line line to check
- Returns
- true, if the range overlaps at least part of line, otherwise false
Definition at line 312 of file linerange.h.
◆ setBothLines()
|
inlinenoexcept |
Convenience function.
Set the start and end lines to line
.
Definition at line 152 of file linerange.h.
◆ setEnd()
|
inlinenoexcept |
Set the end line to end.
- Note
- If end is in front of current start, start and end will be set to new end value.
- Parameters
-
end new end line
Definition at line 181 of file linerange.h.
◆ setRange() [1/2]
|
inlinenoexcept |
Set the start and end lines to start and end respectively.
- Note
- If start is after end, they will be reversed.
- Parameters
-
start start line end end line
Definition at line 141 of file linerange.h.
◆ setRange() [2/2]
|
inlinenoexcept |
Set the start and end lines to start and end respectively.
- Note
- If start is after end, they will be reversed.
- Parameters
-
start start line end end line
Definition at line 128 of file linerange.h.
◆ setStart()
|
inlinenoexcept |
Set the start line to start.
- Note
- If start is after current end, start and end will be set to new start value.
- Parameters
-
start new start line
Definition at line 165 of file linerange.h.
◆ start()
|
inlineconstexprnoexcept |
Get the start line of this line range.
This will always be <= end().
- Returns
- the start line of this line range.
Definition at line 105 of file linerange.h.
◆ toString()
QString LineRange::toString | ( | ) | const |
Returns the line range as string in the format "[start line, end line]".
- See also
- fromString()
Definition at line 145 of file utils/range.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.