forked from qt-creator/qt-creator
PythonEditor: Convert to new editor setup scheme
Change-Id: Ibf886c891bb1884d6bc3c08bfe83c4978d17b2f6 Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
@@ -27,37 +27,52 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/**
|
|
||||||
\class PyEditor::Editor implements interface Core::IEditor
|
|
||||||
This editor makes possible to edit Python source files
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pythoneditor.h"
|
#include "pythoneditor.h"
|
||||||
#include "pythoneditorconstants.h"
|
#include "pythoneditorconstants.h"
|
||||||
#include "pythoneditorplugin.h"
|
#include "pythoneditorplugin.h"
|
||||||
#include "pythoneditorwidget.h"
|
#include "tools/pythonindenter.h"
|
||||||
|
#include "tools/pythonhighlighter.h"
|
||||||
|
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
|
|
||||||
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/texteditorconstants.h>
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
#include <texteditor/basetextdocument.h>
|
||||||
|
#include <texteditor/indenter.h>
|
||||||
|
#include <texteditor/autocompleter.h>
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PythonEditor
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PythonEditor::PythonEditor()
|
PythonEditor::PythonEditor()
|
||||||
{
|
{
|
||||||
setContext(Core::Context(Constants::C_PYTHONEDITOR_ID,
|
addContext(Constants::C_PYTHONEDITOR_ID);
|
||||||
TextEditor::Constants::C_TEXTEDITOR));
|
|
||||||
setDuplicateSupported(true);
|
setDuplicateSupported(true);
|
||||||
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
setCommentStyle(Utils::CommentDefinition::HashStyle);
|
||||||
}
|
setEditorCreator([]() { return new PythonEditor; });
|
||||||
|
setWidgetCreator([]() { return new PythonEditorWidget; });
|
||||||
|
|
||||||
Core::IEditor *PythonEditor::duplicate()
|
setDocumentCreator([]() -> BaseTextDocument * {
|
||||||
{
|
auto doc = new BaseTextDocument(Constants::C_PYTHONEDITOR_ID);
|
||||||
PythonEditorWidget *widget = new PythonEditorWidget(editorWidget()->textDocumentPtr());
|
doc->setIndenter(new PythonIndenter);
|
||||||
return widget->editor();
|
new PythonHighlighter(doc);
|
||||||
|
return doc;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PythonEditor::open(QString *errorString,
|
bool PythonEditor::open(QString *errorString,
|
||||||
@@ -66,7 +81,49 @@ bool PythonEditor::open(QString *errorString,
|
|||||||
{
|
{
|
||||||
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
|
Core::MimeType mimeType = Core::MimeDatabase::findByFile(QFileInfo(fileName));
|
||||||
textDocument()->setMimeType(mimeType.type());
|
textDocument()->setMimeType(mimeType.type());
|
||||||
return TextEditor::BaseTextEditor::open(errorString, fileName, realFileName);
|
return BaseTextEditor::open(errorString, fileName, realFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PythonEditorWidget
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PythonEditorWidget::PythonEditorWidget()
|
||||||
|
{
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setCodeFoldingSupported(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseTextEditor *PythonEditorWidget::createEditor()
|
||||||
|
{
|
||||||
|
QTC_ASSERT("should not happen anymore" && false, return 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PythonEditorFactory
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
PythonEditorFactory::PythonEditorFactory()
|
||||||
|
{
|
||||||
|
setId(Constants::C_PYTHONEDITOR_ID);
|
||||||
|
setDisplayName(tr(Constants::C_EDITOR_DISPLAY_NAME));
|
||||||
|
addMimeType(QLatin1String(Constants::C_PY_MIMETYPE));
|
||||||
|
new TextEditorActionHandler(this, Constants::C_PYTHONEDITOR_ID,
|
||||||
|
TextEditorActionHandler::Format
|
||||||
|
| TextEditorActionHandler::UnCommentSelection
|
||||||
|
| TextEditorActionHandler::UnCollapseAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::IEditor *PythonEditorFactory::createEditor()
|
||||||
|
{
|
||||||
|
return new PythonEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -31,10 +31,24 @@
|
|||||||
#define PYTHONEDITOR_EDITOR_H
|
#define PYTHONEDITOR_EDITOR_H
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
|
|
||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class PythonEditorFactory : public Core::IEditorFactory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PythonEditorFactory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates and initializes new editor widget
|
||||||
|
*/
|
||||||
|
Core::IEditor *createEditor();
|
||||||
|
};
|
||||||
|
|
||||||
class PythonEditor : public TextEditor::BaseTextEditor
|
class PythonEditor : public TextEditor::BaseTextEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -42,8 +56,6 @@ class PythonEditor : public TextEditor::BaseTextEditor
|
|||||||
public:
|
public:
|
||||||
PythonEditor();
|
PythonEditor();
|
||||||
|
|
||||||
Core::IEditor *duplicate();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Opens file for editing, actual work performed by base class
|
Opens file for editing, actual work performed by base class
|
||||||
*/
|
*/
|
||||||
@@ -52,6 +64,17 @@ public:
|
|||||||
const QString &realFileName);
|
const QString &realFileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PythonEditorWidget : public TextEditor::BaseTextEditorWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
PythonEditorWidget();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TextEditor::BaseTextEditor *createEditor();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace PythonEditor
|
} // namespace PythonEditor
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,7 @@ RESOURCES += \
|
|||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
pythoneditorplugin.h \
|
pythoneditorplugin.h \
|
||||||
pythoneditorfactory.h \
|
|
||||||
pythoneditor.h \
|
pythoneditor.h \
|
||||||
pythoneditorwidget.h \
|
|
||||||
pythoneditorconstants.h \
|
pythoneditorconstants.h \
|
||||||
wizard/pythonfilewizard.h \
|
wizard/pythonfilewizard.h \
|
||||||
wizard/pythonclasswizard.h \
|
wizard/pythonclasswizard.h \
|
||||||
@@ -25,9 +23,7 @@ HEADERS += \
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
pythoneditorplugin.cpp \
|
pythoneditorplugin.cpp \
|
||||||
pythoneditorfactory.cpp \
|
|
||||||
pythoneditor.cpp \
|
pythoneditor.cpp \
|
||||||
pythoneditorwidget.cpp \
|
|
||||||
wizard/pythonfilewizard.cpp \
|
wizard/pythonfilewizard.cpp \
|
||||||
wizard/pythonclasswizarddialog.cpp \
|
wizard/pythonclasswizarddialog.cpp \
|
||||||
wizard/pythonclasswizard.cpp \
|
wizard/pythonclasswizard.cpp \
|
||||||
|
|||||||
@@ -18,10 +18,8 @@ QtcPlugin {
|
|||||||
files: [
|
files: [
|
||||||
"pythoneditor.cpp", "pythoneditor.h",
|
"pythoneditor.cpp", "pythoneditor.h",
|
||||||
"pythoneditorconstants.h",
|
"pythoneditorconstants.h",
|
||||||
"pythoneditorfactory.cpp", "pythoneditorfactory.h",
|
|
||||||
"pythoneditorplugin.cpp", "pythoneditorplugin.h",
|
"pythoneditorplugin.cpp", "pythoneditorplugin.h",
|
||||||
"pythoneditorplugin.qrc",
|
"pythoneditorplugin.qrc",
|
||||||
"pythoneditorwidget.cpp", "pythoneditorwidget.h",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,69 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, 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, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "pythoneditorfactory.h"
|
|
||||||
#include "pythoneditorconstants.h"
|
|
||||||
#include "pythoneditorwidget.h"
|
|
||||||
#include "pythoneditorplugin.h"
|
|
||||||
#include "tools/pythonindenter.h"
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
|
||||||
|
|
||||||
using namespace TextEditor;
|
|
||||||
|
|
||||||
namespace PythonEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
EditorFactory::EditorFactory(QObject *parent)
|
|
||||||
: Core::IEditorFactory(parent)
|
|
||||||
{
|
|
||||||
setId(Constants::C_PYTHONEDITOR_ID);
|
|
||||||
setDisplayName(tr(Constants::C_EDITOR_DISPLAY_NAME));
|
|
||||||
addMimeType(QLatin1String(Constants::C_PY_MIMETYPE));
|
|
||||||
new TextEditor::TextEditorActionHandler(this,
|
|
||||||
Constants::C_PYTHONEDITOR_ID,
|
|
||||||
TextEditor::TextEditorActionHandler::Format
|
|
||||||
| TextEditor::TextEditorActionHandler::UnCommentSelection
|
|
||||||
| TextEditor::TextEditorActionHandler::UnCollapseAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IEditor *EditorFactory::createEditor()
|
|
||||||
{
|
|
||||||
BaseTextDocumentPtr doc(new BaseTextDocument);
|
|
||||||
doc->setId(Constants::C_PYTHONEDITOR_ID);
|
|
||||||
doc->setIndenter(new PythonIndenter);
|
|
||||||
PythonEditorWidget *widget = new PythonEditorWidget(doc);
|
|
||||||
|
|
||||||
return widget->editor();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace PythonEditor
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, 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, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PYTHONEDITORFACTORY_H
|
|
||||||
#define PYTHONEDITORFACTORY_H
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
|
||||||
|
|
||||||
namespace PythonEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class EditorFactory : public Core::IEditorFactory
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
EditorFactory(QObject *parent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Creates and initializes new editor widget
|
|
||||||
*/
|
|
||||||
Core::IEditor *createEditor();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace PythonEditor
|
|
||||||
|
|
||||||
#endif // PYTHONEDITORFACTORY_H
|
|
||||||
@@ -28,11 +28,10 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "pythoneditorplugin.h"
|
#include "pythoneditorplugin.h"
|
||||||
|
#include "pythoneditor.h"
|
||||||
#include "pythoneditorconstants.h"
|
#include "pythoneditorconstants.h"
|
||||||
#include "wizard/pythonfilewizard.h"
|
#include "wizard/pythonfilewizard.h"
|
||||||
#include "wizard/pythonclasswizard.h"
|
#include "wizard/pythonclasswizard.h"
|
||||||
#include "pythoneditorwidget.h"
|
|
||||||
#include "pythoneditorfactory.h"
|
|
||||||
#include "tools/pythonhighlighter.h"
|
#include "tools/pythonhighlighter.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -186,7 +185,7 @@ static const char *const LIST_OF_PYTHON_BUILTINS[] = {
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PythonEditorPlugin *PythonEditorPlugin::m_instance = 0;
|
static PythonEditorPlugin *m_instance = 0;
|
||||||
|
|
||||||
/// Copies identifiers from array to QSet
|
/// Copies identifiers from array to QSet
|
||||||
static void copyIdentifiers(const char * const words[], size_t bytesCount, QSet<QString> &result)
|
static void copyIdentifiers(const char * const words[], size_t bytesCount, QSet<QString> &result)
|
||||||
@@ -197,7 +196,6 @@ static void copyIdentifiers(const char * const words[], size_t bytesCount, QSet<
|
|||||||
}
|
}
|
||||||
|
|
||||||
PythonEditorPlugin::PythonEditorPlugin()
|
PythonEditorPlugin::PythonEditorPlugin()
|
||||||
: m_factory(0)
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
copyIdentifiers(LIST_OF_PYTHON_KEYWORDS, sizeof(LIST_OF_PYTHON_KEYWORDS), m_keywords);
|
copyIdentifiers(LIST_OF_PYTHON_KEYWORDS, sizeof(LIST_OF_PYTHON_KEYWORDS), m_keywords);
|
||||||
@@ -207,7 +205,6 @@ PythonEditorPlugin::PythonEditorPlugin()
|
|||||||
|
|
||||||
PythonEditorPlugin::~PythonEditorPlugin()
|
PythonEditorPlugin::~PythonEditorPlugin()
|
||||||
{
|
{
|
||||||
removeObject(m_factory);
|
|
||||||
m_instance = 0;
|
m_instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,8 +215,7 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
|
|||||||
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(RC_PY_MIME_XML), errorMessage))
|
if (!Core::MimeDatabase::addMimeTypes(QLatin1String(RC_PY_MIME_XML), errorMessage))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_factory = new EditorFactory(this);
|
addAutoReleasedObject(new PythonEditorFactory);
|
||||||
addObject(m_factory);
|
|
||||||
|
|
||||||
// Initialize editor actions handler
|
// Initialize editor actions handler
|
||||||
// Add MIME overlay icons (these icons displayed at Project dock panel)
|
// Add MIME overlay icons (these icons displayed at Project dock panel)
|
||||||
@@ -240,23 +236,19 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonEditorPlugin::extensionsInitialized()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<QString> PythonEditorPlugin::keywords()
|
QSet<QString> PythonEditorPlugin::keywords()
|
||||||
{
|
{
|
||||||
return instance()->m_keywords;
|
return m_instance->m_keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> PythonEditorPlugin::magics()
|
QSet<QString> PythonEditorPlugin::magics()
|
||||||
{
|
{
|
||||||
return instance()->m_magics;
|
return m_instance->m_magics;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> PythonEditorPlugin::builtins()
|
QSet<QString> PythonEditorPlugin::builtins()
|
||||||
{
|
{
|
||||||
return instance()->m_builtins;
|
return m_instance->m_builtins;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -36,13 +36,6 @@
|
|||||||
namespace PythonEditor {
|
namespace PythonEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class EditorFactory;
|
|
||||||
class PythonEditorWidget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
\class PyEditor::Plugin implements ExtensionSystem::IPlugin
|
|
||||||
Singletone object - PyEditor plugin
|
|
||||||
*/
|
|
||||||
class PythonEditorPlugin : public ExtensionSystem::IPlugin
|
class PythonEditorPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -53,16 +46,13 @@ public:
|
|||||||
virtual ~PythonEditorPlugin();
|
virtual ~PythonEditorPlugin();
|
||||||
|
|
||||||
virtual bool initialize(const QStringList &arguments, QString *errorMessage);
|
virtual bool initialize(const QStringList &arguments, QString *errorMessage);
|
||||||
virtual void extensionsInitialized();
|
virtual void extensionsInitialized() {}
|
||||||
static PythonEditorPlugin *instance() { return m_instance; }
|
|
||||||
|
|
||||||
static QSet<QString> keywords();
|
static QSet<QString> keywords();
|
||||||
static QSet<QString> magics();
|
static QSet<QString> magics();
|
||||||
static QSet<QString> builtins();
|
static QSet<QString> builtins();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static PythonEditorPlugin *m_instance;
|
|
||||||
EditorFactory *m_factory;
|
|
||||||
QSet<QString> m_keywords;
|
QSet<QString> m_keywords;
|
||||||
QSet<QString> m_magics;
|
QSet<QString> m_magics;
|
||||||
QSet<QString> m_builtins;
|
QSet<QString> m_builtins;
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, 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, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
\class EditorWidget
|
|
||||||
Graphical representation and parent widget for PyEditor::Editor class.
|
|
||||||
Represents editor as plain text editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pythoneditorwidget.h"
|
|
||||||
#include "tools/pythonhighlighter.h"
|
|
||||||
#include "pythoneditor.h"
|
|
||||||
#include "pythoneditorconstants.h"
|
|
||||||
|
|
||||||
#include <texteditor/fontsettings.h>
|
|
||||||
#include <texteditor/texteditorconstants.h>
|
|
||||||
#include <texteditor/basetextdocument.h>
|
|
||||||
#include <texteditor/indenter.h>
|
|
||||||
#include <texteditor/autocompleter.h>
|
|
||||||
|
|
||||||
namespace PythonEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
PythonEditorWidget::PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc)
|
|
||||||
{
|
|
||||||
setTextDocument(doc);
|
|
||||||
setParenthesesMatchingEnabled(true);
|
|
||||||
setMarksVisible(true);
|
|
||||||
setCodeFoldingSupported(true);
|
|
||||||
|
|
||||||
new PythonHighlighter(doc.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
TextEditor::BaseTextEditor *PythonEditorWidget::createEditor()
|
|
||||||
{
|
|
||||||
return new PythonEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace PythonEditor
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** Alternatively, 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, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef PYTHONEDITORWIDGET_H
|
|
||||||
#define PYTHONEDITORWIDGET_H
|
|
||||||
|
|
||||||
#include <texteditor/basetexteditor.h>
|
|
||||||
|
|
||||||
namespace PythonEditor {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class PythonEditorWidget : public TextEditor::BaseTextEditorWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
PythonEditorWidget(TextEditor::BaseTextDocumentPtr doc);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
TextEditor::BaseTextEditor *createEditor();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace PythonEditor
|
|
||||||
|
|
||||||
#endif // PYTHONEDITORWIDGET_H
|
|
||||||
Reference in New Issue
Block a user