| 1 | /* |
| 2 | SPDX-FileCopyrightText: KDE Developers |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KATE_VIMODE_MARKS_H |
| 8 | #define KATE_VIMODE_MARKS_H |
| 9 | |
| 10 | #include <KConfigGroup> |
| 11 | #include <KTextEditor/Document> |
| 12 | |
| 13 | #include <QMap> |
| 14 | |
| 15 | namespace KTextEditor |
| 16 | { |
| 17 | class DocumentPrivate; |
| 18 | class Cursor; |
| 19 | class MovingCursor; |
| 20 | } |
| 21 | |
| 22 | namespace KateVi |
| 23 | { |
| 24 | class InputModeManager; |
| 25 | |
| 26 | class Marks : public QObject |
| 27 | { |
| 28 | public: |
| 29 | explicit Marks(InputModeManager *imm); |
| 30 | |
| 31 | /** JBOS == Just a Bunch Of Shortcuts **/ |
| 32 | void setStartEditYanked(const KTextEditor::Cursor pos); |
| 33 | void setFinishEditYanked(const KTextEditor::Cursor pos); |
| 34 | void setLastChange(const KTextEditor::Cursor pos); |
| 35 | void setInsertStopped(const KTextEditor::Cursor pos); |
| 36 | void setSelectionStart(const KTextEditor::Cursor pos); |
| 37 | void setSelectionFinish(const KTextEditor::Cursor pos); |
| 38 | void setUserMark(const QChar &mark, const KTextEditor::Cursor pos); |
| 39 | |
| 40 | KTextEditor::Cursor getStartEditYanked() const; |
| 41 | KTextEditor::Cursor getFinishEditYanked() const; |
| 42 | KTextEditor::Cursor getLastChange() const; |
| 43 | KTextEditor::Cursor getInsertStopped() const; |
| 44 | KTextEditor::Cursor getSelectionStart() const; |
| 45 | KTextEditor::Cursor getSelectionFinish() const; |
| 46 | KTextEditor::Cursor getMarkPosition(const QChar &mark) const; |
| 47 | |
| 48 | void writeSessionConfig(KConfigGroup &config) const; |
| 49 | void readSessionConfig(const KConfigGroup &config); |
| 50 | |
| 51 | QString getMarksOnTheLine(int line) const; |
| 52 | |
| 53 | private: |
| 54 | void syncViMarksAndBookmarks(); |
| 55 | static bool isShowable(const QChar &mark); |
| 56 | |
| 57 | void setMark(const QChar &mark, const KTextEditor::Cursor pos); |
| 58 | |
| 59 | private: |
| 60 | void markChanged(KTextEditor::Document *doc, KTextEditor::Mark mark, KTextEditor::Document::MarkChangeAction action); |
| 61 | |
| 62 | private: |
| 63 | InputModeManager *m_inputModeManager; |
| 64 | KTextEditor::DocumentPrivate *m_doc; |
| 65 | |
| 66 | QMap<QChar, KTextEditor::MovingCursor *> m_marks; |
| 67 | bool m_settingMark; |
| 68 | }; |
| 69 | } |
| 70 | |
| 71 | #endif // KATE_VIMODE_MARKS_H |
| 72 | |