This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vcreatoreditor.cpp
54 lines (45 loc) · 1.81 KB
/
vcreatoreditor.cpp
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
#include "vcreatoreditor.h"
#include "vcreatorhighlighter.h"
#include "vcreatorconstants.h"
#include "vcreatorindenter.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/commandbutton.h>
#include <texteditor/textdocument.h>
#include <texteditor/texteditoractionhandler.h>
namespace VCreator {
namespace Internal {
EditorFactory::EditorFactory()
{
addMimeType("application/x-vlang");
setId(Constants::C_VLANG_EDITOR_ID);
setDisplayName(
QCoreApplication::translate("OpenWith::Editors", "Vlang Editor"));
setEditorActionHandlers(TextEditor::TextEditorActionHandler::Format
| TextEditor::TextEditorActionHandler::UnCommentSelection
| TextEditor::TextEditorActionHandler::UnCollapseAll);
setDocumentCreator([] {
auto td = new TextEditor::TextDocument(Constants::C_VLANG_EDITOR_ID);
td->setMimeType("application/x-vlang");
return td;
});
setEditorWidgetCreator([]{
auto tw = new TextEditor::TextEditorWidget;
tw->setLanguageSettingsId(Constants::C_VLANGUAGE_ID);
return tw;
});
setIndenterCreator([](QTextDocument *doc) {
return new VlangIndenter(doc);
});
setSyntaxHighlighterCreator([] { return new VlangHighlighter(); });
setCommentDefinition(Utils::CommentDefinition::CppStyle);
setUseGenericHighlighter(false);
setParenthesesMatchingEnabled(true);
setCodeFoldingSupported(true);
}
void EditorFactory::decorateEditor(TextEditor::TextEditorWidget *editor)
{
editor->textDocument()->setSyntaxHighlighter(new VlangHighlighter());
editor->textDocument()->setIndenter(new VlangIndenter(editor->textDocument()->document()));
}
} // namespace Internal
} // namespace Vcreator