forked from qt-creator/qt-creator
Lua: Add possibility to get all opened editors
Change-Id: Iae68fca2ec0f42043b3e4db7de91babba60e29e0 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -224,6 +224,15 @@ void setupTextEditorModule()
|
|||||||
return BaseTextEditor::currentTextEditor();
|
return BaseTextEditor::currentTextEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
result["openedEditors"] = [lua]() mutable -> sol::table {
|
||||||
|
QList<BaseTextEditor *> editors = BaseTextEditor::openedTextEditors();
|
||||||
|
sol::table result = lua.create_table();
|
||||||
|
for (auto& editor : editors) {
|
||||||
|
result.add(TextEditorPtr(editor));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
result.new_usertype<MultiTextCursor>(
|
result.new_usertype<MultiTextCursor>(
|
||||||
"MultiTextCursor",
|
"MultiTextCursor",
|
||||||
sol::no_constructor,
|
sol::no_constructor,
|
||||||
|
@@ -10364,6 +10364,11 @@ BaseTextEditor *BaseTextEditor::currentTextEditor()
|
|||||||
return qobject_cast<BaseTextEditor *>(EditorManager::currentEditor());
|
return qobject_cast<BaseTextEditor *>(EditorManager::currentEditor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<BaseTextEditor *> BaseTextEditor::openedTextEditors()
|
||||||
|
{
|
||||||
|
return qobject_container_cast<BaseTextEditor *>(DocumentModel::editorsForOpenedDocuments());
|
||||||
|
}
|
||||||
|
|
||||||
QVector<BaseTextEditor *> BaseTextEditor::textEditorsForDocument(TextDocument *textDocument)
|
QVector<BaseTextEditor *> BaseTextEditor::textEditorsForDocument(TextDocument *textDocument)
|
||||||
{
|
{
|
||||||
QVector<BaseTextEditor *> ret;
|
QVector<BaseTextEditor *> ret;
|
||||||
|
@@ -127,6 +127,7 @@ public:
|
|||||||
virtual void finalizeInitialization() {}
|
virtual void finalizeInitialization() {}
|
||||||
|
|
||||||
static BaseTextEditor *currentTextEditor();
|
static BaseTextEditor *currentTextEditor();
|
||||||
|
static QList<BaseTextEditor *> openedTextEditors();
|
||||||
static QVector<BaseTextEditor *> textEditorsForDocument(TextDocument *textDocument);
|
static QVector<BaseTextEditor *> textEditorsForDocument(TextDocument *textDocument);
|
||||||
|
|
||||||
TextEditorWidget *editorWidget() const;
|
TextEditorWidget *editorWidget() const;
|
||||||
|
Reference in New Issue
Block a user