KTextEditor

completionrecorder.cpp
1/*
2 SPDX-FileCopyrightText: KDE Developers
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "completionrecorder.h"
8#include "katepartdebug.h"
9#include "lastchangerecorder.h"
10#include "macrorecorder.h"
11#include "vimode/definitions.h"
12#include <vimode/inputmodemanager.h>
13
14#include <QKeyEvent>
15
16using namespace KateVi;
17
18CompletionRecorder::CompletionRecorder(InputModeManager *viInputModeManager)
19 : m_viInputModeManager(viInputModeManager)
20{
21}
22
23CompletionRecorder::~CompletionRecorder() = default;
24
25void CompletionRecorder::logCompletionEvent(const Completion &completion)
26{
27 // Ctrl-space is a special code that means: if you're replaying a macro, fetch and execute
28 // the next logged completion.
29 static const QKeyEvent CompletionEvent(QKeyEvent::KeyPress, Qt::Key_Space, CONTROL_MODIFIER, QStringLiteral(" "));
30
31 if (m_viInputModeManager->macroRecorder()->isRecording()) {
32 m_viInputModeManager->macroRecorder()->record(CompletionEvent);
33 m_currentMacroCompletionsLog.append(completion);
34 }
35
36 m_viInputModeManager->lastChangeRecorder()->record(CompletionEvent);
37 m_currentChangeCompletionsLog.append(completion);
38}
39
40void CompletionRecorder::start()
41{
42 m_currentMacroCompletionsLog.clear();
43}
44
45CompletionList CompletionRecorder::stop()
46{
47 return m_currentMacroCompletionsLog;
48}
49
50void CompletionRecorder::clearCurrentChangeCompletionsLog()
51{
52 m_currentChangeCompletionsLog.clear();
53}
54
55CompletionList CompletionRecorder::currentChangeCompletionsLog()
56{
57 return m_currentChangeCompletionsLog;
58}
void append(QList< T > &&value)
void clear()
Key_Space
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.