File indexing completed on 2024-04-14 03:55:49

0001 /*
0002     SPDX-FileCopyrightText: 2008 Erlend Hamberg <ehamberg@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KATEVI_RANGE_H
0008 #define KATEVI_RANGE_H
0009 
0010 #include <QDebug>
0011 #include <vimode/definitions.h>
0012 
0013 namespace KTextEditor
0014 {
0015 class Cursor;
0016 class Range;
0017 }
0018 
0019 namespace KateVi
0020 {
0021 enum MotionType { ExclusiveMotion = 0, InclusiveMotion };
0022 
0023 class Range
0024 {
0025 public:
0026     Range();
0027 
0028     /**
0029      * For motions which only return a position, in contrast to
0030      * "text objects" which returns a full blown range.
0031      */
0032     explicit Range(int elin, int ecol, MotionType inc);
0033 
0034     explicit Range(int slin, int scol, int elin, int ecol, MotionType mt);
0035     explicit Range(const KTextEditor::Cursor c, MotionType mt);
0036     explicit Range(const KTextEditor::Cursor c1, const KTextEditor::Cursor c2, MotionType mt);
0037 
0038     /**
0039      * Modifies this range so the start attributes are lesser than
0040      * the end attributes.
0041      */
0042     void normalize();
0043 
0044     /**
0045      * @returns an equivalent KTextEditor::Range for this Range.
0046      */
0047     KTextEditor::Range toEditorRange() const;
0048 
0049     /**
0050      * Writes this KateViRange to the debug output in a nicely formatted way.
0051      */
0052     friend QDebug operator<<(QDebug s, const Range &range);
0053 
0054     /**
0055      * @returns an invalid KateViRange allocated on stack.
0056      */
0057     static Range invalid();
0058 
0059 public:
0060     int startLine, startColumn;
0061     int endLine, endColumn;
0062     MotionType motionType;
0063     bool valid, jump;
0064 };
0065 
0066 }
0067 
0068 #endif /* KATEVI_RANGE_H */