2013-01-14 23:11:10 +04:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-01-14 23:11:10 +04:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-01-14 23:11:10 +04:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-01-14 23:11:10 +04:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-03-12 12:05:32 +01:00
|
|
|
#include "pythoneditor.h"
|
2013-01-14 23:11:10 +04:00
|
|
|
#include "pythoneditorconstants.h"
|
|
|
|
|
#include "pythoneditorplugin.h"
|
2016-08-03 00:07:44 +02:00
|
|
|
#include "pythonindenter.h"
|
|
|
|
|
#include "pythonhighlighter.h"
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2014-08-20 15:05:32 +02:00
|
|
|
#include <texteditor/texteditoractionhandler.h>
|
2013-01-14 23:11:10 +04:00
|
|
|
#include <texteditor/texteditorconstants.h>
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
2014-08-20 15:05:32 +02:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2016-10-05 17:59:59 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
2014-08-20 15:05:32 +02:00
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2013-01-14 23:11:10 +04:00
|
|
|
namespace PythonEditor {
|
2013-08-23 13:41:17 +02:00
|
|
|
namespace Internal {
|
2013-01-14 23:11:10 +04:00
|
|
|
|
2014-08-20 15:05:32 +02:00
|
|
|
PythonEditorFactory::PythonEditorFactory()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::C_PYTHONEDITOR_ID);
|
2016-05-30 13:45:25 +09:00
|
|
|
setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_EDITOR_DISPLAY_NAME));
|
2016-08-03 00:07:44 +02:00
|
|
|
addMimeType(Constants::C_PY_MIMETYPE);
|
2014-08-20 15:05:32 +02:00
|
|
|
|
2014-08-22 12:14:18 +02:00
|
|
|
setEditorActionHandlers(TextEditorActionHandler::Format
|
2018-07-13 12:33:46 +02:00
|
|
|
| TextEditorActionHandler::UnCommentSelection
|
|
|
|
|
| TextEditorActionHandler::UnCollapseAll
|
|
|
|
|
| TextEditorActionHandler::FollowSymbolUnderCursor);
|
2014-08-22 12:14:18 +02:00
|
|
|
|
2016-08-03 00:07:44 +02:00
|
|
|
setDocumentCreator([] { return new TextDocument(Constants::C_PYTHONEDITOR_ID); });
|
2019-01-16 09:37:54 +01:00
|
|
|
setIndenterCreator([](QTextDocument *doc) { return new PythonIndenter(doc); });
|
2016-08-03 00:07:44 +02:00
|
|
|
setSyntaxHighlighterCreator([] { return new PythonHighlighter; });
|
2017-04-24 16:01:14 +02:00
|
|
|
setCommentDefinition(Utils::CommentDefinition::HashStyle);
|
2014-10-15 00:36:39 +02:00
|
|
|
setParenthesesMatchingEnabled(true);
|
|
|
|
|
setCodeFoldingSupported(true);
|
2013-01-14 23:11:10 +04:00
|
|
|
}
|
|
|
|
|
|
2013-08-23 13:41:17 +02:00
|
|
|
} // namespace Internal
|
2013-01-14 23:11:10 +04:00
|
|
|
} // namespace PythonEditor
|