feat(editor): basic autocomplete
This commit is contained in:
parent
5e605a9692
commit
882a215b36
1 changed files with 20 additions and 8 deletions
|
@ -108,13 +108,14 @@ ScriptDocument::ScriptDocument(std::shared_ptr<Script> script, QWidget* parent):
|
||||||
dynamic_cast<MainWindow*>(window())->closeScriptDocument(script);
|
dynamic_cast<MainWindow*>(window())->closeScriptDocument(script);
|
||||||
});
|
});
|
||||||
|
|
||||||
// QFrame* frame = new QFrame;
|
QFrame* frame = new QFrame;
|
||||||
// QVBoxLayout* frameLayout = new QVBoxLayout;
|
QVBoxLayout* frameLayout = new QVBoxLayout;
|
||||||
// frame->setLayout(frameLayout);
|
frameLayout->setMargin(0);
|
||||||
scintilla = new QsciScintilla;
|
frame->setLayout(frameLayout);
|
||||||
// frameLayout->addWidget(scintilla);
|
scintilla = new QsciScintilla(this);
|
||||||
// setWidget(frame);
|
|
||||||
setWidget(scintilla);
|
frameLayout->addWidget(scintilla);
|
||||||
|
setWidget(frame);
|
||||||
|
|
||||||
// https://forum.qt.io/post/803690
|
// https://forum.qt.io/post/803690
|
||||||
QFont findFont("<NONE>");
|
QFont findFont("<NONE>");
|
||||||
|
@ -146,6 +147,12 @@ ScriptDocument::ScriptDocument(std::shared_ptr<Script> script, QWidget* parent):
|
||||||
lexer->setPaper(palette().light().color());
|
lexer->setPaper(palette().light().color());
|
||||||
QsciAPIs* api = makeApis(lexer);
|
QsciAPIs* api = makeApis(lexer);
|
||||||
lexer->setAPIs(api);
|
lexer->setAPIs(api);
|
||||||
|
scintilla->setAutoCompletionSource(QsciScintilla::AcsAPIs);
|
||||||
|
scintilla->setAutoCompletionThreshold(1);
|
||||||
|
scintilla->setAutoCompletionCaseSensitivity(false);
|
||||||
|
scintilla->setAutoCompletionReplaceWord(false);
|
||||||
|
scintilla->setCallTipsVisible(-1);
|
||||||
|
scintilla->setCallTipsPosition(QsciScintilla::CallTipsBelowText);
|
||||||
|
|
||||||
// Set color scheme
|
// Set color scheme
|
||||||
// https://stackoverflow.com/a/26318796/16255372
|
// https://stackoverflow.com/a/26318796/16255372
|
||||||
|
@ -167,8 +174,13 @@ ScriptDocument::~ScriptDocument() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QsciAPIs* makeApis(QsciLexer* lexer) {
|
QsciAPIs* makeApis(QsciLexer* lexer) {
|
||||||
|
|
||||||
QsciAPIs* apis = new QsciAPIs(lexer);
|
QsciAPIs* apis = new QsciAPIs(lexer);
|
||||||
|
|
||||||
|
apis->add("workspace");
|
||||||
|
apis->add("game");
|
||||||
|
apis->add("wait(seconds: number)\n\nPauses the current thread for the specified number of seconds");
|
||||||
|
|
||||||
|
apis->prepare();
|
||||||
|
|
||||||
return apis;
|
return apis;
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue