KTextEditor

movingrange.cpp
1 /* SPDX-License-Identifier: LGPL-2.0-or-later
2 
3  Copyright (C) 2010 Christoph Cullmann <[email protected]>
4 
5  Based on code of the SmartCursor/Range by:
6  Copyright (C) 2003-2005 Hamish Rodda <[email protected]>
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 */
23 
24 #include "movingrange.h"
25 
26 using namespace KTextEditor;
27 
29 {
30 }
31 
33 {
34 }
35 
37 {
38  // just use other function, KTextEditor::Range will handle some normalization
39  setRange(Range(start, end));
40 }
41 
42 bool MovingRange::overlaps(const Range &range) const
43 {
44  if (range.start() <= start()) {
45  return range.end() > start();
46  }
47 
48  else if (range.end() >= end()) {
49  return range.start() < end();
50  }
51 
52  else {
53  return contains(range);
54  }
55 }
virtual const MovingCursor & end() const =0
Retrieve end cursor of this range, read-only.
virtual const MovingCursor & start() const =0
Retrieve start cursor of this range, read-only.
The Cursor represents a position in a Document.
Definition: cursor.h:83
bool contains(const Range &range) const
Check whether the this range wholly encompasses range.
Definition: movingrange.h:434
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
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.
MovingRange()
For inherited class only.
Definition: movingrange.cpp:28
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.
virtual ~MovingRange()
Destruct the moving range.
Definition: movingrange.cpp:32
bool overlaps(const Range &range) const
Check whether the this range overlaps with range.
Definition: movingrange.cpp:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 24 2020 23:10:51 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.