blob: 89bf561b1f731fddab6d6fd3657db250013eec30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright (c) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "haskelleditorfactory.h"
#include "haskellconstants.h"
#include "haskellhighlighter.h"
#include "haskellmanager.h"
#include "haskelltr.h"
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreplugintr.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditor.h>
#include <texteditor/texteditoractionhandler.h>
#include <texteditor/textindenter.h>
#include <QAction>
using namespace TextEditor;
namespace Haskell::Internal {
static QWidget *createEditorWidget()
{
auto widget = new TextEditorWidget;
auto ghciButton = Core::Command::createToolButtonWithShortcutToolTip(Constants::A_RUN_GHCI);
ghciButton->defaultAction()->setIconText(Tr::tr("GHCi"));
QObject::connect(ghciButton, &QToolButton::clicked, widget, [widget] {
openGhci(widget->textDocument()->filePath());
});
widget->insertExtraToolBarWidget(TextEditorWidget::Left, ghciButton);
return widget;
}
class HaskellEditorFactory : public TextEditorFactory
{
public:
HaskellEditorFactory()
{
setId(Constants::C_HASKELLEDITOR_ID);
setDisplayName(::Core::Tr::tr("Haskell Editor"));
addMimeType("text/x-haskell");
setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection
| TextEditorActionHandler::FollowSymbolUnderCursor);
setDocumentCreator([] { return new TextDocument(Constants::C_HASKELLEDITOR_ID); });
setIndenterCreator([](QTextDocument *doc) { return new TextIndenter(doc); });
setEditorWidgetCreator(&createEditorWidget);
setCommentDefinition(Utils::CommentDefinition("--", "{-", "-}"));
setParenthesesMatchingEnabled(true);
setMarksVisible(true);
setSyntaxHighlighterCreator([] { return new HaskellHighlighter(); });
}
};
void setupHaskellEditor()
{
static HaskellEditorFactory theHaskellEditorFactory;
}
} // Haskell::Internal
|