File indexing completed on 2024-04-28 15:31:20
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 <ktexteditor_export.h> 0012 #include <vimode/definitions.h> 0013 0014 namespace KTextEditor 0015 { 0016 class Cursor; 0017 class Range; 0018 } 0019 0020 namespace KateVi 0021 { 0022 enum MotionType { ExclusiveMotion = 0, InclusiveMotion }; 0023 0024 class KTEXTEDITOR_EXPORT Range 0025 { 0026 public: 0027 Range(); 0028 0029 /** 0030 * For motions which only return a position, in contrast to 0031 * "text objects" which returns a full blown range. 0032 */ 0033 explicit Range(int elin, int ecol, MotionType inc); 0034 0035 explicit Range(int slin, int scol, int elin, int ecol, MotionType mt); 0036 explicit Range(const KTextEditor::Cursor c, MotionType mt); 0037 explicit Range(const KTextEditor::Cursor c1, const KTextEditor::Cursor c2, MotionType mt); 0038 0039 /** 0040 * Modifies this range so the start attributes are lesser than 0041 * the end attributes. 0042 */ 0043 void normalize(); 0044 0045 /** 0046 * @returns an equivalent KTextEditor::Range for this Range. 0047 */ 0048 KTextEditor::Range toEditorRange() const; 0049 0050 /** 0051 * Writes this KateViRange to the debug output in a nicely formatted way. 0052 */ 0053 friend QDebug operator<<(QDebug s, const Range &range); 0054 0055 /** 0056 * @returns an invalid KateViRange allocated on stack. 0057 */ 0058 static Range invalid(); 0059 0060 public: 0061 int startLine, startColumn; 0062 int endLine, endColumn; 0063 MotionType motionType; 0064 bool valid, jump; 0065 }; 0066 0067 } 0068 0069 #endif /* KATEVI_RANGE_H */