void SqlEditorWidget::prefsChanged() { QFont baseFont(m_prefs->sqlFont()); baseFont.setPointSize(m_prefs->sqlFontSize()); lexer()->setFont(baseFont); setFont(baseFont); // syntax highlighting lexer()->setColor(m_prefs->syDefaultColor(), QsciLexerSQL::Default); lexer()->setColor(m_prefs->syKeywordColor(), QsciLexerSQL::Keyword); QFont defFont(lexer()->font(QsciLexerSQL::Keyword)); defFont.setBold(true); lexer()->setFont(defFont, QsciLexerSQL::Keyword); lexer()->setColor(m_prefs->syNumberColor(), QsciLexerSQL::Number); lexer()->setColor(m_prefs->syStringColor(), QsciLexerSQL::SingleQuotedString); lexer()->setColor(m_prefs->syStringColor(), QsciLexerSQL::DoubleQuotedString); lexer()->setColor(m_prefs->syCommentColor(), QsciLexerSQL::Comment); lexer()->setColor(m_prefs->syCommentColor(), QsciLexerSQL::CommentLine); lexer()->setColor(m_prefs->syCommentColor(), QsciLexerSQL::CommentDoc); setAutoCompletionThreshold(m_prefs->codeCompletion() ? m_prefs->codeCompletionLength() : -1 ); if (m_prefs->textWidthMark()) { setEdgeColumn(m_prefs->textWidthMarkSize()); setEdgeColor(Qt::gray); setEdgeMode(QsciScintilla::EdgeLine); } else setEdgeMode(QsciScintilla::EdgeNone); setMarkerBackgroundColor(m_prefs->activeHighlighting() ? m_prefs->activeHighlightColor() : paper()); }
void QgsCodeEditorPython::setSciLexerPython() { // current line setCaretWidth( 2 ); setEdgeMode( QsciScintilla::EdgeLine ); setEdgeColumn( 80 ); setEdgeColor( QColor( "#FF0000" ) ); setWhitespaceVisibility( QsciScintilla::WsVisibleAfterIndent ); QFont font = getMonospaceFont(); QsciLexerPython* pyLexer = new QsciLexerPython(); pyLexer->setDefaultFont( font ); pyLexer->setFont( font, 1 ); // comment pyLexer->setFont( font, 3 ); // singlequotes pyLexer->setFont( font, 4 ); // doublequotes pyLexer->setFont( font, 6 ); // triplequotes pyLexer->setColor( Qt::red, 1 ); // comment color pyLexer->setColor( Qt::darkGreen, 5 ); // keyword color pyLexer->setColor( Qt::darkBlue, 15 ); // decorator color QsciAPIs* apis = new QsciAPIs( pyLexer ); // check if the file is a prepared apis file. //QString mPapFileName = QFileInfo( mAPISFilesList[0] ).fileName(); //QString isPapFile = mPapFileName.right( 3 ); //QgsDebugMsg( QString( "file extension: %1" ).arg( isPapFile ) ); if ( mAPISFilesList.isEmpty() ) { mPapFile = QgsApplication::pkgDataPath() + "/python/qsci_apis/pyqgis.pap"; apis->loadPrepared( mPapFile ); } else if ( mAPISFilesList.length() == 1 && mAPISFilesList[0].right( 3 ) == "pap" ) { if ( !QFileInfo( mAPISFilesList[0] ).exists() ) { QgsDebugMsg( QString( "The apis file %1 not found" ).arg( mAPISFilesList[0] ) ); return; } mPapFile = mAPISFilesList[0]; apis->loadPrepared( mPapFile ); } else { for ( int i = 0; i < mAPISFilesList.size(); i++ ) { if ( !QFileInfo( mAPISFilesList[i] ).exists() ) { QgsDebugMsg( QString( "The apis file %1 was not found" ).arg( mAPISFilesList[i] ) ); return; } else { apis->load( mAPISFilesList[i] ); } } apis->prepare(); pyLexer->setAPIs( apis ); } setLexer( pyLexer ); setMarginVisible( true ); setFoldingVisible( true ); }