forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTScriptEditorManager.cpp
More file actions
49 lines (33 loc) · 1.54 KB
/
TScriptEditorManager.cpp
File metadata and controls
49 lines (33 loc) · 1.54 KB
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
#include "TScriptEditorManager.h"
#include "edbee/models/textdocument.h"
#include "edbee/views/textrenderer.h"
#include "edbee/views/texttheme.h"
#include "edbee/models/textgrammar.h"
#include "edbee/models/texteditorconfig.h"
#include <QDir>
TScriptEditorManager::TScriptEditorManager()
{
_edbee = edbee::Edbee::instance();
_edbee->autoInit();
_edbee->autoShutDownOnAppExit();
edbee::TextGrammarManager* grammarManager = _edbee->grammarManager();
_grammar = grammarManager->readGrammarFile( QDir::homePath() + "/.config/mudlet/edbee/Lua.tmLanguage" );
edbee::TextThemeManager* themeManager = _edbee->themeManager();
themeManager->readThemeFile( QDir::homePath() + "/.config/mudlet/edbee/Fluidvisionlet.tmTheme" ); // Once it's read it becomes available
_themeName = QLatin1Literal("Fluidvisionlet");
}
// Apply configuration to editorwidget
void TScriptEditorManager::applyConfigToWidget(edbee::TextEditorWidget* widget) const
{
edbee::TextEditorConfig* config = widget->config();
config->beginChanges();
config->setSmartTab( true); // I'm not fully sure what this does, but it says "Smart" so it must be good
config->setCaretBlinkRate( 200);
config->setIndentSize( 2); // 2 spaces is the Lua default
config->setFont(QFont( "Courier New", 28)); // This is just a fallback, the actual font is set later
config->setThemeName("Fluidvisionlet");
config->setCaretWidth( 1);
config->setThemeName(_themeName);
widget->textDocument()->setLanguageGrammar(_grammar);
config->endChanges();
}