File indexing completed on 2024-04-28 15:30:57

0001 /*
0002     SPDX-FileCopyrightText: 2010 Christoph Cullmann <cullmann@kde.org>
0003 
0004     Based on code of the SmartCursor/Range by:
0005     SPDX-FileCopyrightText: 2003-2005 Hamish Rodda <rodda@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #include "movingrange.h"
0011 
0012 using namespace KTextEditor;
0013 
0014 MovingRange::MovingRange() = default;
0015 
0016 MovingRange::~MovingRange() = default;
0017 
0018 void MovingRange::setRange(const Cursor &start, const Cursor &end)
0019 {
0020     // just use other function, KTextEditor::Range will handle some normalization
0021     setRange(Range(start, end));
0022 }
0023 
0024 bool MovingRange::overlaps(const Range &range) const
0025 {
0026     if (range.start() <= start()) {
0027         return range.end() > start();
0028     }
0029 
0030     else if (range.end() >= end()) {
0031         return range.start() < end();
0032     }
0033 
0034     else {
0035         return contains(range);
0036     }
0037 }