void JuliaEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) { using namespace TextEditor; using namespace TextEditor::Internal; BaseTextEditorWidget::setFontSettings(fs); if (baseTextDocument()->syntaxHighlighter()) { Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter()); highlighter->configureFormat(Highlighter::VisualWhitespace, fs.toTextCharFormat(C_VISUAL_WHITESPACE)); highlighter->configureFormat(Highlighter::Keyword, fs.toTextCharFormat(C_KEYWORD)); highlighter->configureFormat(Highlighter::DataType, fs.toTextCharFormat(C_TYPE)); highlighter->configureFormat(Highlighter::Comment, fs.toTextCharFormat(C_COMMENT)); // Using C_NUMBER for all kinds of numbers. highlighter->configureFormat(Highlighter::Decimal, fs.toTextCharFormat(C_NUMBER)); highlighter->configureFormat(Highlighter::BaseN, fs.toTextCharFormat(C_NUMBER)); highlighter->configureFormat(Highlighter::Float, fs.toTextCharFormat(C_NUMBER)); // Using C_STRING for strings and chars. highlighter->configureFormat(Highlighter::Char, fs.toTextCharFormat(C_STRING)); highlighter->configureFormat(Highlighter::String, fs.toTextCharFormat(C_STRING)); highlighter->rehighlight(); } }
void GLSLTextEditorWidget::setFontSettings(const TextEditor::FontSettings &fs) { TextEditor::BaseTextEditorWidget::setFontSettings(fs); Highlighter *highlighter = qobject_cast<Highlighter*>(baseTextDocument()->syntaxHighlighter()); if (!highlighter) return; /* NumberFormat, StringFormat, TypeFormat, KeywordFormat, LabelFormat, CommentFormat, VisualWhitespace, */ static QVector<TextEditor::TextStyle> categories; if (categories.isEmpty()) { categories << TextEditor::C_NUMBER << TextEditor::C_STRING << TextEditor::C_TYPE << TextEditor::C_KEYWORD << TextEditor::C_OPERATOR << TextEditor::C_PREPROCESSOR << TextEditor::C_LABEL << TextEditor::C_COMMENT << TextEditor::C_DOXYGEN_COMMENT << TextEditor::C_DOXYGEN_TAG << TextEditor::C_VISUAL_WHITESPACE << TextEditor::C_REMOVED_LINE; } highlighter->setFormats(fs.toTextCharFormats(categories)); highlighter->rehighlight(); }
QTextEdit * Editor::addEditor(const QString & name, const Effect * effect, int i) { SourceEdit * textEdit = new SourceEdit(this); this->addTab(textEdit, name); textEdit->setFont(m_font); textEdit->setLineWrapMode(QTextEdit::NoWrap); textEdit->setTabStopWidth(28); textEdit->setAcceptRichText(false); QTextDocument * textDocument = textEdit->document(); Highlighter * hl = new Highlighter(textDocument); hl->setRules(effect->factory()->highlightingRules()); hl->setMultiLineCommentStart(effect->factory()->multiLineCommentStart()); hl->setMultiLineCommentEnd(effect->factory()->multiLineCommentEnd()); textEdit->setPlainText(effect->getInput(i)); textDocument->setModified(false); connect(textEdit, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(textEdit, SIGNAL(cursorPositionChanged()), this, SIGNAL(cursorPositionChanged())); connect(textDocument, SIGNAL(modificationChanged(bool)), this, SIGNAL(modifiedChanged(bool))); if (count() == 1) { emit onCurrentChanged(currentIndex()); } return textEdit; }
void KateHighlighter::setTabSize(SyntaxHighlighter *h, int tabSize) { Highlighter *highlighter = static_cast<Highlighter*>(h); if (!highlighter) { return; } highlighter->setTabSize(tabSize); }
void QmlJSSnippetProvider::decorateEditor(TextEditor::SnippetEditorWidget *editor) const { Highlighter *highlighter = new Highlighter; const TextEditor::FontSettings &fs = TextEditor::TextEditorSettings::instance()->fontSettings(); highlighter->setFormats(fs.toTextCharFormats(QmlJSTextEditorWidget::highlighterFormatCategories())); editor->setSyntaxHighlighter(highlighter); editor->setIndenter(new Indenter); editor->setAutoCompleter(new AutoCompleter); }
void PlainTextEditorWidget::setTabSettings(const TextEditor::TabSettings &ts) { BaseTextEditorWidget::setTabSettings(ts); if (baseTextDocument()->syntaxHighlighter()) { Highlighter *highlighter = static_cast<Highlighter *>(baseTextDocument()->syntaxHighlighter()); highlighter->setTabSettings(ts); } }
TextEditor::SyntaxHighlighter *KateHighlighter::create(QTextDocument *doc, const QString &mimeType) { Highlighter *h = new Highlighter(doc); //reset(h); QString id = Manager2::instance()->definitionIdByMimeType(mimeType); QSharedPointer<HighlightDefinition> def = Manager2::instance()->definition(id); if (def) { h->setDefaultContext(def->initialContext()); } return h; }
void PlainTextEditorWidget::configure(const Core::MimeType &mimeType) { Highlighter *highlighter = new Highlighter(); baseTextDocument()->setSyntaxHighlighter(highlighter); setCodeFoldingSupported(false); if (!mimeType.isNull()) { m_isMissingSyntaxDefinition = true; const QString &type = mimeType.type(); setMimeType(type); QString definitionId = Manager::instance()->definitionIdByMimeType(type); if (definitionId.isEmpty()) definitionId = findDefinitionId(mimeType, true); if (!definitionId.isEmpty()) { m_isMissingSyntaxDefinition = false; const QSharedPointer<HighlightDefinition> &definition = Manager::instance()->definition(definitionId); if (!definition.isNull() && definition->isValid()) { highlighter->setDefaultContext(definition->initialContext()); m_commentDefinition.setAfterWhiteSpaces(definition->isCommentAfterWhiteSpaces()); m_commentDefinition.setSingleLine(definition->singleLineComment()); m_commentDefinition.setMultiLineStart(definition->multiLineCommentStart()); m_commentDefinition.setMultiLineEnd(definition->multiLineCommentEnd()); setCodeFoldingSupported(true); } } else if (editorDocument()) { const QString &fileName = editorDocument()->fileName(); if (TextEditorSettings::instance()->highlighterSettings().isIgnoredFilePattern(fileName)) m_isMissingSyntaxDefinition = false; } } setFontSettings(TextEditorSettings::instance()->fontSettings()); emit configured(editor()); }
void Timepix3VolcanoEdge::Execute(){ // Ask the store gate if the previous algorithm (BlobsFinder --> reponsible for clustering) // sent any objects to the StoreGate. Int_t lastObject = GetNumberOfObjectsWithAuthor("BlobsFinder"); if(lastObject == 0) return; // If so, get the pointer to the last object. BlobsFinder, as it comes out of the box, sends // a single object containing all clusters. m_aB = (AllBlobsContainer *) GetObjectFromAuthor("BlobsFinder", lastObject-1); // AllBlobsContainer is a box full of Blobs(Clusters). Now we can iterate over all clusters inside. vector<blob> blobsVector = m_aB->GetBlobsVector(); Log << MSG::INFO << "Number of blobs from clustering = " << (Int_t) blobsVector.size() << endreq; vector<blob>::iterator blobsItr = blobsVector.begin(); //allBlobs.begin(); cluster cl; for( ; blobsItr != blobsVector.end() ; blobsItr++) { cl = *blobsItr; // Limit all this to clusters with a minimum size. // Note that m_minNPixels can be configured through the Viewer // so you can reprocess and check results online. if(cl.bP.nPixels < m_minNPixels) continue; if(cl.bP.nInnerPixels < m_minInner) continue; // Finish selection. Signal the cluster Highlighter * highLight = new Highlighter(cl.bP.geoCenter_x, cl.bP.geoCenter_y, "arrow", this); highLight->SetLineColor(kBlack); highLight->SetLineWidth(1); FillValuesForDisplay(highLight, cl); PullToStoreGateAccess(highLight, MPXDefs::DO_NOT_SERIALIZE_ME); // If the cluster passes the minimum requirements loop over the // the constituents of the cluster --> ClusterDescription list< pair < pair<int, int>, int > > cl_des = cl.GetClusterDescription(); list< pair < pair<int, int>, int > >::iterator i = cl_des.begin(); // Store the cluster TOT for output m_clusterTOT.push_back( cl.bP.clusterTOT ); double calib_edep = 0.0, clusterEdep = 0.; int tot = 0; pair<int, int> pix; for ( ; i != cl_des.end() ; i++) { // pixel coordinates and tot pix = (*i).first; tot = (*i).second; // Use calibration to obtain E = Surrogate(TOT) for this pixel calib_edep = CalculateAndGetCalibEnergy(pix, tot); // Fill the TOT Vs. Energy map m_TOTEnergyMap[tot].push_back( calib_edep ); // Calculate the energy of the cluster clusterEdep += calib_edep; } // Store the cluster Energy calculated in the previous loop m_clusterEnergy.push_back( clusterEdep ); } // Fill the output tree of this algorithm getMyTree()->Fill(); // WARNING ! don't forget to clean up your variables for the next TTree::Fill call m_clusterEnergy.clear(); m_clusterTOT.clear(); }
void ReportViewWidget::setupQry() { m_currentQry = QString(); QWidget *cornerWidget = new QWidget(this); QHBoxLayout *layout = new QHBoxLayout; layout->setContentsMargins(0, 0, 0, 1); layout->setSpacing(1); cornerWidget->setLayout(layout); m_actnQryButton = new QToolButton(this); m_actnQryButton->setMinimumSize(20, 20); m_actnQryButton->setIcon(QIcon(":/pic/kchart_chrt.png")); m_actnQryButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_actnQryButton->setPopupMode(QToolButton::InstantPopup); layout->addWidget(m_actnQryButton); QMenu *menu = new QMenu(this); menu->addAction(ui.actionRunQryFromText); menu->addAction(ui.actionSaveQry); menu->addAction(ui.actionCloseQry); menu->addSeparator(); menu->addAction(ui.actionCSV); m_actnQryButton->setMenu(menu); ui.tabWidget->setCornerWidget(cornerWidget, Qt::TopRightCorner); m_qryModel = new SqlQueryModel(this); QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setSourceModel(m_qryModel); ui.resultView->setModel(proxy); m_dirModel = new QDirModel(QStringList() /*<< "*.qry"*/, QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Name, this); m_dirModel->setReadOnly(false); FileIconProvider *fIp= new FileIconProvider; m_dirModel->setIconProvider(fIp); // if (!QDir(QDir::home().path() + "/CuteFarm/Reports").exists()) { // QDir(QDir::home().path()).mkdir("CuteFarm"); // QDir(QDir::home().path() + "/CuteFarm").mkdir("Reports"); // } // // qDebug() << QDir::home().path(); ui.dirView->setModel(m_dirModel); ui.dirView->setRootIndex(m_dirModel->index(CuteFarm::reportsDirPath())); ui.dirView->setAcceptDrops(true); ui.dirView->hideColumn(1); ui.dirView->hideColumn(2); ui.dirView->hideColumn(3); m_treeWidgetQryStrgFileActns << ui.actionEditQry << ui.actionDeleteQry << ui.actionRunQryFromFile << ui.actionNewFolder; m_treeWidgetQryStrgDirActns << ui.actionNewFolder << ui.actionDeleteFolder; ui.dirView->resizeColumnToContents(0); ui.dirView->header()->setResizeMode(0, QHeaderView::ResizeToContents); ui.resultView->setAlternatingRowColors(SettingsDialog::alternatingRowColors()); ui.resultView->horizontalHeader()->setResizeMode(SettingsDialog::resizeMode()); ui.resultView->setShowGrid(SettingsDialog::showGrid()); // resultView->horizontalHeader()->setStretchLastSection(true); Highlighter *highlighter = new Highlighter(0, true); highlighter->setDocument(ui.textEditSql->document()); Highlighter *schemaHighlighter = new Highlighter(0, false); schemaHighlighter->setDocument(ui.textEditSchema->document()); }
void KateHighlighter::setColorStyle(TextEditor::SyntaxHighlighter *h,const ColorStyleScheme *scheme) { Highlighter *highlighter = static_cast<Highlighter*>(h); if (!highlighter) { return; } QTextCharFormat fmt_vw; if (!setTextCharStyle(fmt_vw,"VisualWhitespace",scheme)) { fmt_vw.setForeground(Qt::lightGray); } highlighter->configureFormat(Highlighter::VisualWhitespace, fmt_vw); QTextCharFormat fmt_kw; if (!setTextCharStyle(fmt_kw,"Keyword",scheme)) { fmt_kw.setForeground(Qt::darkBlue); fmt_kw.setFontWeight(QFont::Bold); } highlighter->configureFormat(Highlighter::Keyword, fmt_kw); QTextCharFormat fmt_dt; if (!setTextCharStyle(fmt_dt,"DataType",scheme)) { fmt_dt.setForeground(Qt::darkBlue);//Qt::darkMagenta); } highlighter->configureFormat(Highlighter::DataType, fmt_dt); QTextCharFormat fmt_fn; if (!setTextCharStyle(fmt_fn,"Function",scheme)) { fmt_fn.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::Function,fmt_fn); QTextCharFormat fmt_cmn; if (!setTextCharStyle(fmt_cmn,"Comment",scheme)) { fmt_cmn.setForeground(Qt::darkGreen); } highlighter->configureFormat(Highlighter::Comment, fmt_cmn); QTextCharFormat fmt_dd; if (!setTextCharStyle(fmt_dd,"Decimal",scheme)) { fmt_dd.setForeground(Qt::darkMagenta); } // Using C_NUMBER for all kinds of numbers. highlighter->configureFormat(Highlighter::Decimal, fmt_dd); QTextCharFormat fmt_db; if (!setTextCharStyle(fmt_db,"BaseN",scheme)) { fmt_db.setForeground(Qt::darkMagenta); } highlighter->configureFormat(Highlighter::BaseN, fmt_db); QTextCharFormat fmt_df; if (!setTextCharStyle(fmt_df,"Float",scheme)) { fmt_df.setForeground(Qt::darkMagenta); } highlighter->configureFormat(Highlighter::Float, fmt_df); QTextCharFormat fmt_ch; if (!setTextCharStyle(fmt_ch,"Char",scheme)) { fmt_ch.setForeground(Qt::darkGreen); } // Using C_STRING for strings and chars. highlighter->configureFormat(Highlighter::Char, fmt_ch); QTextCharFormat fmt_cs; if (!setTextCharStyle(fmt_cs,"String",scheme)) { fmt_cs.setForeground(Qt::darkGreen); } highlighter->configureFormat(Highlighter::String, fmt_cs); QTextCharFormat fmt_rm; if (!setTextCharStyle(fmt_rm,"RegionMarker",scheme)) { fmt_rm.setForeground(Qt::yellow); } highlighter->configureFormat(Highlighter::RegionMarker,fmt_rm); QTextCharFormat fmt_alert; if (!setTextCharStyle(fmt_alert,"Alert",scheme)) { fmt_alert.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Alert,fmt_alert); QTextCharFormat fmt_err; if (!setTextCharStyle(fmt_err,"Error",scheme)) { fmt_err.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Error,fmt_err); QTextCharFormat fmt_sym; if (!setTextCharStyle(fmt_sym,"Symbol",scheme)) { fmt_sym.setForeground(Qt::red); } highlighter->configureFormat(Highlighter::Symbol,fmt_sym); QTextCharFormat fmt_bf; if (!setTextCharStyle(fmt_bf,"BuiltinFunc",scheme)) { fmt_bf.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::BuiltinFunc,fmt_bf); QTextCharFormat fmt_pre; if (!setTextCharStyle(fmt_pre,"Predeclared",scheme)) { fmt_pre.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::Predeclared,fmt_pre); QTextCharFormat fmt_fc; if (!setTextCharStyle(fmt_fc,"FuncDecl",scheme)) { fmt_fc.setForeground(Qt::blue); } highlighter->configureFormat(Highlighter::FuncDecl,fmt_fc); highlighter->rehighlight(); }
void tst_SyntaxHighlighter::sanityCheck() { delete new Highlighter; // make sure null parent doesn't crash { TextEdit edit; SyntaxHighlighter *s = new Highlighter(&edit); QVERIFY(s->textEdit() == &edit); QCOMPARE(edit.syntaxHighlighters().size(), 1); QVERIFY(edit.syntaxHighlighters().first() == s); QVERIFY(edit.syntaxHighlighter() == s); delete s; QCOMPARE(edit.syntaxHighlighters().size(), 0); } { QPointer<SyntaxHighlighter> ptr; TextEdit *textEdit = new TextEdit; ptr = new Highlighter(textEdit); delete textEdit; QVERIFY(!ptr); } { QPointer<SyntaxHighlighter> ptr; TextEdit *textEdit = new TextEdit; ptr = new Highlighter; textEdit->addSyntaxHighlighter(ptr); delete textEdit; QVERIFY(ptr); delete ptr; } { TextEdit edit; QPointer<SyntaxHighlighter> s = new Highlighter; edit.setSyntaxHighlighter(s); QCOMPARE(edit.syntaxHighlighters().size(), 1); QVERIFY(edit.syntaxHighlighters().first() == s); QVERIFY(edit.syntaxHighlighter() == s); edit.setSyntaxHighlighter(s); QCOMPARE(edit.syntaxHighlighters().size(), 1); QVERIFY(edit.syntaxHighlighters().first() == s); QVERIFY(edit.syntaxHighlighter() == s); SyntaxHighlighter *s2 = new Highlighter; edit.setSyntaxHighlighter(s2); QCOMPARE(edit.syntaxHighlighters().size(), 1); QVERIFY(edit.syntaxHighlighters().first() == s2); QVERIFY(edit.syntaxHighlighter() == s2); QVERIFY(!s->textEdit()); } { TextEdit edit; QList<SyntaxHighlighter*> list; for (int i=0; i<1024; ++i) { list.append(new Highlighter(&edit)); } QCOMPARE(list, edit.syntaxHighlighters()); } { TextEdit edit; Highlighter hl; hl.setTextEdit(&edit); } }