File indexing completed on 2024-04-21 03:58:06
0001 /* 0002 SPDX-FileCopyrightText: KDE Developers 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "completionrecorder.h" 0008 #include "katepartdebug.h" 0009 #include "lastchangerecorder.h" 0010 #include "macrorecorder.h" 0011 #include "vimode/definitions.h" 0012 #include <vimode/inputmodemanager.h> 0013 0014 #include <QKeyEvent> 0015 0016 using namespace KateVi; 0017 0018 CompletionRecorder::CompletionRecorder(InputModeManager *viInputModeManager) 0019 : m_viInputModeManager(viInputModeManager) 0020 { 0021 } 0022 0023 CompletionRecorder::~CompletionRecorder() = default; 0024 0025 void CompletionRecorder::logCompletionEvent(const Completion &completion) 0026 { 0027 // Ctrl-space is a special code that means: if you're replaying a macro, fetch and execute 0028 // the next logged completion. 0029 static const QKeyEvent CompletionEvent(QKeyEvent::KeyPress, Qt::Key_Space, CONTROL_MODIFIER, QStringLiteral(" ")); 0030 0031 if (m_viInputModeManager->macroRecorder()->isRecording()) { 0032 m_viInputModeManager->macroRecorder()->record(CompletionEvent); 0033 m_currentMacroCompletionsLog.append(completion); 0034 } 0035 0036 m_viInputModeManager->lastChangeRecorder()->record(CompletionEvent); 0037 m_currentChangeCompletionsLog.append(completion); 0038 } 0039 0040 void CompletionRecorder::start() 0041 { 0042 m_currentMacroCompletionsLog.clear(); 0043 } 0044 0045 CompletionList CompletionRecorder::stop() 0046 { 0047 return m_currentMacroCompletionsLog; 0048 } 0049 0050 void CompletionRecorder::clearCurrentChangeCompletionsLog() 0051 { 0052 m_currentChangeCompletionsLog.clear(); 0053 } 0054 0055 CompletionList CompletionRecorder::currentChangeCompletionsLog() 0056 { 0057 return m_currentChangeCompletionsLog; 0058 }