KTextEditor

movingrange.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Christoph Cullmann <[email protected]>
3 
4  Based on code of the SmartCursor/Range by:
5  SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #include "movingrange.h"
11 
12 using namespace KTextEditor;
13 
14 MovingRange::MovingRange() = default;
15 
16 MovingRange::~MovingRange() = default;
17 
18 void MovingRange::setRange(const Cursor &start, const Cursor &end)
19 {
20  // just use other function, KTextEditor::Range will handle some normalization
22 }
23 
24 bool MovingRange::overlaps(const Range &range) const
25 {
26  if (range.start() <= start()) {
27  return range.end() > start();
28  }
29 
30  else if (range.end() >= end()) {
31  return range.start() < end();
32  }
33 
34  else {
35  return contains(range);
36  }
37 }
virtual const MovingCursor & start() const =0
Retrieve start cursor of this range, read-only.
MovingRange()
For inherited class only.
Q_SCRIPTABLE Q_NOREPLY void start()
bool overlaps(const Range &range) const
Check whether the this range overlaps with range.
Definition: movingrange.cpp:24
An object representing a section of text, from one Cursor to another.
constexpr Cursor end() const Q_DECL_NOEXCEPT
Get the end position of this range.
The Cursor represents a position in a Document.
Definition: cursor.h:71
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:22
virtual const MovingCursor & end() const =0
Retrieve end cursor of this range, read-only.
virtual ~MovingRange()
Destruct the moving range.
constexpr Cursor start() const Q_DECL_NOEXCEPT
Get the start position of this range.
virtual void setRange(const KTextEditor::Range &range)=0
Set the range of this range.
bool contains(const Range &range) const
Check whether the this range wholly encompasses range.
Definition: movingrange.h:432
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 03:52:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.