forked from qt-creator/qt-creator
Change-Id: I8e3a1d66ea6125d2cc5ee9c8f8442cca0913fec6 Reviewed-by: <lie@spyro-soft.com> Reviewed-by: hjk <hjk@qt.io>
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
// Copyright (C) 2024 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#include "../luaengine.h"
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
#include <texteditor/textdocument.h>
|
|
|
|
namespace Lua {
|
|
|
|
namespace Internal {
|
|
|
|
void addHookModule()
|
|
{
|
|
LuaEngine::registerHook("editors.documentOpened", [](const sol::protected_function &func) {
|
|
QObject::connect(
|
|
Core::EditorManager::instance(),
|
|
&Core::EditorManager::documentOpened,
|
|
[func](Core::IDocument *document) {
|
|
Utils::expected_str<void> res = LuaEngine::void_safe_call(func, document);
|
|
QTC_CHECK_EXPECTED(res);
|
|
});
|
|
});
|
|
|
|
LuaEngine::registerHook("editors.documentClosed", [](const sol::protected_function &func) {
|
|
QObject::connect(
|
|
Core::EditorManager::instance(),
|
|
&Core::EditorManager::documentClosed,
|
|
[func](Core::IDocument *document) {
|
|
Utils::expected_str<void> res = LuaEngine::void_safe_call(func, document);
|
|
QTC_CHECK_EXPECTED(res);
|
|
});
|
|
});
|
|
}
|
|
|
|
} // namespace Internal
|
|
|
|
} // namespace Lua
|