void LuaEditor::initLexer() { lexer = new QsciLexerLua; lexer->setFoldCompact(false); lexer->setColor(QColor(128, 128, 255), 5); lexer->setColor(QColor(0, 220, 0), 1); lexer->setColor(QColor(0, 220, 0), 2); lexer->setColor(QColor(Qt::red), 6); lexer->setColor(QColor(Qt::red), 8); lexer->setColor(QColor(255, 128, 0), 13); lexer->setColor(QColor(51, 102, 255), 15); lexer->setColor(QColor(72, 61, 139), 10); lexer->setFont(QFont("Courier New", 11, QFont::Bold)); QSettings settings(ORGNAME, APPNAME); settings.beginGroup("QtLuaPad"); bool autoComp = settings.value("autocompletion").toBool(); QString funcFile = settings.value("funcfile").toString().toLatin1(); settings.endGroup(); if(autoComp) { setAutoCompletionSource(QsciScintilla::AcsAll); setAutoCompletionCaseSensitivity(false); setAutoCompletionFillupsEnabled(true); setAutoCompletionThreshold(2); setAutoCompletionShowSingle(true); QsciAPIs *apis = new QsciAPIs(lexer); xmlDocPtr doc = xmlParseFile(funcFile.toLatin1()); if(!doc) { QMessageBox::critical(NULL, "Unable to load keywords!", tr("Could not load keywords file. No such file or directory."), QMessageBox::Ok, QMessageBox::NoButton); return; } xmlNodePtr root = xmlDocGetRootElement(doc); if (xmlStrcmp(root->name, (const xmlChar*)"functions")) { QMessageBox::critical(NULL, "Error", tr("Malformed functions file.")); return; } for (xmlNodePtr p = root->children; p; p = p->next) { if(p->type != XML_ELEMENT_NODE) continue; if(xmlStrcmp(p->name, (const xmlChar*)"function")) continue; QString func = QString((const char*)p->children->content); apis->add(func); } apis->prepare(); lexer->setAPIs(apis); } }
SqlEditorWidget::SqlEditorWidget(QWidget * parent) : QsciScintilla(parent), m_searchText(""), m_searchIndicator(9) // see QsciScintilla docs { m_prefs = Preferences::instance(); setMarginLineNumbers(0, true); setBraceMatching(SloppyBraceMatch); setAutoIndent(true); QsciLexerSQL * lexer = new QsciLexerSQL(this); QsciAPIs * api = new QsciAPIs(lexer); if (!api->load(":/api/sqlite.api")) qDebug("api is not loaded"); else { api->prepare(); lexer->setAPIs(api); } setAutoCompletionSource(QsciScintilla::AcsAll); setAutoCompletionCaseSensitivity(false); setAutoCompletionReplaceWord(true); setCaretLineVisible(m_prefs->activeHighlighting()); setCaretLineBackgroundColor(m_prefs->activeHighlightColor()); setUtf8(true); setFolding(QsciScintilla::BoxedFoldStyle); lexer->setFoldComments(true); lexer->setFoldCompact(false); setLexer(lexer); // search all occurrences // allow indicator painting *under* the text (but it makes editor slower a bit...) // It paints a colored box under the text for all occurrences of m_searchText. SendScintilla(QsciScintilla::SCI_SETTWOPHASEDRAW, 1); SendScintilla(QsciScintilla::SCI_INDICSETSTYLE, m_searchIndicator, QsciScintilla::INDIC_ROUNDBOX); // TODO/FIXME: make it configurable SendScintilla(QsciScintilla::SCI_INDICSETFORE, m_searchIndicator, QColor(255, 230, 90, 100)); SendScintilla(QsciScintilla::SCI_INDICSETUNDER, m_searchIndicator, 1); // end of search all occurrences connect(this, SIGNAL(linesChanged()), this, SLOT(linesChanged())); connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(cursorPositionChanged(int, int))); setCursorPosition(0, 0); linesChanged(); prefsChanged(); }
QgsCodeEditorSQL::QgsCodeEditorSQL( QWidget *parent ) : QgsCodeEditor( parent ) { if ( !parent ) { setTitle( tr( "SQL Editor" ) ); } setMarginVisible( false ); setFoldingVisible( true ); setAutoCompletionCaseSensitivity( false ); setSciLexerSQL(); }
QgsCodeEditorExpression::QgsCodeEditorExpression( QWidget *parent ) : QgsCodeEditor( parent ) { if ( !parent ) { setTitle( tr( "Expression Editor" ) ); } setMarginVisible( false ); setFoldingVisible( true ); setAutoCompletionCaseSensitivity( false ); initializeLexer(); }
FastoScintilla::FastoScintilla(QWidget* parent) : QsciScintilla(parent), lineNumberMarginWidth_(0), showAutoCompletion_(false) { setAutoIndent(true); setIndentationsUseTabs(false); setIndentationWidth(indentationWidth); setUtf8(true); setMarginWidth(1, 0); setCaretForegroundColor(caretForegroundColor); setMatchedBraceForegroundColor(matchedBraceForegroundColor); setMatchedBraceBackgroundColor(matchedBraceBackgroundColor); setSelectionBackgroundColor(selectionBackgroundColor); setSelectionForegroundColor(selectionForegroundColor); setContentsMargins(0, 0, 0, 0); setViewportMargins(3, 3, 3, 3); setMarginLineNumbers(0, true); // Margins colors // line numbers margin setMarginsBackgroundColor(marginsBackgroundColor); setMarginsForegroundColor(marginsForegroundColor); SendScintilla(QsciScintilla::SCI_SETHSCROLLBAR, 0); setWrapMode(QsciScintilla::WrapNone); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); VERIFY(connect(this, &FastoScintilla::linesChanged, this, &FastoScintilla::updateLineNumbersMarginWidth)); setAutoCompletionThreshold(1); setAutoCompletionCaseSensitivity(false); setAutoCompletionSource(QsciScintilla::AcsNone); }
/** * Initializes the lexer. * @param script * The script file. */ void SingleDocument::initLexer(QString script) { (void)script; if(lexer() == 0) { setLexer(new QsciLexerJavaScript(this)); QsciAPIs* apis = new QsciAPIs(lexer()); (void)apis; setAutoCompletionSource(QsciScintilla::AcsAPIs); setAutoCompletionCaseSensitivity(true); setAutoCompletionThreshold(3); setAutoIndent(true); setIndentationWidth(4); setTabWidth(4); setMarginLineNumbers(0,true); setMarginType(0, QsciScintilla::NumberMargin); setMarginsForegroundColor(QColor(128, 128, 128)); } }
SonicPiScintilla::SonicPiScintilla(SonicPiLexer *lexer, SonicPiTheme *theme) : QsciScintilla() { this->theme = theme; standardCommands()->clearKeys(); standardCommands()->clearAlternateKeys(); QString skey; QSettings settings("sonic-pi.net", "Key bindings"); #if defined(Q_OS_MAC) int SPi_CTRL = Qt::META; int SPi_META = Qt::CTRL; #else int SPi_CTRL = Qt::CTRL; int SPi_META = Qt::ALT; #endif // basic navigation addKeyBinding(settings, QsciCommand::PageDown, Qt::Key_PageDown); addKeyBinding(settings, QsciCommand::PageUp, Qt::Key_PageUp); addKeyBinding(settings, QsciCommand::LineDown, Qt::Key_N | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::LineDown, Qt::Key_Down); addKeyBinding(settings, QsciCommand::LineDownExtend, Qt::Key_Down | Qt::SHIFT); addKeyBinding(settings, QsciCommand::LineUp, Qt::Key_P | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::LineUp, Qt::Key_Up); addKeyBinding(settings, QsciCommand::LineUpExtend, Qt::Key_Up | Qt::SHIFT); addKeyBinding(settings, QsciCommand::CharRight, Qt::Key_F | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::CharRight, Qt::Key_Right); addKeyBinding(settings, QsciCommand::CharRightExtend, Qt::Key_Right | Qt::SHIFT); addKeyBinding(settings, QsciCommand::WordRight, Qt::Key_F | SPi_META); addOtherKeyBinding(settings, QsciCommand::WordRight, Qt::Key_Right | SPi_CTRL); addKeyBinding(settings, QsciCommand::WordRightExtend, Qt::Key_Right | SPi_CTRL | Qt::SHIFT); addKeyBinding(settings, QsciCommand::CharLeft, Qt::Key_B | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::CharLeft, Qt::Key_Left); addKeyBinding(settings, QsciCommand::CharLeftExtend, Qt::Key_Left | Qt::SHIFT); addKeyBinding(settings, QsciCommand::WordLeft, Qt::Key_B | SPi_META); addOtherKeyBinding(settings, QsciCommand::WordLeft, Qt::Key_Left | SPi_CTRL); addKeyBinding(settings, QsciCommand::WordLeftExtend, Qt::Key_Left | SPi_CTRL | Qt::SHIFT); addKeyBinding(settings, QsciCommand::Delete, Qt::Key_D | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::Delete, Qt::Key_Delete); addKeyBinding(settings, QsciCommand::DeleteBack, Qt::Key_H | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::DeleteBack, Qt::Key_Backspace); addKeyBinding(settings, QsciCommand::Home, Qt::Key_A | SPi_CTRL); addKeyBinding(settings, QsciCommand::VCHome, Qt::Key_Home); addKeyBinding(settings, QsciCommand::VCHomeExtend, Qt::Key_Home | Qt::SHIFT); addKeyBinding(settings, QsciCommand::DocumentStart, Qt::Key_Home | SPi_CTRL); addKeyBinding(settings, QsciCommand::DocumentStartExtend, Qt::Key_Home | SPi_CTRL | Qt::SHIFT); addKeyBinding(settings, QsciCommand::LineEnd, Qt::Key_E | SPi_CTRL); addOtherKeyBinding(settings, QsciCommand::LineEnd, Qt::Key_End); addKeyBinding(settings, QsciCommand::LineEndExtend, Qt::Key_End | Qt::SHIFT); addKeyBinding(settings, QsciCommand::DocumentEnd, Qt::Key_End | SPi_CTRL); addKeyBinding(settings, QsciCommand::DocumentEndExtend, Qt::Key_End | SPi_CTRL | Qt::SHIFT); addKeyBinding(settings, QsciCommand::Delete, Qt::Key_D | SPi_CTRL); addKeyBinding(settings, QsciCommand::VerticalCentreCaret, Qt::Key_L | SPi_CTRL); // tab return addKeyBinding(settings, QsciCommand::Newline, Qt::Key_Return); addKeyBinding(settings, QsciCommand::Backtab, Qt::Key_Tab | Qt::SHIFT); // copy paste addKeyBinding(settings, QsciCommand::SelectionCopy, Qt::Key_C | SPi_META); addOtherKeyBinding(settings, QsciCommand::SelectionCopy, Qt::Key_C | SPi_CTRL); addKeyBinding(settings, QsciCommand::SelectionCut, Qt::Key_X | SPi_META); addOtherKeyBinding(settings, QsciCommand::SelectionCut, Qt::Key_X | SPi_CTRL); addKeyBinding(settings, QsciCommand::Paste, Qt::Key_V | SPi_META); addOtherKeyBinding(settings, QsciCommand::Paste, Qt::Key_Y | SPi_CTRL); addKeyBinding(settings, QsciCommand::Undo, Qt::Key_Z | SPi_META); addOtherKeyBinding(settings, QsciCommand::Undo, Qt::Key_Z | SPi_CTRL); addKeyBinding(settings, QsciCommand::Redo, Qt::Key_Z | Qt::SHIFT | SPi_META); addOtherKeyBinding(settings, QsciCommand::Redo, Qt::Key_Z | Qt::SHIFT | SPi_CTRL); addKeyBinding(settings, QsciCommand::SelectAll, Qt::Key_A | SPi_META); // delete word left and right addKeyBinding(settings, QsciCommand::DeleteWordLeft, Qt::Key_Backslash | SPi_META); addKeyBinding(settings, QsciCommand::DeleteWordLeft, Qt::Key_Backspace | SPi_META); addKeyBinding(settings, QsciCommand::DeleteWordRight, Qt::Key_D | SPi_META); standardCommands()->readSettings(settings); this->setMatchedBraceBackgroundColor(theme->color("MatchedBraceBackground")); this->setMatchedBraceForegroundColor(theme->color("MatchedBraceForeground")); setIndentationWidth(2); setIndentationGuides(true); setIndentationGuidesForegroundColor(theme->color("IndentationGuidesForeground")); setBraceMatching( SonicPiScintilla::SloppyBraceMatch); //TODO: add preference toggle for this: //this->setFolding(SonicPiScintilla::CircledTreeFoldStyle, 2); setCaretLineVisible(true); setCaretLineBackgroundColor(theme->color("CaretLineBackground")); setFoldMarginColors(theme->color("FoldMarginForeground"),theme->color("FoldMarginForeground")); setMarginLineNumbers(0, true); setMarginsBackgroundColor(theme->color("MarginBackground")); setMarginsForegroundColor(theme->color("MarginForeground")); setMarginsFont(QFont("Menlo", 15, -1, true)); setUtf8(true); setText("#loading..."); setLexer((QsciLexer *)lexer); markerDefine(RightArrow, 8); setMarkerBackgroundColor("deeppink", 8); setAutoCompletionThreshold(1); setAutoCompletionSource(SonicPiScintilla::AcsAPIs); setAutoCompletionCaseSensitivity(false); setSelectionBackgroundColor(theme->color("SelectionBackground")); setSelectionForegroundColor(theme->color("SelectionForeground")); setCaretWidth(5); setCaretForegroundColor(theme->color("CaretForeground")); setEolMode(EolUnix); SendScintilla(SCI_SETWORDCHARS, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:_?!"); }
int QComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 24) qt_static_metacall(this, _c, _id, _a); _id -= 24; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = isEditable(); break; case 1: *reinterpret_cast< int*>(_v) = count(); break; case 2: *reinterpret_cast< QString*>(_v) = currentText(); break; case 3: *reinterpret_cast< int*>(_v) = currentIndex(); break; case 4: *reinterpret_cast< int*>(_v) = maxVisibleItems(); break; case 5: *reinterpret_cast< int*>(_v) = maxCount(); break; case 6: *reinterpret_cast< InsertPolicy*>(_v) = insertPolicy(); break; case 7: *reinterpret_cast< SizeAdjustPolicy*>(_v) = sizeAdjustPolicy(); break; case 8: *reinterpret_cast< int*>(_v) = minimumContentsLength(); break; case 9: *reinterpret_cast< QSize*>(_v) = iconSize(); break; case 10: *reinterpret_cast< bool*>(_v) = autoCompletion(); break; case 11: *reinterpret_cast< Qt::CaseSensitivity*>(_v) = autoCompletionCaseSensitivity(); break; case 12: *reinterpret_cast< bool*>(_v) = duplicatesEnabled(); break; case 13: *reinterpret_cast< bool*>(_v) = hasFrame(); break; case 14: *reinterpret_cast< int*>(_v) = modelColumn(); break; } _id -= 15; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setEditable(*reinterpret_cast< bool*>(_v)); break; case 3: setCurrentIndex(*reinterpret_cast< int*>(_v)); break; case 4: setMaxVisibleItems(*reinterpret_cast< int*>(_v)); break; case 5: setMaxCount(*reinterpret_cast< int*>(_v)); break; case 6: setInsertPolicy(*reinterpret_cast< InsertPolicy*>(_v)); break; case 7: setSizeAdjustPolicy(*reinterpret_cast< SizeAdjustPolicy*>(_v)); break; case 8: setMinimumContentsLength(*reinterpret_cast< int*>(_v)); break; case 9: setIconSize(*reinterpret_cast< QSize*>(_v)); break; case 10: setAutoCompletion(*reinterpret_cast< bool*>(_v)); break; case 11: setAutoCompletionCaseSensitivity(*reinterpret_cast< Qt::CaseSensitivity*>(_v)); break; case 12: setDuplicatesEnabled(*reinterpret_cast< bool*>(_v)); break; case 13: setFrame(*reinterpret_cast< bool*>(_v)); break; case 14: setModelColumn(*reinterpret_cast< int*>(_v)); break; } _id -= 15; } else if (_c == QMetaObject::ResetProperty) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 15; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 15; } #endif // QT_NO_PROPERTIES return _id; }