KTextEditor

include/ktexteditor/range.h
1 /*
2  SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <[email protected]>
3  SPDX-FileCopyrightText: 2001-2005 Christoph Cullmann <[email protected]>
4  SPDX-FileCopyrightText: 2002 Christian Couder <[email protected]>
5  SPDX-FileCopyrightText: 2001 Joseph Wenninger <[email protected]>
6  SPDX-FileCopyrightText: 1999 Jochen Wilhelmy <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #ifndef KTEXTEDITOR_RANGE_H
12 #define KTEXTEDITOR_RANGE_H
13 
14 #include <ktexteditor/cursor.h>
15 #include <ktexteditor/linerange.h>
16 #include <ktexteditor_export.h>
17 
18 #include <QDebug>
19 #include <QtGlobal>
20 
21 namespace KTextEditor
22 {
23 /**
24  * \class Range range.h <KTextEditor/Range>
25  *
26  * \short An object representing a section of text, from one Cursor to another.
27  *
28  * A Range is a basic class which represents a range of text with two Cursors,
29  * from a start() position to an end() position.
30  *
31  * For simplicity and convenience, ranges always maintain their start position to
32  * be before or equal to their end position. Attempting to set either the
33  * start or end of the range beyond the respective end or start will result in
34  * both values being set to the specified position. In the constructor, the
35  * start and end will be swapped if necessary.
36  *
37  * If you want additional functionality such as the ability to maintain position
38  * in a document, see MovingRange.
39  *
40  * \sa MovingRange
41  *
42  * \author Hamish Rodda <[email protected]>
43  */
44 class KTEXTEDITOR_EXPORT Range
45 {
46 public:
47  /**
48  * Default constructor. Creates a valid range from position (0, 0) to
49  * position (0, 0).
50  */
51  Q_DECL_CONSTEXPR Range() Q_DECL_NOEXCEPT
52  {
53  }
54 
55  /**
56  * Constructor which creates a range from \e start to \e end.
57  * If start is after end, they will be swapped.
58  *
59  * \param start start position
60  * \param end end position
61  */
62  Q_DECL_CONSTEXPR Range(const Cursor &start, const Cursor &end) Q_DECL_NOEXCEPT : m_start(qMin(start, end)), m_end(qMax(start, end))
63  {
64  }
65 
66  /**
67  * Constructor which creates a single-line range from \p start,
68  * extending \p width characters along the same line.
69  *
70  * \param start start position
71  * \param width width of this range in columns along the same line
72  */
73  Q_DECL_CONSTEXPR Range(const Cursor &start, int width) Q_DECL_NOEXCEPT : m_start(qMin(start, Cursor(start.line(), start.column() + width))),
74  m_end(qMax(start, Cursor(start.line(), start.column() + width)))
75  {
76  }
77 
78  /**
79  * Constructor which creates a range from \p start, to \p endLine, \p endColumn.
80  *
81  * \param start start position
82  * \param endLine end line
83  * \param endColumn end column
84  */
85  Q_DECL_CONSTEXPR Range(const Cursor &start, int endLine, int endColumn) Q_DECL_NOEXCEPT : m_start(qMin(start, Cursor(endLine, endColumn))),
86  m_end(qMax(start, Cursor(endLine, endColumn)))
87  {
88  }
89 
90  /**
91  * Constructor which creates a range from \e startLine, \e startColumn to \e endLine, \e endColumn.
92  *
93  * \param startLine start line
94  * \param startColumn start column
95  * \param endLine end line
96  * \param endColumn end column
97  */
98  Q_DECL_CONSTEXPR Range(int startLine, int startColumn, int endLine, int endColumn) Q_DECL_NOEXCEPT
99  : m_start(qMin(Cursor(startLine, startColumn), Cursor(endLine, endColumn))),
100  m_end(qMax(Cursor(startLine, startColumn), Cursor(endLine, endColumn)))
101  {
102  }
103 
104  /**
105  * Validity check. In the base class, returns true unless the range starts before (0,0).
106  */
107  Q_DECL_CONSTEXPR inline bool isValid() const Q_DECL_NOEXCEPT
108  {
109  return start().isValid() && end().isValid();
110  }
111 
112  /**
113  * Returns an invalid range.
114  */
115  Q_DECL_CONSTEXPR static Range invalid() Q_DECL_NOEXCEPT
116  {
118  }
119 
120  /**
121  * Returns the cursor position as string in the format
122  * "start-line:start-column,endl-line:end-column".
123  * \see fromString()
124  */
126  {
127  return QLatin1Char('[') + m_start.toString() + QLatin1String(", ") + m_end.toString() + QLatin1Char(']');
128  }
129 
130 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
131  /**
132  * Returns a Range created from the string \p str containing the format
133  * "[(start-line, start-column), (endl-line:end-column)]".
134  * In case the string cannot be parsed, an Range::invalid() is returned.
135  * \see toString()
136  */
137  // TODO KF6: Remove this overload in favor of fromString(QStringView).
138  static Range fromString(const QString &str) Q_DECL_NOEXCEPT
139  {
140  return fromString(str.leftRef(-1));
141  }
142 
143  /**
144  * Returns a Range created from the string \p str containing the format
145  * "[(start-line, start-column), (endl-line:end-column)]".
146  * In case the string cannot be parsed, an Range::invalid() is returned.
147  * \see toString()
148  */
149  // TODO KF6: Remove this overload in favor of fromString(QStringView).
150  static Range fromString(const QStringRef &str) Q_DECL_NOEXCEPT;
151 #endif
152 
153  /**
154  * Returns a Range created from the string \p str containing the format
155  * "[(start-line, start-column), (endl-line:end-column)]".
156  * In case the string cannot be parsed, an Range::invalid() is returned.
157  * \see toString()
158  */
159  static Range fromString(QStringView str) Q_DECL_NOEXCEPT;
160 
161  /**
162  * \name Position
163  *
164  * The following functions provide access to, and manipulation of, the range's position.
165  * \{
166  */
167 
168  /**
169  * Get the start position of this range. This will always be <= end().
170  *
171  * \returns const reference to the start position of this range.
172  */
173  Q_DECL_CONSTEXPR inline Cursor start() const Q_DECL_NOEXCEPT
174  {
175  return m_start;
176  }
177 
178  /**
179  * Get the end position of this range. This will always be >= start().
180  *
181  * \returns const reference to the end position of this range.
182  */
183  Q_DECL_CONSTEXPR inline Cursor end() const Q_DECL_NOEXCEPT
184  {
185  return m_end;
186  }
187 
188  /**
189  * Convert this Range to a LineRange
190  *
191  * @return LineRange from the start line to the end line of this range.
192  */
193  Q_DECL_CONSTEXPR inline LineRange toLineRange() const Q_DECL_NOEXCEPT
194  {
195  return {start().line(), end().line()};
196  }
197 
198  /**
199  * Convenience function. Set the start and end lines to \p line.
200  *
201  * \param line the line number to assign to start() and end()
202  */
203  void setBothLines(int line) Q_DECL_NOEXCEPT;
204 
205  /**
206  * Convenience function. Set the start and end columns to \p column.
207  *
208  * \param column the column number to assign to start() and end()
209  */
210  void setBothColumns(int column) Q_DECL_NOEXCEPT;
211 
212  /**
213  * Set the start and end cursors to \e range.start() and \e range.end() respectively.
214  *
215  * \param range range to assign to this range
216  */
217  void setRange(const Range &range) Q_DECL_NOEXCEPT;
218 
219  /**
220  * \overload
221  * \n \n
222  * Set the start and end cursors to \e start and \e end respectively.
223  *
224  * \note If \e start is after \e end, they will be reversed.
225  *
226  * \param start start cursor
227  * \param end end cursor
228  */
229  void setRange(const Cursor &start, const Cursor &end) Q_DECL_NOEXCEPT;
230 
231  /**
232  * Set the start cursor to \e start.
233  *
234  * \note If \e start is after current end, start and end will be set to new start value.
235  *
236  * \param start new start cursor
237  */
238  inline void setStart(const Cursor &start) Q_DECL_NOEXCEPT
239  {
240  if (start > end()) {
241  setRange(start, start);
242  } else {
243  setRange(start, end());
244  }
245  }
246 
247  /**
248  * Set the end cursor to \e end.
249  *
250  * \note If \e end is in front of current start, start and end will be set to new end value.
251  *
252  * \param end new end cursor
253  */
254  inline void setEnd(const Cursor &end) Q_DECL_NOEXCEPT
255  {
256  if (end < start()) {
257  setRange(end, end);
258  } else {
259  setRange(start(), end);
260  }
261  }
262 
263  /**
264  * Expand this range if necessary to contain \p range.
265  *
266  * \param range range which this range should contain
267  *
268  * \return \e true if expansion occurred, \e false otherwise
269  */
270  bool expandToRange(const Range &range) Q_DECL_NOEXCEPT;
271 
272  /**
273  * Confine this range if necessary to fit within \p range.
274  *
275  * \param range range which should contain this range
276  *
277  * \return \e true if confinement occurred, \e false otherwise
278  */
279  bool confineToRange(const Range &range) Q_DECL_NOEXCEPT;
280 
281  /**
282  * Check whether this range is wholly contained within one line, ie. if
283  * the start() and end() positions are on the same line.
284  *
285  * \return \e true if both the start and end positions are on the same
286  * line, otherwise \e false
287  */
288  Q_DECL_CONSTEXPR inline bool onSingleLine() const Q_DECL_NOEXCEPT
289  {
290  return start().line() == end().line();
291  }
292 
293  /**
294  * Returns the number of lines separating the start() and end() positions.
295  *
296  * \return the number of lines separating the start() and end() positions;
297  * 0 if the start and end lines are the same.
298  */
299  Q_DECL_CONSTEXPR inline int numberOfLines() const Q_DECL_NOEXCEPT
300  {
301  return end().line() - start().line();
302  }
303 
304  /**
305  * Returns the number of columns separating the start() and end() positions.
306  *
307  * \return the number of columns separating the start() and end() positions;
308  * 0 if the start and end columns are the same.
309  */
310  Q_DECL_CONSTEXPR inline int columnWidth() const Q_DECL_NOEXCEPT
311  {
312  return end().column() - start().column();
313  }
314 
315  /**
316  * Returns true if this range contains no characters, ie. the start() and
317  * end() positions are the same.
318  *
319  * \returns \e true if the range contains no characters, otherwise \e false
320  */
321  Q_DECL_CONSTEXPR inline bool isEmpty() const Q_DECL_NOEXCEPT
322  {
323  return start() == end();
324  }
325 
326  // BEGIN comparison functions
327  /**
328  * \}
329  *
330  * \name Comparison
331  *
332  * The following functions perform checks against this range in comparison
333  * to other lines, columns, cursors, and ranges.
334  * \{
335  */
336  /**
337  * Check whether the this range wholly encompasses \e range.
338  *
339  * \param range range to check
340  *
341  * \return \e true, if this range contains \e range, otherwise \e false
342  */
343  Q_DECL_CONSTEXPR inline bool contains(const Range &range) const Q_DECL_NOEXCEPT
344  {
345  return range.start() >= start() && range.end() <= end();
346  }
347 
348  /**
349  * Check to see if \p cursor is contained within this range, ie >= start() and < end().
350  *
351  * \param cursor the position to test for containment
352  *
353  * \return \e true if the cursor is contained within this range, otherwise \e false.
354  */
355  Q_DECL_CONSTEXPR inline bool contains(const Cursor &cursor) const Q_DECL_NOEXCEPT
356  {
357  return cursor >= start() && cursor < end();
358  }
359 
360  /**
361  * Returns true if this range wholly encompasses \p line.
362  *
363  * \param line line to check
364  *
365  * \return \e true if the line is wholly encompassed by this range, otherwise \e false.
366  */
367  Q_DECL_CONSTEXPR inline bool containsLine(int line) const Q_DECL_NOEXCEPT
368  {
369  return (line > start().line() || (line == start().line() && !start().column())) && line < end().line();
370  }
371 
372  /**
373  * Check whether the range contains \e column.
374  *
375  * \param column column to check
376  *
377  * \return \e true if the range contains \e column, otherwise \e false
378  */
379  Q_DECL_CONSTEXPR inline bool containsColumn(int column) const Q_DECL_NOEXCEPT
380  {
381  return column >= start().column() && column < end().column();
382  }
383 
384  /**
385  * Check whether the this range overlaps with \e range.
386  *
387  * \param range range to check against
388  *
389  * \return \e true, if this range overlaps with \e range, otherwise \e false
390  */
391  Q_DECL_CONSTEXPR inline bool overlaps(const Range &range) const Q_DECL_NOEXCEPT
392  {
393  return (range.start() <= start()) ? (range.end() > start()) : (range.end() >= end()) ? (range.start() < end()) : contains(range);
394  }
395 
396  /**
397  * Check whether the range overlaps at least part of \e line.
398  *
399  * \param line line to check
400  *
401  * \return \e true, if the range overlaps at least part of \e line, otherwise \e false
402  */
403  Q_DECL_CONSTEXPR inline bool overlapsLine(int line) const Q_DECL_NOEXCEPT
404  {
405  return line >= start().line() && line <= end().line();
406  }
407 
408  /**
409  * Check to see if this range overlaps \p column; that is, if \p column is
410  * between start().column() and end().column(). This function is most likely
411  * to be useful in relation to block text editing.
412  *
413  * \param column the column to test
414  *
415  * \return \e true if the column is between the range's starting and ending
416  * columns, otherwise \e false.
417  */
418  Q_DECL_CONSTEXPR inline bool overlapsColumn(int column) const Q_DECL_NOEXCEPT
419  {
420  return start().column() <= column && end().column() > column;
421  }
422 
423  /**
424  * Check whether \p cursor is located at either of the start() or end()
425  * boundaries.
426  *
427  * \param cursor cursor to check
428  *
429  * \return \e true if the cursor is equal to \p start() or \p end(),
430  * otherwise \e false.
431  */
432  Q_DECL_CONSTEXPR inline bool boundaryAtCursor(const Cursor &cursor) const Q_DECL_NOEXCEPT
433  {
434  return cursor == start() || cursor == end();
435  }
436  //!\}
437  // END
438 
439  /**
440  * Intersects this range with another, returning the shared area of
441  * the two ranges.
442  *
443  * \param range other range to intersect with this
444  *
445  * \return the intersection of this range and the supplied \a range.
446  */
447  Q_DECL_CONSTEXPR inline Range intersect(const Range &range) const Q_DECL_NOEXCEPT
448  {
449  return ((!isValid() || !range.isValid() || *this > range || *this < range)) ? invalid() : Range(qMax(start(), range.start()), qMin(end(), range.end()));
450  }
451 
452  /**
453  * Returns the smallest range which encompasses this range and the
454  * supplied \a range.
455  *
456  * \param range other range to encompass
457  *
458  * \return the smallest range which contains this range and the supplied \a range.
459  */
460  Q_DECL_CONSTEXPR inline Range encompass(const Range &range) const Q_DECL_NOEXCEPT
461  {
462  return (!isValid()) ? (range.isValid() ? range : invalid())
463  : (!range.isValid()) ? (*this) : Range(qMin(start(), range.start()), qMax(end(), range.end()));
464  }
465 
466  /**
467  * Addition operator. Takes two ranges and returns their summation.
468  *
469  * \param r1 the first range
470  * \param r2 the second range
471  *
472  * \return a the summation of the two input ranges
473  */
474  Q_DECL_CONSTEXPR inline friend Range operator+(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
475  {
476  return Range(r1.start() + r2.start(), r1.end() + r2.end());
477  }
478 
479  /**
480  * Addition assignment operator. Adds \p r2 to this range.
481  *
482  * \param r1 the first range
483  * \param r2 the second range
484  *
485  * \return a reference to the cursor which has just been added to
486  */
487  inline friend Range &operator+=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
488  {
489  r1.setRange(r1.start() + r2.start(), r1.end() + r2.end());
490  return r1;
491  }
492 
493  /**
494  * Subtraction operator. Takes two ranges and returns the subtraction
495  * of \p r2 from \p r1.
496  *
497  * \param r1 the first range
498  * \param r2 the second range
499  *
500  * \return a range representing the subtraction of \p r2 from \p r1
501  */
502  Q_DECL_CONSTEXPR inline friend Range operator-(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
503  {
504  return Range(r1.start() - r2.start(), r1.end() - r2.end());
505  }
506 
507  /**
508  * Subtraction assignment operator. Subtracts \p r2 from \p r1.
509  *
510  * \param r1 the first range
511  * \param r2 the second range
512  *
513  * \return a reference to the range which has just been subtracted from
514  */
515  inline friend Range &operator-=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
516  {
517  r1.setRange(r1.start() - r2.start(), r1.end() - r2.end());
518  return r1;
519  }
520 
521  /**
522  * Intersects \a r1 and \a r2.
523  *
524  * \param r1 the first range
525  * \param r2 the second range
526  *
527  * \return the intersected range, invalid() if there is no overlap
528  */
529  Q_DECL_CONSTEXPR inline friend Range operator&(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
530  {
531  return r1.intersect(r2);
532  }
533 
534  /**
535  * Intersects \a r1 with \a r2 and assigns the result to \a r1.
536  *
537  * \param r1 the range to assign the intersection to
538  * \param r2 the range to intersect \a r1 with
539  *
540  * \return a reference to this range, after the intersection has taken place
541  */
542  inline friend Range &operator&=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
543  {
544  r1.setRange(r1.intersect(r2));
545  return r1;
546  }
547 
548  /**
549  * Equality operator.
550  *
551  * \param r1 first range to compare
552  * \param r2 second range to compare
553  *
554  * \return \e true if \e r1 and \e r2 equal, otherwise \e false
555  */
556  Q_DECL_CONSTEXPR inline friend bool operator==(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
557  {
558  return r1.start() == r2.start() && r1.end() == r2.end();
559  }
560 
561  /**
562  * Inequality operator.
563  *
564  * \param r1 first range to compare
565  * \param r2 second range to compare
566  *
567  * \return \e true if \e r1 and \e r2 do \e not equal, otherwise \e false
568  */
569  Q_DECL_CONSTEXPR inline friend bool operator!=(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
570  {
571  return r1.start() != r2.start() || r1.end() != r2.end();
572  }
573 
574  /**
575  * Greater than operator. Looks only at the position of the two ranges,
576  * does not consider their size.
577  *
578  * \param r1 first range to compare
579  * \param r2 second range to compare
580  *
581  * \return \e true if \e r1 starts after where \e r2 ends, otherwise \e false
582  */
583  Q_DECL_CONSTEXPR inline friend bool operator>(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
584  {
585  return r1.start() > r2.end();
586  }
587 
588  /**
589  * Less than operator. Looks only at the position of the two ranges,
590  * does not consider their size.
591  *
592  * \param r1 first range to compare
593  * \param r2 second range to compare
594  *
595  * \return \e true if \e r1 ends before \e r2 begins, otherwise \e false
596  */
597  Q_DECL_CONSTEXPR inline friend bool operator<(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
598  {
599  return r1.end() < r2.start();
600  }
601 
602  /**
603  * qDebug() stream operator. Writes this range to the debug output in a nicely formatted way.
604  */
605  inline friend QDebug operator<<(QDebug s, const Range &range)
606  {
607  s << "[" << range.start() << " -> " << range.end() << "]";
608  return s;
609  }
610 
611 private:
612  /**
613  * This range's start cursor pointer.
614  *
615  * \internal
616  */
617  Cursor m_start;
618 
619  /**
620  * This range's end cursor pointer.
621  *
622  * \internal
623  */
624  Cursor m_end;
625 };
626 
627 }
628 
629 Q_DECLARE_TYPEINFO(KTextEditor::Range, Q_MOVABLE_TYPE);
630 Q_DECLARE_METATYPE(KTextEditor::Range)
631 
632 /**
633  * QHash function for KTextEditor::Range.
634  * Returns the hash value for @p range.
635  */
636 inline uint qHash(const KTextEditor::Range &range, uint seed = 0) Q_DECL_NOTHROW
637 {
638  return qHash(qMakePair(qHash(range.start()), qHash(range.end())), seed);
639 }
640 
641 namespace QTest
642 {
643 // forward declaration of template in qtestcase.h
644 template<typename T>
645 char *toString(const T &);
646 
647 /**
648  * QTestLib integration to have nice output in e.g. QCOMPARE failures.
649  */
650 template<>
651 KTEXTEDITOR_EXPORT char *toString(const KTextEditor::Range &range);
652 }
653 
654 #endif
constexpr int numberOfLines() const Q_DECL_NOEXCEPT
Returns the number of lines separating the start() and end() positions.
constexpr bool overlaps(const Range &range) const Q_DECL_NOEXCEPT
Check whether the this range overlaps with range.
constexpr friend Range operator&(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Intersects r1 and r2.
constexpr Range encompass(const Range &range) const Q_DECL_NOEXCEPT
Returns the smallest range which encompasses this range and the supplied range.
friend Range & operator&=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Intersects r1 with r2 and assigns the result to r1.
Q_SCRIPTABLE Q_NOREPLY void start()
constexpr static Cursor invalid() Q_DECL_NOEXCEPT
Returns an invalid cursor.
Definition: cursor.h:109
An object representing lines from a start line to an end line.
Definition: linerange.h:37
An object representing a section of text, from one Cursor to another.
constexpr friend Range operator-(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Subtraction operator.
constexpr Range() Q_DECL_NOEXCEPT
Default constructor.
constexpr friend bool operator<(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Less than operator.
constexpr bool containsColumn(int column) const Q_DECL_NOEXCEPT
Check whether the range contains column.
constexpr bool contains(const Range &range) const Q_DECL_NOEXCEPT
Check whether the this range wholly encompasses range.
constexpr Cursor end() const Q_DECL_NOEXCEPT
Get the end position of this range.
QString toString() const
Returns the cursor position as string in the format "start-line:start-column,endl-line:end-column".
constexpr int columnWidth() const Q_DECL_NOEXCEPT
Returns the number of columns separating the start() and end() positions.
void setEnd(const Cursor &end) Q_DECL_NOEXCEPT
Set the end cursor to end.
The Cursor represents a position in a Document.
Definition: cursor.h:71
constexpr friend bool operator==(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Equality operator.
constexpr LineRange toLineRange() const Q_DECL_NOEXCEPT
Convert this Range to a LineRange.
constexpr friend bool operator!=(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Inequality operator.
char * toString(const T &value)
friend Range & operator-=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Subtraction assignment operator.
constexpr Range(const Cursor &start, const Cursor &end) Q_DECL_NOEXCEPT
Constructor which creates a range from start to end.
friend QDebug operator<<(QDebug s, const Range &range)
qDebug() stream operator.
constexpr bool overlapsColumn(int column) const Q_DECL_NOEXCEPT
Check to see if this range overlaps column; that is, if column is between start()....
constexpr bool isEmpty() const Q_DECL_NOEXCEPT
Returns true if this range contains no characters, ie.
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
constexpr bool contains(const Cursor &cursor) const Q_DECL_NOEXCEPT
Check to see if cursor is contained within this range, ie >= start() and < end().
void setRange(const Range &range) Q_DECL_NOEXCEPT
Set the start and end cursors to range.start() and range.end() respectively.
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
void setStart(const Cursor &start) Q_DECL_NOEXCEPT
Set the start cursor to start.
constexpr bool isValid() const Q_DECL_NOEXCEPT
Validity check.
constexpr friend Range operator+(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Addition operator.
constexpr Cursor start() const Q_DECL_NOEXCEPT
Get the start position of this range.
friend Range & operator+=(Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Addition assignment operator.
constexpr bool onSingleLine() const Q_DECL_NOEXCEPT
Check whether this range is wholly contained within one line, ie.
constexpr friend bool operator>(const Range &r1, const Range &r2) Q_DECL_NOEXCEPT
Greater than operator.
constexpr Range(const Cursor &start, int endLine, int endColumn) Q_DECL_NOEXCEPT
Constructor which creates a range from start, to endLine, endColumn.
constexpr Range intersect(const Range &range) const Q_DECL_NOEXCEPT
Intersects this range with another, returning the shared area of the two ranges.
constexpr bool containsLine(int line) const Q_DECL_NOEXCEPT
Returns true if this range wholly encompasses line.
constexpr static Range invalid() Q_DECL_NOEXCEPT
Returns an invalid range.
constexpr bool boundaryAtCursor(const Cursor &cursor) const Q_DECL_NOEXCEPT
Check whether cursor is located at either of the start() or end() boundaries.
constexpr bool overlapsLine(int line) const Q_DECL_NOEXCEPT
Check whether the range overlaps at least part of line.
constexpr Range(const Cursor &start, int width) Q_DECL_NOEXCEPT
Constructor which creates a single-line range from start, extending width characters along the same l...
constexpr Range(int startLine, int startColumn, int endLine, int endColumn) Q_DECL_NOEXCEPT
Constructor which creates a range from startLine, startColumn to endLine, endColumn.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Apr 1 2023 03:57:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.