File indexing completed on 2024-05-05 03:58:34

0001 /*
0002     SPDX-FileCopyrightText: 2013-2016 Simon St James <kdedevel@etotheipiplusone.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "activemode.h"
0008 #include "emulatedcommandbar.h"
0009 #include "matchhighlighter.h"
0010 
0011 #include <vimode/inputmodemanager.h>
0012 #include <vimode/modes/visualvimode.h>
0013 
0014 #include "kateview.h"
0015 
0016 using namespace KateVi;
0017 
0018 CompletionStartParams ActiveMode::completionInvoked(Completer::CompletionInvocation invocationType)
0019 {
0020     Q_UNUSED(invocationType);
0021     return CompletionStartParams();
0022 }
0023 
0024 void ActiveMode::setViInputModeManager(InputModeManager *viInputModeManager)
0025 {
0026     m_viInputModeManager = viInputModeManager;
0027 }
0028 
0029 ActiveMode::~ActiveMode() = default;
0030 
0031 void ActiveMode::hideAllWidgetsExcept(QWidget *widgetToKeepVisible)
0032 {
0033     m_emulatedCommandBar->hideAllWidgetsExcept(widgetToKeepVisible);
0034 }
0035 
0036 void ActiveMode::updateMatchHighlight(KTextEditor::Range matchRange)
0037 {
0038     m_matchHighligher->updateMatchHighlight(matchRange);
0039 }
0040 
0041 void ActiveMode::close(bool wasAborted)
0042 {
0043     m_emulatedCommandBar->m_wasAborted = wasAborted;
0044     m_emulatedCommandBar->hideMe();
0045 }
0046 
0047 void ActiveMode::closeWithStatusMessage(const QString &exitStatusMessage)
0048 {
0049     m_emulatedCommandBar->closeWithStatusMessage(exitStatusMessage);
0050 }
0051 
0052 void ActiveMode::startCompletion(const CompletionStartParams &completionStartParams)
0053 {
0054     m_emulatedCommandBar->m_completer->startCompletion(completionStartParams);
0055 }
0056 
0057 void ActiveMode::moveCursorTo(const KTextEditor::Cursor cursorPos)
0058 {
0059     m_view->setCursorPosition(cursorPos);
0060     if (m_viInputModeManager->getCurrentViMode() == ViMode::VisualMode || m_viInputModeManager->getCurrentViMode() == ViMode::VisualLineMode) {
0061         m_viInputModeManager->getViVisualMode()->goToPos(cursorPos);
0062     }
0063 }
0064 
0065 EmulatedCommandBar *ActiveMode::emulatedCommandBar()
0066 {
0067     return m_emulatedCommandBar;
0068 }
0069 
0070 KTextEditor::ViewPrivate *ActiveMode::view()
0071 {
0072     return m_view;
0073 }
0074 
0075 InputModeManager *ActiveMode::viInputModeManager()
0076 {
0077     return m_viInputModeManager;
0078 }