1/*
2 SPDX-FileCopyrightText: 2008 Erlend Hamberg <ehamberg@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATEVI_RANGE_H
8#define KATEVI_RANGE_H
9
10#include <QDebug>
11#include <vimode/definitions.h>
12
13namespace KTextEditor
14{
15class Cursor;
16class Range;
17}
18
19namespace KateVi
20{
21enum MotionType { ExclusiveMotion = 0, InclusiveMotion };
22
23class Range
24{
25public:
26 Range();
27
28 /**
29 * For motions which only return a position, in contrast to
30 * "text objects" which returns a full blown range.
31 */
32 explicit Range(int elin, int ecol, MotionType inc);
33
34 explicit Range(int slin, int scol, int elin, int ecol, MotionType mt);
35 explicit Range(const KTextEditor::Cursor c, MotionType mt);
36 explicit Range(const KTextEditor::Cursor c1, const KTextEditor::Cursor c2, MotionType mt);
37
38 /**
39 * Modifies this range so the start attributes are lesser than
40 * the end attributes.
41 */
42 void normalize();
43
44 /**
45 * @returns an equivalent KTextEditor::Range for this Range.
46 */
47 KTextEditor::Range toEditorRange() const;
48
49 /**
50 * Writes this KateViRange to the debug output in a nicely formatted way.
51 */
52 friend QDebug operator<<(QDebug s, const Range &range);
53
54 /**
55 * @returns an invalid KateViRange allocated on stack.
56 */
57 static Range invalid();
58
59public:
60 int startLine, startColumn;
61 int endLine, endColumn;
62 MotionType motionType;
63 bool valid, jump;
64};
65
66}
67
68#endif /* KATEVI_RANGE_H */
69

source code of ktexteditor/src/vimode/range.h