1 | /* |
2 | SPDX-FileCopyrightText: 2013-2016 Simon St James <kdedevel@etotheipiplusone.com> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KATEVI_EMULATED_COMMAND_BAR_SEARCHMODE_H |
8 | #define KATEVI_EMULATED_COMMAND_BAR_SEARCHMODE_H |
9 | |
10 | #include "../searcher.h" |
11 | #include "activemode.h" |
12 | |
13 | namespace KTextEditor |
14 | { |
15 | class ViewPrivate; |
16 | } |
17 | |
18 | #include <KTextEditor/Cursor> |
19 | |
20 | namespace KateVi |
21 | { |
22 | class EmulatedCommandBar; |
23 | QString vimRegexToQtRegexPattern(const QString &vimRegexPattern); // TODO - move these generic helper functions into their own file? |
24 | QString (const QString &originalSearchTerm); |
25 | QString ensuredCharEscaped(const QString &originalString, QChar charToEscape); |
26 | QStringList reversed(const QStringList &originalList); |
27 | |
28 | class SearchMode : public ActiveMode |
29 | { |
30 | public: |
31 | SearchMode(EmulatedCommandBar *emulatedCommandBar, |
32 | MatchHighlighter *matchHighlighter, |
33 | InputModeManager *viInputModeManager, |
34 | KTextEditor::ViewPrivate *view, |
35 | QLineEdit *edit); |
36 | ~SearchMode() override |
37 | { |
38 | } |
39 | enum class SearchDirection { Forward, Backward }; |
40 | void init(SearchDirection); |
41 | bool handleKeyPress(const QKeyEvent *keyEvent) override; |
42 | void editTextChanged(const QString &newText) override; |
43 | CompletionStartParams completionInvoked(Completer::CompletionInvocation invocationType) override; |
44 | void completionChosen() override; |
45 | void deactivate(bool wasAborted) override; |
46 | bool isSendingSyntheticSearchCompletedKeypress() const |
47 | { |
48 | return m_isSendingSyntheticSearchCompletedKeypress; |
49 | } |
50 | |
51 | private: |
52 | QLineEdit *m_edit = nullptr; |
53 | SearchDirection m_searchDirection; |
54 | KTextEditor::Cursor m_startingCursorPos; |
55 | KateVi::Searcher::SearchParams m_currentSearchParams; |
56 | CompletionStartParams activateSearchHistoryCompletion(); |
57 | enum BarBackgroundStatus { Normal, MatchFound, NoMatchFound }; |
58 | void setBarBackground(BarBackgroundStatus status); |
59 | bool m_isSendingSyntheticSearchCompletedKeypress = false; |
60 | }; |
61 | } |
62 | |
63 | #endif |
64 | |