18#include <sonnet/speller.h>
20#include "katedocument.h"
29 enum ModificationType {
34 typedef QPair<KTextEditor::MovingRange *, QString> SpellCheckItem;
35 typedef QList<KTextEditor::MovingRange *> MovingRangeList;
36 typedef QPair<KTextEditor::MovingRange *, QString> MisspelledItem;
37 typedef QList<MisspelledItem> MisspelledList;
39 typedef QPair<ModificationType, KTextEditor::MovingRange *> ModificationItem;
40 typedef QList<ModificationItem> ModificationList;
43 explicit KateOnTheFlyChecker(KTextEditor::DocumentPrivate *document);
44 ~KateOnTheFlyChecker()
override;
46 QPair<KTextEditor::Range, QString> getMisspelledItem(
const KTextEditor::Cursor cursor)
const;
47 QString dictionaryForMisspelledRange(KTextEditor::Range range)
const;
48 MovingRangeList installedMovingRanges(KTextEditor::Range range)
const;
50 void clearMisspellingForWord(
const QString &word);
53 void textInserted(KTextEditor::Document *document, KTextEditor::Range range);
54 void textRemoved(KTextEditor::Document *document, KTextEditor::Range range);
59 void updateInstalledMovingRanges(KTextEditor::View *view);
62 KTextEditor::DocumentPrivate *
const m_document;
63 Sonnet::Speller m_speller;
64 QList<SpellCheckItem> m_spellCheckQueue;
65 Sonnet::BackgroundChecker *m_backgroundChecker;
66 SpellCheckItem m_currentlyCheckedItem;
67 MisspelledList m_misspelledList;
68 ModificationList m_modificationList;
69 KTextEditor::DocumentPrivate::OffsetList m_currentDecToEncOffsetList;
70 std::map<KTextEditor::View *, KTextEditor::Range> m_displayRangeMap;
74 void queueLineSpellCheck(KTextEditor::DocumentPrivate *document,
int line);
78 void queueLineSpellCheck(KTextEditor::Range range,
const QString &dictionary);
79 void queueSpellCheckVisibleRange(KTextEditor::Range range);
80 void queueSpellCheckVisibleRange(KTextEditor::ViewPrivate *view, KTextEditor::Range range);
82 void addToSpellCheckQueue(KTextEditor::Range range,
const QString &dictionary);
83 void addToSpellCheckQueue(KTextEditor::MovingRange *range,
const QString &dictionary);
85 QTimer *m_viewRefreshTimer;
86 QPointer<KTextEditor::View> m_refreshView;
88 virtual void removeRangeFromEverything(KTextEditor::MovingRange *range);
89 bool removeRangeFromCurrentSpellCheck(KTextEditor::MovingRange *range);
90 bool removeRangeFromSpellCheckQueue(KTextEditor::MovingRange *range);
91 void rangeEmpty(KTextEditor::MovingRange *range)
override;
92 void rangeInvalid(KTextEditor::MovingRange *range)
override;
93 void caretEnteredRange(KTextEditor::MovingRange *range, KTextEditor::View *view)
override;
94 void caretExitedRange(KTextEditor::MovingRange *range, KTextEditor::View *view)
override;
96 KTextEditor::Range findWordBoundaries(
const KTextEditor::Cursor begin,
const KTextEditor::Cursor end);
98 void deleteMovingRange(KTextEditor::MovingRange *range);
99 void deleteMovingRanges(
const QList<KTextEditor::MovingRange *> &list);
100 void deleteMovingRangeQuickly(KTextEditor::MovingRange *range);
101 void stopCurrentSpellCheck();
104 void performSpellCheck();
105 void addToDictionary(
const QString &word);
106 void addToSession(
const QString &word);
107 void misspelling(
const QString &word,
int start);
108 void spellCheckDone();
110 void viewDestroyed(
QObject *obj);
111 void addView(KTextEditor::Document *document, KTextEditor::View *view);
112 void removeView(KTextEditor::View *view);
114 void restartViewRefreshTimer(KTextEditor::View *view);
115 void viewRefreshTimeout();
117 void handleModifiedRanges();
118 void handleInsertedText(KTextEditor::Range range);
119 void handleRemovedText(KTextEditor::Range range);
120 void handleRespellCheckBlock(
int start,
int end);
121 bool removeRangeFromModificationList(KTextEditor::MovingRange *range);
122 void clearModificationList();
A class which provides notifications of state changes to a MovingRange.
static constexpr Range invalid() noexcept
Returns an invalid range.
Q_SCRIPTABLE Q_NOREPLY void start()