| 1 | /* |
|---|---|
| 2 | SPDX-FileCopyrightText: KDE Developers |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #ifndef KATE_NORMAL_INPUT_MODE_H |
| 8 | #define KATE_NORMAL_INPUT_MODE_H |
| 9 | |
| 10 | #include <memory> |
| 11 | |
| 12 | #include "kateabstractinputmode.h" |
| 13 | |
| 14 | class KateNormalInputModeFactory; |
| 15 | class KateSearchBar; |
| 16 | class KateCommandLineBar; |
| 17 | |
| 18 | class KateNormalInputMode : public KateAbstractInputMode |
| 19 | { |
| 20 | explicit KateNormalInputMode(KateViewInternal *viewInternal); |
| 21 | friend KateNormalInputModeFactory; |
| 22 | |
| 23 | public: |
| 24 | KTextEditor::View::ViewMode viewMode() const override; |
| 25 | QString viewModeHuman() const override; |
| 26 | KTextEditor::View::InputMode viewInputMode() const override; |
| 27 | QString viewInputModeHuman() const override; |
| 28 | |
| 29 | void activate() override; |
| 30 | void deactivate() override; |
| 31 | void reset() override; |
| 32 | |
| 33 | bool overwrite() const override; |
| 34 | void overwrittenChar(const QChar &) override; |
| 35 | |
| 36 | void clearSelection() override; |
| 37 | bool stealKey(QKeyEvent *) override; |
| 38 | |
| 39 | void gotFocus() override; |
| 40 | void lostFocus() override; |
| 41 | |
| 42 | void readSessionConfig(const KConfigGroup &config) override; |
| 43 | void writeSessionConfig(KConfigGroup &config) override; |
| 44 | void updateRendererConfig() override; |
| 45 | void updateConfig() override; |
| 46 | void readWriteChanged(bool rw) override; |
| 47 | |
| 48 | void find() override; |
| 49 | void findSelectedForwards() override; |
| 50 | void findSelectedBackwards() override; |
| 51 | void findReplace() override; |
| 52 | void findNext() override; |
| 53 | void findPrevious() override; |
| 54 | |
| 55 | void activateCommandLine() override; |
| 56 | |
| 57 | bool keyPress(QKeyEvent *) override; |
| 58 | bool blinkCaret() const override; |
| 59 | KTextEditor::caretStyles caretStyle() const override; |
| 60 | |
| 61 | void toggleInsert() override; |
| 62 | void launchInteractiveCommand(const QString &command) override; |
| 63 | |
| 64 | QString bookmarkLabel(int line) const override; |
| 65 | |
| 66 | private: |
| 67 | /** |
| 68 | * Search bar mode: |
| 69 | * - Setup Incremental mode, among other things: potential new search pattern |
| 70 | * - Setup Power mode, aka find & replace: Also potential new search pattern |
| 71 | * - Use current mode and current search pattern or if no Search bar exists, launch Incremental mode |
| 72 | */ |
| 73 | enum SearchBarMode { |
| 74 | IncrementalSearchBar, |
| 75 | PowerSearchBar, |
| 76 | IncrementalSearchBarOrKeepMode |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * Get search bar, create it on demand. (with right mode) |
| 81 | * @param mode wanted search bar mode |
| 82 | * @return search bar widget |
| 83 | */ |
| 84 | KateSearchBar *searchBar(const SearchBarMode mode); |
| 85 | |
| 86 | /** |
| 87 | * search bar around? |
| 88 | * @return search bar around? |
| 89 | */ |
| 90 | bool hasSearchBar() const |
| 91 | { |
| 92 | return m_searchBar.get(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Get command line bar, create it on demand. |
| 97 | * @return command line bar, created if not already there |
| 98 | */ |
| 99 | KateCommandLineBar *cmdLineBar(); |
| 100 | |
| 101 | private: |
| 102 | std::unique_ptr<KateSearchBar> m_searchBar; |
| 103 | std::unique_ptr<KateCommandLineBar> m_cmdLine; |
| 104 | }; |
| 105 | |
| 106 | #endif |
| 107 |
