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();
|
||||
};
|
||||
|
||||
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>(
|
||||
"MultiTextCursor",
|
||||
sol::no_constructor,
|
||||
|
@@ -10364,6 +10364,11 @@ BaseTextEditor *BaseTextEditor::currentTextEditor()
|
||||
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 *> ret;
|
||||
|
@@ -127,6 +127,7 @@ public:
|
||||
virtual void finalizeInitialization() {}
|
||||
|
||||
static BaseTextEditor *currentTextEditor();
|
||||
static QList<BaseTextEditor *> openedTextEditors();
|
||||
static QVector<BaseTextEditor *> textEditorsForDocument(TextDocument *textDocument);
|
||||
|
||||
TextEditorWidget *editorWidget() const;
|
||||
|
Reference in New Issue
Block a user