2024-04-12 14:36:37 +02:00
|
|
|
// 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>
|
2024-07-10 12:47:23 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
2024-04-12 14:36:37 +02:00
|
|
|
|
|
|
|
|
namespace Lua {
|
|
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
void addHookModule()
|
|
|
|
|
{
|
2024-05-07 13:59:46 +02:00
|
|
|
LuaEngine::registerHook("editors.documentOpened", [](const sol::protected_function &func) {
|
|
|
|
|
QObject::connect(
|
|
|
|
|
Core::EditorManager::instance(),
|
|
|
|
|
&Core::EditorManager::documentOpened,
|
|
|
|
|
[func](Core::IDocument *document) {
|
2024-07-16 16:07:57 +02:00
|
|
|
Utils::expected_str<void> res = LuaEngine::void_safe_call(func, document);
|
|
|
|
|
QTC_CHECK_EXPECTED(res);
|
2024-05-07 13:59:46 +02:00
|
|
|
});
|
2024-04-12 14:36:37 +02:00
|
|
|
});
|
2024-07-10 12:47:23 +02:00
|
|
|
|
2024-05-07 13:59:46 +02:00
|
|
|
LuaEngine::registerHook("editors.documentClosed", [](const sol::protected_function &func) {
|
|
|
|
|
QObject::connect(
|
|
|
|
|
Core::EditorManager::instance(),
|
|
|
|
|
&Core::EditorManager::documentClosed,
|
|
|
|
|
[func](Core::IDocument *document) {
|
2024-07-16 16:07:57 +02:00
|
|
|
Utils::expected_str<void> res = LuaEngine::void_safe_call(func, document);
|
|
|
|
|
QTC_CHECK_EXPECTED(res);
|
2024-05-07 13:59:46 +02:00
|
|
|
});
|
2024-04-12 14:36:37 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
} // namespace Lua
|