summaryrefslogtreecommitdiffstats
path: root/objects
diff options
context:
space:
mode:
authorNicolas Arnaud-Cormos <nicolas@kdab.com>2012-02-04 17:34:48 +0100
committerNicolas Arnaud-Cormos <nicolas@kdab.com>2012-02-04 17:34:48 +0100
commit5e6b3d3a1d10587f4b7ac74e8806aecf06d5ba30 (patch)
tree202c3856ac2a1dbc79033d5967ea168be281dc92 /objects
Initialize the Scripting plugin
Diffstat (limited to 'objects')
-rw-r--r--objects/basetexteditor.cpp416
-rw-r--r--objects/basetexteditor.h126
-rw-r--r--objects/console.cpp61
-rw-r--r--objects/console.h56
-rw-r--r--objects/editor.cpp89
-rw-r--r--objects/editor.h76
-rw-r--r--objects/editors.cpp59
-rw-r--r--objects/editors.h56
8 files changed, 939 insertions, 0 deletions
diff --git a/objects/basetexteditor.cpp b/objects/basetexteditor.cpp
new file mode 100644
index 0000000..3df3638
--- /dev/null
+++ b/objects/basetexteditor.cpp
@@ -0,0 +1,416 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "basetexteditor.h"
+
+#include <texteditor/basetexteditor.h>
+
+#include <coreplugin/messagemanager.h>
+
+#include <QTextCursor>
+
+using namespace Scripting;
+using namespace Scripting::Internal;
+
+
+BaseTextEditor::BaseTextEditor(QObject *parent) :
+ Editor(parent)
+{
+}
+
+void BaseTextEditor::copy()
+{
+ if (textEditorWidget())
+ textEditorWidget()->copy();
+}
+
+void BaseTextEditor::paste()
+{
+ if (textEditorWidget())
+ textEditorWidget()->paste();
+}
+
+void BaseTextEditor::cut()
+{
+ if (textEditorWidget())
+ textEditorWidget()->cut();
+}
+
+void BaseTextEditor::cutLine()
+{
+ if (textEditorWidget())
+ textEditorWidget()->cutLine();
+}
+
+void BaseTextEditor::copyLine()
+{
+ if (textEditorWidget())
+ textEditorWidget()->copyLine();
+}
+
+void BaseTextEditor::deleteSelection()
+{
+ if (textEditorWidget() && hasSelection())
+ textEditorWidget()->textCursor().deleteChar();
+}
+
+void BaseTextEditor::deleteLine(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->deleteLine();
+}
+
+void BaseTextEditor::deleteEndOfWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->deleteEndOfWord();
+}
+
+void BaseTextEditor::deleteEndOfWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->deleteEndOfWordCamelCase();
+}
+
+void BaseTextEditor::deleteStartOfWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->deleteStartOfWord();
+}
+
+void BaseTextEditor::deleteStartOfWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->deleteStartOfWordCamelCase();
+}
+
+void BaseTextEditor::gotoBlockStart(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoBlockStart();
+}
+
+void BaseTextEditor::gotoBlockEnd(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoBlockEnd();
+}
+
+void BaseTextEditor::gotoLineStart(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoLineStart();
+}
+
+void BaseTextEditor::gotoLineEnd(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoLineEnd();
+}
+
+void BaseTextEditor::gotoNextLine(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextLine();
+}
+
+void BaseTextEditor::gotoPreviousLine(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousLine();
+}
+
+void BaseTextEditor::gotoPreviousCharacter(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousCharacter();
+}
+
+void BaseTextEditor::gotoNextCharacter(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextCharacter();
+}
+
+void BaseTextEditor::gotoPreviousWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousWord();
+}
+
+void BaseTextEditor::gotoNextWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextWord();
+}
+
+void BaseTextEditor::gotoPreviousWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousWordCamelCase();
+}
+
+void BaseTextEditor::gotoNextWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextWordCamelCase();
+}
+
+void BaseTextEditor::clearSelection()
+{
+ if (textEditorWidget())
+ textEditorWidget()->textCursor().clearSelection();
+}
+
+bool BaseTextEditor::hasSelection()
+{
+ if (textEditorWidget())
+ return textEditorWidget()->textCursor().hasSelection();
+ return false;
+}
+
+void BaseTextEditor::selectAll()
+{
+ if (textEditorWidget())
+ textEditorWidget()->selectAll();
+}
+
+void BaseTextEditor::selectBlockStart(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoBlockStartWithSelection();
+}
+
+void BaseTextEditor::selectBlockEnd(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoBlockEndWithSelection();
+}
+
+void BaseTextEditor::selectLineStart(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoLineStartWithSelection();
+}
+
+void BaseTextEditor::selectLineEnd(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoLineEndWithSelection();
+}
+
+void BaseTextEditor::selectNextLine(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextLineWithSelection();
+}
+
+void BaseTextEditor::selectPreviousLine(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousLineWithSelection();
+}
+
+void BaseTextEditor::selectPreviousCharacter(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousCharacterWithSelection();
+}
+
+void BaseTextEditor::selectNextCharacter(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextCharacterWithSelection();
+}
+
+void BaseTextEditor::selectPreviousWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousWordWithSelection();
+}
+
+void BaseTextEditor::selectNextWord(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextWordWithSelection();
+}
+
+void BaseTextEditor::selectPreviousWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoPreviousWordCamelCaseWithSelection();
+}
+
+void BaseTextEditor::selectNextWordCamelCase(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->gotoNextWordCamelCaseWithSelection();
+}
+
+void BaseTextEditor::selectBlockUp(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->selectBlockUp();
+}
+
+void BaseTextEditor::selectBlockDown(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->selectBlockDown();
+}
+
+void BaseTextEditor::moveLineUp(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->moveLineUp();
+}
+
+void BaseTextEditor::moveLineDown(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->moveLineDown();
+}
+
+void BaseTextEditor::copyLineUp(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->copyLineUp();
+}
+
+void BaseTextEditor::copyLineDown(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->copyLineDown();
+}
+
+void BaseTextEditor::joinLines(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->joinLines();
+}
+
+void BaseTextEditor::insertLineAbove(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->insertLineAbove();
+}
+
+void BaseTextEditor::insertLineBelow(int count)
+{
+ if (textEditorWidget())
+ for(int i=0; i<count; ++i)
+ textEditorWidget()->insertLineBelow();
+}
+
+void BaseTextEditor::uppercaseSelection()
+{
+ if (textEditorWidget())
+ textEditorWidget()->uppercaseSelection();
+}
+
+void BaseTextEditor::lowercaseSelection()
+{
+ if (textEditorWidget())
+ textEditorWidget()->lowercaseSelection();
+}
+
+void BaseTextEditor::cleanWhitespace()
+{
+ if (textEditorWidget())
+ textEditorWidget()->cleanWhitespace();
+}
+
+void BaseTextEditor::insertText(const QString &text)
+{
+ if (textEditorWidget())
+ textEditorWidget()->insertPlainText(text);
+}
+
+QString BaseTextEditor::selectedText()
+{
+ if (textEditorWidget())
+ return textEditorWidget()->textCursor().selectedText();
+ return QString();
+}
+
+QString BaseTextEditor::text()
+{
+ if (textEditorWidget())
+ return textEditorWidget()->toPlainText();
+ return QString();
+}
+
+TextEditor::BaseTextEditorWidget *BaseTextEditor::textEditorWidget()
+{
+ TextEditor::BaseTextEditor *textEditor =
+ qobject_cast<TextEditor::BaseTextEditor*>(editor());
+ if (textEditor)
+ return textEditor->editorWidget();
+ return 0;
+}
diff --git a/objects/basetexteditor.h b/objects/basetexteditor.h
new file mode 100644
index 0000000..7ac9b75
--- /dev/null
+++ b/objects/basetexteditor.h
@@ -0,0 +1,126 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef TEXTEDITORWRAPPER_H
+#define TEXTEDITORWRAPPER_H
+
+#include "editor.h"
+
+
+namespace TextEditor {
+ class BaseTextEditor;
+ class BaseTextEditorWidget;
+}
+
+namespace Scripting {
+namespace Internal {
+
+class BaseTextEditor : public Editor
+{
+ Q_OBJECT
+public:
+ explicit BaseTextEditor(QObject *parent=0);
+
+public slots:
+ void copy();
+ void paste();
+ void cut();
+ void cutLine();
+ void copyLine();
+
+ void deleteSelection();
+ void deleteLine(int count=1);
+ void deleteEndOfWord(int count=1);
+ void deleteEndOfWordCamelCase(int count=1);
+ void deleteStartOfWord(int count=1);
+ void deleteStartOfWordCamelCase(int count=1);
+
+ void gotoBlockStart(int count=1);
+ void gotoBlockEnd(int count=1);
+ void gotoLineStart(int count=1);
+ void gotoLineEnd(int count=1);
+ void gotoNextLine(int count=1);
+ void gotoPreviousLine(int count=1);
+ void gotoPreviousCharacter(int count=1);
+ void gotoNextCharacter(int count=1);
+ void gotoPreviousWord(int count=1);
+ void gotoNextWord(int count=1);
+ void gotoPreviousWordCamelCase(int count=1);
+ void gotoNextWordCamelCase(int count=1);
+
+ void clearSelection();
+ bool hasSelection();
+ void selectAll();
+
+ void selectBlockStart(int count=1);
+ void selectBlockEnd(int count=1);
+ void selectLineStart(int count=1);
+ void selectLineEnd(int count=1);
+ void selectNextLine(int count=1);
+ void selectPreviousLine(int count=1);
+ void selectPreviousCharacter(int count=1);
+ void selectNextCharacter(int count=1);
+ void selectPreviousWord(int count=1);
+ void selectNextWord(int count=1);
+ void selectPreviousWordCamelCase(int count=1);
+ void selectNextWordCamelCase(int count=1);
+ void selectBlockUp(int count=1);
+ void selectBlockDown(int count=1);
+
+ void moveLineUp(int count=1);
+ void moveLineDown(int count=1);
+ void copyLineUp(int count=1);
+ void copyLineDown(int count=1);
+ void joinLines(int count=1);
+
+ void insertLineAbove(int count=1);
+ void insertLineBelow(int count=1);
+
+ void uppercaseSelection();
+ void lowercaseSelection();
+
+ void cleanWhitespace();
+
+ void insertText(const QString &text);
+ QString selectedText();
+ QString text();
+
+protected:
+ TextEditor::BaseTextEditorWidget *textEditorWidget();
+};
+
+} // namespace Internal
+} // namespace Scripting
+
+Q_DECLARE_METATYPE(Scripting::Internal::BaseTextEditor*)
+
+#endif // TEXTEDITORWRAPPER_H
diff --git a/objects/console.cpp b/objects/console.cpp
new file mode 100644
index 0000000..c9afbac
--- /dev/null
+++ b/objects/console.cpp
@@ -0,0 +1,61 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "console.h"
+
+#include <coreplugin/messagemanager.h>
+
+#include <utils/outputformat.h>
+
+using namespace Scripting;
+using namespace Scripting::Internal;
+
+
+Console::Console(QObject *parent) :
+ QObject(parent)
+{
+}
+
+void Console::error(const QString &text)
+{
+ Core::MessageManager::instance()->printToOutputPane(text, Utils::ErrorMessageFormat);
+}
+
+void Console::log(const QString &text)
+{
+ Core::MessageManager::instance()->printToOutputPane(text, false);
+}
+
+void Console::debug(const QString &text)
+{
+ Core::MessageManager::instance()->printToOutputPane(text, Utils::DebugFormat);
+}
diff --git a/objects/console.h b/objects/console.h
new file mode 100644
index 0000000..fde3e87
--- /dev/null
+++ b/objects/console.h
@@ -0,0 +1,56 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef CONSOLEINTERFACE_H
+#define CONSOLEINTERFACE_H
+
+#include <QObject>
+
+namespace Scripting {
+namespace Internal {
+
+class Console : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Console(QObject *parent = 0);
+
+public slots:
+ void error(const QString &text);
+ void log(const QString &text);
+ void debug(const QString &text);
+};
+
+} // namespace Internal
+} // namespace Scripting
+
+#endif // CONSOLEINTERFACE_H
diff --git a/objects/editor.cpp b/objects/editor.cpp
new file mode 100644
index 0000000..e3e1714
--- /dev/null
+++ b/objects/editor.cpp
@@ -0,0 +1,89 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "editor.h"
+
+#include <coreplugin/editormanager/ieditor.h>
+#include <coreplugin/ifile.h>
+
+using namespace Scripting;
+using namespace Scripting::Internal;
+
+
+Editor::Editor(QObject *parent):
+ QObject(parent),
+ m_editor(0)
+{
+}
+
+void Editor::setEditor(Core::IEditor *editor)
+{
+ m_editor = editor;
+}
+
+bool Editor::exists()
+{
+ return m_editor->widget()!=0;
+}
+
+bool Editor::save()
+{
+ QString errorString;
+ return m_editor->file()->save(&errorString);
+}
+
+int Editor::currentLine()
+{
+ return m_editor->currentLine();
+}
+
+int Editor::currentColumn()
+{
+ return m_editor->currentColumn();
+}
+
+void Editor::gotoLine(int line, int column)
+{
+ m_editor->gotoLine(line, column);
+}
+
+QString Editor::fileName()
+{
+ if (m_editor->file())
+ return m_editor->file()->fileName();
+ return QString();
+}
+
+Core::IEditor * Editor::editor()
+{
+ return m_editor;
+}
diff --git a/objects/editor.h b/objects/editor.h
new file mode 100644
index 0000000..aa3a1e2
--- /dev/null
+++ b/objects/editor.h
@@ -0,0 +1,76 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef EDITORWRAPPER_H
+#define EDITORWRAPPER_H
+
+#include <QObject>
+#include <QMetaType>
+
+namespace Core {
+class IEditor;
+}
+
+namespace Scripting {
+namespace Internal {
+
+class Editor : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Editor(QObject *parent=0);
+
+ void setEditor(Core::IEditor *editor);
+
+public slots:
+ bool exists();
+ bool save();
+
+ int currentLine();
+ int currentColumn();
+ void gotoLine(int line, int column=0);
+
+ QString fileName();
+
+protected:
+ Core::IEditor *editor();
+
+private:
+ Core::IEditor *m_editor;
+};
+
+} // namespace Internal
+} // namespace Scripting
+
+Q_DECLARE_METATYPE(Scripting::Internal::Editor*)
+
+#endif // EDITORWRAPPER_H
diff --git a/objects/editors.cpp b/objects/editors.cpp
new file mode 100644
index 0000000..4613012
--- /dev/null
+++ b/objects/editors.cpp
@@ -0,0 +1,59 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include "editors.h"
+#include "editor.h"
+#include "basetexteditor.h"
+
+#include <coreplugin/editormanager/editormanager.h>
+#include <texteditor/basetexteditor.h>
+
+using namespace Scripting;
+using namespace Scripting::Internal;
+
+Editors::Editors(QObject *parent) :
+ QObject(parent)
+{
+}
+
+Editor * Editors::current()
+{
+ Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
+ Editor *wrapper;
+
+ if (qobject_cast<TextEditor::BaseTextEditor*>(editor))
+ wrapper = new BaseTextEditor;
+ else
+ wrapper = new Editor;
+ wrapper->setEditor(editor);
+ return wrapper;
+}
diff --git a/objects/editors.h b/objects/editors.h
new file mode 100644
index 0000000..08ce30f
--- /dev/null
+++ b/objects/editors.h
@@ -0,0 +1,56 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (C) 2011 Kläralvdalens Datakonsult AB, a KDAB Group company.
+**
+** Contact: Kläralvdalens Datakonsult AB (info@kdab.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#ifndef SCRIPTING_INTERNAL_EDITORS_H
+#define SCRIPTING_INTERNAL_EDITORS_H
+
+#include <QObject>
+
+namespace Scripting {
+namespace Internal {
+
+class Editor;
+
+class Editors : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Editors(QObject *parent = 0);
+
+public slots:
+ static Editor * current();
+};
+
+} // namespace Internal
+} // namespace Scripting
+
+#endif // SCRIPTING_INTERNAL_EDITORS_H