| 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 | #include "activemode.h" |
| 8 | #include "emulatedcommandbar.h" |
| 9 | #include "matchhighlighter.h" |
| 10 | |
| 11 | #include <vimode/inputmodemanager.h> |
| 12 | #include <vimode/modes/visualvimode.h> |
| 13 | |
| 14 | #include "kateview.h" |
| 15 | |
| 16 | using namespace KateVi; |
| 17 | |
| 18 | CompletionStartParams ActiveMode::completionInvoked(Completer::CompletionInvocation invocationType) |
| 19 | { |
| 20 | Q_UNUSED(invocationType); |
| 21 | return CompletionStartParams(); |
| 22 | } |
| 23 | |
| 24 | void ActiveMode::setViInputModeManager(InputModeManager *viInputModeManager) |
| 25 | { |
| 26 | m_viInputModeManager = viInputModeManager; |
| 27 | } |
| 28 | |
| 29 | ActiveMode::~ActiveMode() = default; |
| 30 | |
| 31 | void ActiveMode::hideAllWidgetsExcept(QWidget *widgetToKeepVisible) |
| 32 | { |
| 33 | m_emulatedCommandBar->hideAllWidgetsExcept(widgetToKeepVisible); |
| 34 | } |
| 35 | |
| 36 | void ActiveMode::updateMatchHighlight(KTextEditor::Range matchRange) |
| 37 | { |
| 38 | m_matchHighligher->updateMatchHighlight(matchRange); |
| 39 | } |
| 40 | |
| 41 | void ActiveMode::close(bool wasAborted) |
| 42 | { |
| 43 | m_emulatedCommandBar->m_wasAborted = wasAborted; |
| 44 | m_emulatedCommandBar->hideMe(); |
| 45 | } |
| 46 | |
| 47 | void ActiveMode::closeWithStatusMessage(const QString &exitStatusMessage) |
| 48 | { |
| 49 | m_emulatedCommandBar->closeWithStatusMessage(exitStatusMessage); |
| 50 | } |
| 51 | |
| 52 | void ActiveMode::startCompletion(const CompletionStartParams &completionStartParams) |
| 53 | { |
| 54 | m_emulatedCommandBar->m_completer->startCompletion(completionStartParams); |
| 55 | } |
| 56 | |
| 57 | void ActiveMode::moveCursorTo(const KTextEditor::Cursor cursorPos) |
| 58 | { |
| 59 | m_view->setCursorPosition(cursorPos); |
| 60 | if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualMode || m_viInputModeManager->getCurrentViMode() == ViMode::VisualLineMode) { |
| 61 | m_viInputModeManager->getViVisualMode()->goToPos(c: cursorPos); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | EmulatedCommandBar *ActiveMode::emulatedCommandBar() |
| 66 | { |
| 67 | return m_emulatedCommandBar; |
| 68 | } |
| 69 | |
| 70 | KTextEditor::ViewPrivate *ActiveMode::view() |
| 71 | { |
| 72 | return m_view; |
| 73 | } |
| 74 | |
| 75 | InputModeManager *ActiveMode::viInputModeManager() |
| 76 | { |
| 77 | return m_viInputModeManager; |
| 78 | } |
| 79 |
