TextEdit::TextEdit(QWidget* parent) : MdiSubWindow(parent) { setAttribute(Qt::WA_DeleteOnClose); sciScintilla_ = new QsciScintilla(this); setWidget(sciScintilla_); #ifdef Q_OS_MAC keysForMac(sciScintilla_); #endif isUntitled_ = true; // settings #ifdef Q_OS_MAC sciScintilla_->setFont(QFont("Monaco", 12)); #else sciScintilla_->setFont(QFont("Courier New", 10)); #endif sciScintilla_->setFolding(QsciScintilla::BoxedTreeFoldStyle, 3); sciScintilla_->setAutoIndent(true); sciScintilla_->setTabWidth(4); sciScintilla_->setIndentationsUseTabs(true); sciScintilla_->setIndentationGuides(true); sciScintilla_->setMarginLineNumbers(1, true); sciScintilla_->setMarginWidth(1, QString("10000")); sciScintilla_->setBraceMatching(QsciScintilla::SloppyBraceMatch); sciScintilla_->setUtf8(true); sciScintilla_->setCaretLineVisible(true); sciScintilla_->setCaretLineBackgroundColor(QColor(232, 232, 255)); sciScintilla_->setMatchedBraceBackgroundColor(QColor(232, 232, 255)); sciScintilla_->setUnmatchedBraceBackgroundColor(QColor(232, 232, 255)); connect(sciScintilla_, SIGNAL(modificationChanged(bool)), this, SLOT(onModificationChanged(bool))); connect(sciScintilla_, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(sciScintilla_, SIGNAL(textChanged()), this, SIGNAL(textChanged())); sciScintilla_->setMarginMarkerMask(1, 0); // we dont want any markers at line number margin sciScintilla_->setMarginWidth(2, 14); // margin 2 is bookmark margin sciScintilla_->markerDefine(QsciScintilla::RightTriangle, 1); sciScintilla_->setMarginMarkerMask(2, 1 << 1); sciScintilla_->setMarkerForegroundColor(QColor(255, 150, 30), 1); sciScintilla_->setMarkerBackgroundColor(QColor(255, 200, 80), 1); sciScintilla_->setEolMode(QsciScintilla::EolUnix); sciScintilla_->setAutoCompletionThreshold(2); sciScintilla_->setAutoCompletionSource(QsciScintilla::AcsAll); }
TextEdit::TextEdit(QWidget* parent) : MdiSubWindow(parent) { setAttribute(Qt::WA_DeleteOnClose); sciScintilla_ = new QsciScintilla(this); setWidget(sciScintilla_); #ifdef Q_OS_MAC keysForMac(sciScintilla_); #endif isUntitled_ = true; // settings QSettings settings; QString theme = settings.value("editorTheme").toString(); QSettings lls(theme, QSettings::IniFormat); #ifdef Q_OS_MAC sciScintilla_->setFont(QFont( lls.value("FontFamily", "Monaco").toString(), lls.value("FontSize", 12).toInt())); #else sciScintilla_->setFont(QFont( lls.value("FontFamily", "Courier New").toString(), lls.value("FontSize", 10).toInt())); #endif sciScintilla_->setFolding(QsciScintilla::BoxedTreeFoldStyle, 3); sciScintilla_->setAutoIndent(true); sciScintilla_->setTabWidth(4); sciScintilla_->setIndentationsUseTabs(true); sciScintilla_->setIndentationGuides(true); sciScintilla_->setMarginLineNumbers(1, true); sciScintilla_->setMarginWidth(1, QString("10000")); sciScintilla_->setBraceMatching(QsciScintilla::SloppyBraceMatch); sciScintilla_->setUtf8(true); sciScintilla_->setCaretLineVisible(true); sciScintilla_->setCaretForegroundColor ( lls.value("CaretForegroundColor", 0).toInt()); sciScintilla_->setCaretLineBackgroundColor( lls.value("CaretLineBackgroundColor", 15658734).toInt()); sciScintilla_->setMatchedBraceForegroundColor( lls.value("MatchedBraceForegroundColor", 0).toInt()); sciScintilla_->setMatchedBraceBackgroundColor( lls.value("MatchedBraceBackgroundColor", 15658734).toInt()); sciScintilla_->setUnmatchedBraceForegroundColor( lls.value("UnmatchedBraceForegroundColor", 0).toInt()); sciScintilla_->setUnmatchedBraceBackgroundColor( lls.value("UnmatchedBraceBackgroundColor", 10085887).toInt()); sciScintilla_->setMarginSensitivity(2, true); connect(sciScintilla_, SIGNAL(modificationChanged(bool)), this, SLOT(onModificationChanged(bool))); connect(sciScintilla_, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); connect(sciScintilla_, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(sciScintilla_, SIGNAL(marginClicked(int, int, Qt::KeyboardModifiers)), this, SLOT(setBookmark(int, int, Qt::KeyboardModifiers))); sciScintilla_->setMarginMarkerMask(1, 0); // we dont want any markers at line number margin sciScintilla_->setMarginWidth(2, 14); // margin 2 is bookmark margin sciScintilla_->markerDefine(QsciScintilla::RightTriangle, 1); sciScintilla_->setMarginMarkerMask(2, 1 << 1); sciScintilla_->setMarkerForegroundColor( lls.value("MarkerForegroundColor", 2566178).toInt(), 1); sciScintilla_->setMarkerBackgroundColor( lls.value("MarkerBackgroundColor", 5348047).toInt(), 1); sciScintilla_->setEolMode(QsciScintilla::EolUnix); sciScintilla_->setAutoCompletionThreshold(2); sciScintilla_->setAutoCompletionSource(QsciScintilla::AcsAll); sciScintilla_->setFoldMarginColors( lls.value("FoldMarginFirstColor", 16777215).toInt(), lls.value("FoldMarginSecondColor", 10066329).toInt() ); sciScintilla_->setIndentationGuidesForegroundColor(lls.value("IndentationGuidesForegroundColor", 0).toInt()); sciScintilla_->setIndentationGuidesBackgroundColor(lls.value("IndentationGuidesBackgroundColor", 8421504).toInt()); sciScintilla_->setIndicatorForegroundColor(lls.value("IndicatorForegroundColor", 0).toInt()); sciScintilla_->setIndicatorOutlineColor(lls.value("IndicatorOutlineColor", 8421504).toInt()); sciScintilla_->setMarginsForegroundColor(lls.value("MarginsForegroundColor", 2566178).toInt()); sciScintilla_->setMarginsBackgroundColor(lls.value("MarginsBackgroundColor", 15658734).toInt()); }