7#include "katenormalinputmode.h"
8#include "katecompletionwidget.h"
10#include "katedocument.h"
11#include "katerenderer.h"
12#include "katesearchbar.h"
14#include "kateviewinternal.h"
16#include <KLocalizedString>
18KateNormalInputMode::KateNormalInputMode(KateViewInternal *viewInternal)
19 : KateAbstractInputMode(viewInternal)
23void KateNormalInputMode::activate()
25 view()->activateEditActions();
28void KateNormalInputMode::deactivate()
30 view()->deactivateEditActions();
33void KateNormalInputMode::reset()
38bool KateNormalInputMode::overwrite()
const
40 return view()->doc()->
config()->ovr();
43void KateNormalInputMode::overwrittenChar(
const QChar &)
48void KateNormalInputMode::clearSelection()
50 view()->clearSelection();
53bool KateNormalInputMode::stealKey(
QKeyEvent *)
63QString KateNormalInputMode::viewInputModeHuman()
const
65 return i18n(
"Normal");
73QString KateNormalInputMode::viewModeHuman()
const
75 return view()->isOverwriteMode() ?
i18n(
"OVERWRITE") :
i18n(
"INSERT");
78void KateNormalInputMode::gotFocus()
80 view()->activateEditActions();
83void KateNormalInputMode::lostFocus()
85 view()->deactivateEditActions();
88void KateNormalInputMode::readSessionConfig(
const KConfigGroup &)
93void KateNormalInputMode::writeSessionConfig(
KConfigGroup &)
98void KateNormalInputMode::updateConfig()
103void KateNormalInputMode::readWriteChanged(
bool)
107 m_searchBar->slotReadWriteChanged();
111void KateNormalInputMode::find()
113 KateSearchBar *
const bar = searchBar(IncrementalSearchBar);
114 view()->bottomViewBar()->addBarWidget(bar);
115 view()->bottomViewBar()->showBarWidget(bar);
119void KateNormalInputMode::findSelectedForwards()
121 searchBar(IncrementalSearchBarOrKeepMode)->nextMatchForSelection(view(), KateSearchBar::SearchForward);
124void KateNormalInputMode::findSelectedBackwards()
126 searchBar(IncrementalSearchBarOrKeepMode)->nextMatchForSelection(view(), KateSearchBar::SearchBackward);
129void KateNormalInputMode::findReplace()
131 KateSearchBar *
const bar = searchBar(PowerSearchBar);
132 view()->bottomViewBar()->addBarWidget(bar);
133 view()->bottomViewBar()->showBarWidget(bar);
137void KateNormalInputMode::findNext()
139 searchBar(IncrementalSearchBarOrKeepMode)->findNext();
142void KateNormalInputMode::findPrevious()
144 searchBar(IncrementalSearchBarOrKeepMode)->findPrevious();
147void KateNormalInputMode::activateCommandLine()
156 view()->bottomViewBar()->showBarWidget(cmdLineBar());
160KateSearchBar *KateNormalInputMode::searchBar(
const SearchBarMode mode)
163 const bool wantPowerMode = (mode == PowerSearchBar);
167 m_searchBar.reset(
new KateSearchBar(wantPowerMode, view(), KateViewConfig::global()));
171 else if (mode != IncrementalSearchBarOrKeepMode) {
173 m_searchBar->enterPowerMode();
175 m_searchBar->enterIncrementalMode();
179 return m_searchBar.get();
182KateCommandLineBar *KateNormalInputMode::cmdLineBar()
185 m_cmdLine.reset(
new KateCommandLineBar(view(), view()->bottomViewBar()));
186 view()->bottomViewBar()->addBarWidget(m_cmdLine.get());
189 return m_cmdLine.get();
192void KateNormalInputMode::updateRendererConfig()
195 m_searchBar->updateHighlightColors();
199bool KateNormalInputMode::keyPress(
QKeyEvent *e)
204 if (view()->isCompletionActive()) {
206 if (KateViewConfig::global()->tabCompletion()) {
209 const auto direction = key ==
Qt::Key_Tab ? W::Down : W::Up;
210 view()->completionWidget()->tabCompletion(direction);
218 if (isEnter && !view()->config()->value(KateViewConfig::EnterToInsertCompletion).toBool()) {
222 if (view()->completionWidget()->execute()) {
232bool KateNormalInputMode::blinkCaret()
const
237KTextEditor::caretStyles KateNormalInputMode::caretStyle()
const
239 return view()->isOverwriteMode() ? KTextEditor::caretStyles::Block : KTextEditor::caretStyles::Line;
242void KateNormalInputMode::toggleInsert()
244 view()->toggleInsert();
247void KateNormalInputMode::launchInteractiveCommand(
const QString &command)
249 KateCommandLineBar *cmdLine = cmdLineBar();
250 view()->bottomViewBar()->showBarWidget(cmdLine);
251 cmdLine->setText(command,
false);
254QString KateNormalInputMode::bookmarkLabel(
int)
const
constexpr int line() const noexcept
Retrieve the line on which this cursor is situated.
KateDocumentConfig * config()
Configuration.
An object representing a section of text, from one Cursor to another.
constexpr Cursor end() const noexcept
Get the end position of this range.
constexpr Cursor start() const noexcept
Get the start position of this range.
ViewMode
Possible view modes These correspond to various modes the text editor might be in.
@ NormalModeInsert
Insert mode.
@ NormalModeOverwrite
Overwrite mode.
InputMode
Possible input modes.
@ NormalInputMode
Normal Mode.
QString i18n(const char *text, const TYPE &arg...)
Qt::KeyboardModifiers modifiers() const const
QString number(double n, char format, int precision)