void toLexerOracleAPIs::updateAutoCompletionList(const QStringList &context, QStringList &list) { list << "AAA" << "BBB"; QsciScintilla* editor = lexer()->editor(); if (editor == NULL) return; QmlJS::PersistentTrie::Trie trie; QString text = editor->text(); int len = editor->length(); char* bufferText = new char[len+1]; editor->SendScintilla(QsciScintillaBase::SCI_GETTEXT, len, bufferText); bufferText[len] = '\0'; std::auto_ptr <SQLLexer::Lexer> lexer = LexerFactTwoParmSing::Instance().create("OracleGuiLexer", "", "toCustomLexer"); lexer->setStatement(bufferText, len); SQLLexer::Lexer::token_const_iterator it = lexer->begin(); while (it != lexer->end()) { SQLLexer::Token::TokenType t = it->getTokenType(); if (it->getTokenType() == SQLLexer::Token::L_IDENTIFIER) trie.insert(it->getText()); it++; } list << trie.complete(context.last()); }
void SciDoc::applySettings() { // LOGGER; setShowLineNumbers(EditorSettings::get(EditorSettings::ShowLineNumbers)); QFont font = EditorSettings::font(); LexerStorage::instance()->updateLexers(font); QColor textColor = EditorSettings::get(EditorSettings::DefaultFontColor); QColor bgColor = EditorSettings::get(EditorSettings::DefaultBgColor); QsciScintilla* edits[] = { int_->edit1_, int_->edit2_, NULL }; for (int i = 0; edits[i] != NULL; ++i ) { QsciScintilla* edit = edits[i]; // indents //edit->setTabWidth(EditorSettings::get(EditorSettings::TabWidth)); //edit->setIndentationsUseTabs(EditorSettings::get(EditorSettings::UseTabs)); edit->setBackspaceUnindents(EditorSettings::get(EditorSettings::BackspaceUnindents)); // colors edit->setIndentationGuides(QSciSettings::get(QSciSettings::ShowIndents)); edit->setIndentationGuidesForegroundColor(QSciSettings::get(QSciSettings::IndentsColor)); edit->setIndentationGuidesBackgroundColor(bgColor); QColor selBgColor = EditorSettings::get(EditorSettings::SelectionBgColor); edit->setSelectionBackgroundColor(selBgColor); if ( selBgColor.red() + selBgColor.green() + selBgColor.blue() < 3 * 255 / 2) edit->setSelectionForegroundColor(QColor(255, 255, 255)); else edit->setSelectionForegroundColor(QColor(0, 0, 0)); if ( QSciSettings::get(QSciSettings::HighlightMatchingBrace) ) { edit->setMatchedBraceBackgroundColor(QSciSettings::get(QSciSettings::MatchingBraceBgColor)); edit->setMatchedBraceForegroundColor(QSciSettings::get(QSciSettings::MatchingBraceFgColor)); } else { edit->setMatchedBraceBackgroundColor(bgColor); edit->setMatchedBraceForegroundColor(textColor); } edit->setCaretLineBackgroundColor(LexerStorage::instance()->curLineColor(syntax())); edit->setMarkerBackgroundColor(QSciSettings::get(QSciSettings::MarkersColor)); edit->setCaretForegroundColor(textColor); QColor marginsBgColor = QSciSettings::get(QSciSettings::MarginsBgColor); edit->setMarginsBackgroundColor(marginsBgColor); edit->setMarginsForegroundColor(textColor); edit->setFoldMarginColors(marginsBgColor, bgColor); // markers edit->markerDefine(markerPixmap(QSciSettings::get(QSciSettings::MarkersColor), marginsBgColor), -1); edit->setCaretLineVisible(QSciSettings::get(QSciSettings::HighlightCurLine)); // line length indicator int lInd = EditorSettings::get(EditorSettings::LineLengthIndicator); if ( lInd > 0 ) { edit->setEdgeMode(QsciScintilla::EdgeLine); edit->setEdgeColumn(lInd); } else { edit->setEdgeMode(QsciScintilla::EdgeNone); } edit->SendScintilla(QsciScintillaBase::SCI_SETWHITESPACEFORE, 1, QSciSettings::get(QSciSettings::WhiteSpaceColor)); // selection /* QColor selBgColor = TextDocSettings::selectionBgColor(); edit->setSelectionBackgroundColor(selBgColor); if ( selBgColor.red() + selBgColor.green() + selBgColor.blue() < 3 * 255 / 2) edit->setSelectionForegroundColor(QColor(255, 255, 255)); else edit->setSelectionForegroundColor(QColor(0, 0, 0)); */ // autocompletion edit->setAutoCompletionThreshold(AutocompleteSettings::get(AutocompleteSettings::Threshold)); edit->setAutoCompletionReplaceWord(AutocompleteSettings::get(AutocompleteSettings::ReplaceWord)); // edit->setAutoCompletionCaseSensitivity(AutocompleteSettings::get(AutocompleteSettings::CaseSensitive)); if ( AutocompleteSettings::get(AutocompleteSettings::UseDocument) ) { if ( AutocompleteSettings::get(AutocompleteSettings::UseApis) ) edit->setAutoCompletionSource(QsciScintilla::AcsAll); else edit->setAutoCompletionSource(QsciScintilla::AcsDocument); } else { if ( AutocompleteSettings::get(AutocompleteSettings::UseApis) ) edit->setAutoCompletionSource(QsciScintilla::AcsAPIs); else edit->setAutoCompletionSource(QsciScintilla::AcsNone); } edit->setAutoCompletionCaseSensitivity(false); } }