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
14class KateNormalInputModeFactory;
15class KateSearchBar;
16class KateCommandLineBar;
17
18class KateNormalInputMode : public KateAbstractInputMode
19{
20 explicit KateNormalInputMode(KateViewInternal *viewInternal);
21 friend KateNormalInputModeFactory;
22
23public:
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
66private:
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 { IncrementalSearchBar, PowerSearchBar, IncrementalSearchBarOrKeepMode };
74
75 /**
76 * Get search bar, create it on demand. (with right mode)
77 * @param mode wanted search bar mode
78 * @return search bar widget
79 */
80 KateSearchBar *searchBar(const SearchBarMode mode);
81
82 /**
83 * search bar around?
84 * @return search bar around?
85 */
86 bool hasSearchBar() const
87 {
88 return m_searchBar.get();
89 }
90
91 /**
92 * Get command line bar, create it on demand.
93 * @return command line bar, created if not already there
94 */
95 KateCommandLineBar *cmdLineBar();
96
97private:
98 std::unique_ptr<KateSearchBar> m_searchBar;
99 std::unique_ptr<KateCommandLineBar> m_cmdLine;
100};
101
102#endif
103

source code of ktexteditor/src/inputmode/katenormalinputmode.h