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 withCaseSensitivityMarkersStripped(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 { |
40 | Forward, |
41 | Backward |
42 | }; |
43 | void init(SearchDirection); |
44 | bool handleKeyPress(const QKeyEvent *keyEvent) override; |
45 | void editTextChanged(const QString &newText) override; |
46 | CompletionStartParams completionInvoked(Completer::CompletionInvocation invocationType) override; |
47 | void completionChosen() override; |
48 | void deactivate(bool wasAborted) override; |
49 | bool isSendingSyntheticSearchCompletedKeypress() const |
50 | { |
51 | return m_isSendingSyntheticSearchCompletedKeypress; |
52 | } |
53 | |
54 | private: |
55 | QLineEdit *m_edit = nullptr; |
56 | SearchDirection m_searchDirection; |
57 | KTextEditor::Cursor m_startingCursorPos; |
58 | KateVi::Searcher::SearchParams m_currentSearchParams; |
59 | CompletionStartParams activateSearchHistoryCompletion(); |
60 | enum BarBackgroundStatus { |
61 | Normal, |
62 | MatchFound, |
63 | NoMatchFound |
64 | }; |
65 | void setBarBackground(BarBackgroundStatus status); |
66 | bool m_isSendingSyntheticSearchCompletedKeypress = false; |
67 | }; |
68 | } |
69 | |
70 | #endif |
71 |