forked from qt-creator/qt-creator
Haskell: Use new setup for HaskellEditorFactory
Change-Id: I537248460291d5d649a1dc60a5f495003d76fa8b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -10,38 +10,51 @@
|
|||||||
|
|
||||||
#include <coreplugin/actionmanager/commandbutton.h>
|
#include <coreplugin/actionmanager/commandbutton.h>
|
||||||
#include <coreplugin/coreplugintr.h>
|
#include <coreplugin/coreplugintr.h>
|
||||||
|
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
|
#include <texteditor/texteditor.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
#include <texteditor/textindenter.h>
|
#include <texteditor/textindenter.h>
|
||||||
|
|
||||||
|
using namespace TextEditor;
|
||||||
|
|
||||||
namespace Haskell::Internal {
|
namespace Haskell::Internal {
|
||||||
|
|
||||||
static QWidget *createEditorWidget()
|
static QWidget *createEditorWidget()
|
||||||
{
|
{
|
||||||
auto widget = new TextEditor::TextEditorWidget;
|
auto widget = new TextEditorWidget;
|
||||||
auto ghciButton = new Core::CommandButton(Constants::A_RUN_GHCI, widget);
|
auto ghciButton = new Core::CommandButton(Constants::A_RUN_GHCI, widget);
|
||||||
ghciButton->setText(Tr::tr("GHCi"));
|
ghciButton->setText(Tr::tr("GHCi"));
|
||||||
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
|
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
|
||||||
HaskellManager::openGhci(widget->textDocument()->filePath());
|
HaskellManager::openGhci(widget->textDocument()->filePath());
|
||||||
});
|
});
|
||||||
widget->insertExtraToolBarWidget(TextEditor::TextEditorWidget::Left, ghciButton);
|
widget->insertExtraToolBarWidget(TextEditorWidget::Left, ghciButton);
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
HaskellEditorFactory::HaskellEditorFactory()
|
class HaskellEditorFactory : public TextEditorFactory
|
||||||
{
|
{
|
||||||
setId(Constants::C_HASKELLEDITOR_ID);
|
public:
|
||||||
setDisplayName(::Core::Tr::tr("Haskell Editor"));
|
HaskellEditorFactory()
|
||||||
addMimeType("text/x-haskell");
|
{
|
||||||
setEditorActionHandlers(TextEditor::TextEditorActionHandler::UnCommentSelection
|
setId(Constants::C_HASKELLEDITOR_ID);
|
||||||
| TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor);
|
setDisplayName(::Core::Tr::tr("Haskell Editor"));
|
||||||
setDocumentCreator([] { return new TextEditor::TextDocument(Constants::C_HASKELLEDITOR_ID); });
|
addMimeType("text/x-haskell");
|
||||||
setIndenterCreator([](QTextDocument *doc) { return new TextEditor::TextIndenter(doc); });
|
setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection
|
||||||
setEditorWidgetCreator(&createEditorWidget);
|
| TextEditorActionHandler::FollowSymbolUnderCursor);
|
||||||
setCommentDefinition(Utils::CommentDefinition("--", "{-", "-}"));
|
setDocumentCreator([] { return new TextDocument(Constants::C_HASKELLEDITOR_ID); });
|
||||||
setParenthesesMatchingEnabled(true);
|
setIndenterCreator([](QTextDocument *doc) { return new TextIndenter(doc); });
|
||||||
setMarksVisible(true);
|
setEditorWidgetCreator(&createEditorWidget);
|
||||||
setSyntaxHighlighterCreator([] { return new HaskellHighlighter(); });
|
setCommentDefinition(Utils::CommentDefinition("--", "{-", "-}"));
|
||||||
|
setParenthesesMatchingEnabled(true);
|
||||||
|
setMarksVisible(true);
|
||||||
|
setSyntaxHighlighterCreator([] { return new HaskellHighlighter(); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupHaskellEditor()
|
||||||
|
{
|
||||||
|
static HaskellEditorFactory theHaskellEditorFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Haskell::Internal
|
} // Haskell::Internal
|
||||||
|
|||||||
@@ -3,14 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
|
|
||||||
namespace Haskell::Internal {
|
namespace Haskell::Internal {
|
||||||
|
|
||||||
class HaskellEditorFactory : public TextEditor::TextEditorFactory
|
void setupHaskellEditor();
|
||||||
{
|
|
||||||
public:
|
|
||||||
HaskellEditorFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // Haskell::Internal
|
} // Haskell::Internal
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ namespace Haskell::Internal {
|
|||||||
class HaskellPluginPrivate
|
class HaskellPluginPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HaskellEditorFactory editorFactory;
|
|
||||||
HaskellRunConfigurationFactory runConfigFactory;
|
HaskellRunConfigurationFactory runConfigFactory;
|
||||||
ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
ProjectExplorer::SimpleTargetRunnerFactory runWorkerFactory{{Constants::C_HASKELL_RUNCONFIG_ID}};
|
||||||
};
|
};
|
||||||
@@ -59,6 +58,7 @@ private:
|
|||||||
|
|
||||||
setupHaskellStackBuildStep();
|
setupHaskellStackBuildStep();
|
||||||
setupHaskellBuildConfiguration();
|
setupHaskellBuildConfiguration();
|
||||||
|
setupHaskellEditor();
|
||||||
|
|
||||||
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
|
ProjectExplorer::ProjectManager::registerProjectType<HaskellProject>(
|
||||||
Constants::C_HASKELL_PROJECT_MIMETYPE);
|
Constants::C_HASKELL_PROJECT_MIMETYPE);
|
||||||
|
|||||||
Reference in New Issue
Block a user