void ExtendedTextEdit::toggleWrapping() { if(lineWrapMode() != QPlainTextEdit::NoWrap) setLineWrapMode(QPlainTextEdit::NoWrap); else setLineWrapMode(QPlainTextEdit::WidgetWidth); }
void PgxEditor::toggleWrap() { if(lineWrapMode() == QPlainTextEdit::WidgetWidth) setLineWrapMode(QPlainTextEdit::NoWrap); else setLineWrapMode(QPlainTextEdit::WidgetWidth); }
GenericTextEditorDocument::GenericTextEditorDocument(QWidget *parent) : QPlainTextEdit(parent), mCodec(0), mCompleter(0), mDocName(""), mFilePath(""), mTextModified(false), mFile(0), mIsOfsFile(false), mInitialDisplay(true), mCloseEvtAlreadyProcessed(false) { QSettings settings; QFont fnt = font(); fnt.setFamily("Courier New"); fnt.setPointSize(settings.value("preferences/fontSize").toUInt()); setFont(fnt); QPlainTextEdit::LineWrapMode mode; if(settings.value("preferences/lineWrapping").toBool()) mode = QPlainTextEdit::WidgetWidth; else mode = QPlainTextEdit::NoWrap; setLineWrapMode(mode); setAttribute(Qt::WA_DeleteOnClose); QFontMetrics fm(fnt); setTabStopWidth(fm.width("abcd")); mLineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(const QRect &, int)), this, SLOT(updateLineNumberArea(const QRect &, int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); }
/** * Constructor * @param title :: The title * @param parent :: The parent widget * @param flags :: Window flags */ ScriptOutputDisplay::ScriptOutputDisplay(QWidget *parent) : QTextEdit(parent), m_copy(NULL), m_clear(NULL), m_save(NULL), m_origFontSize(8), m_zoomLevel(0) { #ifdef __APPLE__ // Make all fonts 4 points bigger on the Mac because otherwise they're tiny! m_zoomLevel += 4; #endif // the control is readonly, but if you set it read only then ctrl+c for // copying does not work // this approach allows ctrl+c and disables user editing through the use of // the KeyPress handler // and disabling drag and drop // also the mouseMoveEventHandler prevents dragging out of the control // affecting the text. setReadOnly(false); this->setAcceptDrops(false); setLineWrapMode(QTextEdit::WidgetWidth); setLineWrapColumnOrWidth(105); setAutoFormatting(QTextEdit::AutoNone); // Change to fix width font so that table formatting isn't screwed up resetFont(); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &))); initActions(); }
TextEditor::TextEditor(QWidget *parent) : QPlainTextEdit(parent) { lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); QFont font("consolas",9); const int tabStop = 4; // 4 characters QFontMetrics metrics(font); setTabStopWidth(tabStop * metrics.width(' ')); setFont(font); setLineWrapMode(QPlainTextEdit::NoWrap); m_highlighter = new Highlighter(document()); m_autoUpdate = false; m_timer = new QTimer(); m_timer->setSingleShot(true); m_timer->setInterval(1000); connect(m_timer, SIGNAL(timeout()), this, SLOT(updateShader())); connect(this, SIGNAL(textChanged()), this, SLOT(resetTimer())); }
HaiQTextEdit::HaiQTextEdit(QWidget *parent) : QTextEdit(parent), num_tab_spaces(0), emit_key_only_mode(false) { setTabStopWidth(20); //pixels setFrameStyle(QFrame::NoFrame); //here's a temporary workaround to the setLineWrapMode(QTextEdit:NoWrap) bug... setLineWrapMode(QTextEdit::NoWrap); //CHECK IF THIS WORKS!! //setLineWrapMode(QTextEdit::FixedPixelWidth); //setLineWrapColumnOrWidth(2500); ////////////////s////////////////////////////////////////////////////////////////// braces_highlighting_timer.setSingleShot(true); braces_highlighting_timer.setInterval(600); connect(&braces_highlighting_timer,SIGNAL(timeout()),this,SLOT(slot_clear_braces_highlighting())); setAcceptRichText(true); grabShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Tab), Qt::ApplicationShortcut); has_temporary_marker=false; do_emit_modification_changed=true; }
void SourceViewerWidget::optionChanged(const QString &option, const QVariant &value) { if (option == QLatin1String("Interface/ShowScrollBars")) { setHorizontalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff); } else if (option == QLatin1String("SourceViewer/ShowLineNumbers")) { if (value.toBool() && !m_marginWidget) { m_marginWidget = new MarginWidget(this); m_marginWidget->show(); m_marginWidget->setGeometry(QRect(contentsRect().left(), contentsRect().top(), m_marginWidget->width(), contentsRect().height())); } else if (!value.toBool() && m_marginWidget) { m_marginWidget->deleteLater(); m_marginWidget = NULL; setViewportMargins(0, 0, 0, 0); } } else if (option == QLatin1String("SourceViewer/WrapLines")) { setLineWrapMode(value.toBool() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap); } }
PathListPlainTextEdit::PathListPlainTextEdit(QWidget *parent) : QPlainTextEdit(parent) { // No wrapping, scroll at all events setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); setLineWrapMode(QPlainTextEdit::NoWrap); }
QScriptEdit::QScriptEdit(QWidget *parent) : QPlainTextEdit(parent) { m_baseLineNumber = 1; m_executionLineNumber = -1; m_extraArea = new QScriptEditExtraArea(this); QObject::connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateExtraAreaWidth())); QObject::connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateExtraArea(QRect,int))); QObject::connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateExtraAreaWidth(); //> NeoScriptTools setTabStopWidth(24); #ifdef WIN32 QFont font("Courier New"); font.setPointSize(10); document()->setDefaultFont(font); #endif setLineWrapMode(QPlainTextEdit::NoWrap); //< NeoScriptTools #ifndef QT_NO_SYNTAXHIGHLIGHTER (void) new QScriptSyntaxHighlighter(document()); #endif }
void SourceViewerWidget::optionChanged(int identifier, const QVariant &value) { if (identifier == SettingsManager::Interface_ShowScrollBarsOption) { setHorizontalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff); } else if (identifier == SettingsManager::SourceViewer_ShowLineNumbersOption) { if (value.toBool() && !m_marginWidget) { m_marginWidget = new MarginWidget(this); m_marginWidget->show(); m_marginWidget->setGeometry(QRect(contentsRect().left(), contentsRect().top(), m_marginWidget->width(), contentsRect().height())); } else if (!value.toBool() && m_marginWidget) { m_marginWidget->deleteLater(); m_marginWidget = nullptr; setViewportMargins(0, 0, 0, 0); } } else if (identifier == SettingsManager::SourceViewer_WrapLinesOption) { setLineWrapMode(value.toBool() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap); } }
ide::Editor::Editor(QWidget* w) : QPlainTextEdit(w) { setFont(monospace_font()); setBackgroundRole(QPalette::Base); setLineWrapMode(NoWrap); // please, no line wrap. setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); setDocumentTitle(path.isEmpty() ? "*unsaved*" : path); }
void pqXmlView::openFile(QString file) { this->file = file; setPlainText(file2string(file)); new XmlSyntaxHighlighter(document()); setLineWrapMode(QTextEdit::NoWrap); }
void body_view::set_wrap(bool on) { Q_UNUSED(on); // for text parts, we'll probably need to implement wrapmode by HTML-styling the contents #ifndef TODO_WEBKIT if (on) { setWordWrapMode(QTextOption::WordWrap); setLineWrapMode(QTextEdit::WidgetWidth); } else { setLineWrapMode(QTextEdit::NoWrap); setWordWrapMode(QTextOption::NoWrap); } #endif }
Wt_TextEdit::Wt_TextEdit() { QFont font; font.setFamily("monaco"); font.setFixedPitch(true); font.setPointSize(9); setFont(font); setTabStopWidth(4 * fontMetrics().width(' ')); //setStyleSheet("QPlainTextEdit {background: #262626; color:#D4D4D4}"); setStyleSheet("QPlainTextEdit {background: #373737; color:#D4D4D4;}"); //setStyleSheet("QPlainTextEdit {background: #F2F2F2; color:#D4D4D4}"); //setStyleSheet("QPlainTextEdit {background: url('bg2.png'); color:#D4D4D4}"); setLineWrapMode(QPlainTextEdit::NoWrap); setTabChangesFocus(true); highLight = new Wt_HighLight(this->document()); //QShortcut *action = new QShortcut(QKeySequence(tr("ctrl+f")),this); //connect(action, SIGNAL(activated()), this, SLOT(wt_selectionHighLight())); //connect(this, SIGNAL(selectionChanged()), this, SLOT(wt_selectionChanged())); //Wt_HighLight *searchTextHighLight = new Wt_HighLight(this->document(), Wt_HighLight::HighLightSearchText); //searchTextHighLight->initSearchTextHighlighting(tr("include")); //this->document()->setTextWidth(100); //block().blockFormat().setLineHeight(20, QTextBlockFormat::FixedHeight); }
void LogViewer::init() { setAcceptDrops(true); setReadOnly(true); setTabWidth(4); setLineWrapMode(QPlainTextEdit::NoWrap); setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); QPalette palette; palette.setColor(QPalette::Inactive, QPalette::Highlight, palette.color(QPalette::Active, QPalette::Highlight)); palette.setColor(QPalette::Inactive, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::HighlightedText)); setPalette(palette); // Read settings. setFont(INIMANAGER()->font()); setForegroundColor(INIMANAGER()->foregroundColor()); setBackgroundColor(INIMANAGER()->backgroundColor()); setCustomBackgroundColor(INIMANAGER()->customBackgroundColor()); setCurrentLineFgColor(INIMANAGER()->currentLineFgColor()); setCurrentLineBgColor(INIMANAGER()->currentLineBgColor()); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(drawCurrentLine())); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(blockCountChanged(int))); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); // Line Number. updateLineNumberAreaWidth(0); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); // Keyword Highlighter. connect(m_keywordHighlighter, SIGNAL(modelCreated(QStandardItemModel*)), this, SLOT(modelCreated(QStandardItemModel*))); connect(m_keywordHighlighter, SIGNAL(chartLoaded(QPixmap*)), this, SLOT(chartLoaded(QPixmap*))); }
CodeEditor::CodeEditor(Config* config, QWidget* parent) : QPlainTextEdit(parent), config(config) { highlighter = new Highlighter(config, this); // тормоз extraArea = new QWidget(this); extraArea->setCursor(Qt::PointingHandCursor); extraArea->setAutoFillBackground(true); extraArea->installEventFilter(this); completer = new QCompleter(config->keywordsSorted, this); completer->setWidget(this); completer->setCompletionMode(QCompleter::PopupCompletion); completer->setWrapAround(false); setLineWrapMode(QPlainTextEdit::NoWrap); setCursorWidth(2); blockCountChanged(0); setMouseTracking(true); reconfig(); // не допускаем проваливание на последнем свернутом блоке connect(this, SIGNAL(cursorPositionChanged()), SLOT(ensureCursorVisible())); connect(this, SIGNAL(blockCountChanged(int)), SLOT(blockCountChanged(int))); connect(document(), SIGNAL(contentsChange(int, int, int)), SLOT(contentsChange(int, int, int))); connect(completer, SIGNAL(activated(const QString&)), SLOT(insertCompletion(const QString&))); connect(config, SIGNAL(reread(int)), SLOT(reconfig(int))); connect(this, SIGNAL(updateRequest(QRect, int)), extraArea, SLOT(update())); }
void GenericCodeEditor::applySettings( Settings::Manager *settings ) { settings->beginGroup("IDE/editor"); bool lineWrap = settings->value("lineWrap").toBool(); bool showWhitespace = settings->value("showWhitespace").toBool(); mInactiveFadeAlpha = settings->value("inactiveEditorFadeAlpha").toInt(); QPalette palette; settings->beginGroup("colors"); if (settings->contains("text")) { QTextCharFormat format = settings->value("text").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Base, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::Text, fg); } if (settings->contains("lineNumbers")) { // NOTE: the line number widget will inherit the palette from the editor QTextCharFormat format = settings->value("lineNumbers").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Mid, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::ButtonText, fg); } if (settings->contains("selection")) { QTextCharFormat format = settings->value("selection").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Highlight, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::HighlightedText, fg); } mCurrentLineTextFormat = settings->value("currentLine").value<QTextCharFormat>(); mSearchResultTextFormat = settings->value("searchResult").value<QTextCharFormat>(); settings->endGroup(); // colors mHighlightCurrentLine = settings->value("highlightCurrentLine").toBool(); updateCurrentLineHighlighting(); settings->endGroup(); // IDE/editor setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap ); setShowWhitespace( showWhitespace ); setPalette(palette); setActiveAppearance(hasFocus()); }
// // custom_user_field // custom_user_field::custom_user_field() { QFontMetrics m(font()) ; setFixedHeight(m.lineSpacing()*4); // 4 visible lines setMinimumWidth(50*m.width("a")); // ~70 characters setLineWrapMode(QPlainTextEdit::NoWrap); setTabChangesFocus(true); }
void OpenedFile::initialize() { setLineWrapMode(QPlainTextEdit::NoWrap); setTabChangesFocus(false); document()->setDefaultFont(QFont(DEF_FONT_INFO)); document()->setDocumentLayout(new QPlainTextDocumentLayout(document())); }
void CodeEditor::rename( const QString &path ){ _path=path; _fileType=extractExt( _path ).toLower(); QString t=';'+_fileType+';'; _txt=textFileTypes.contains( t ); _code=codeFileTypes.contains( t ); _monkey=_fileType=="monkey"; if( _txt ){ setLineWrapMode( QPlainTextEdit::WidgetWidth ); }else{ setLineWrapMode( QPlainTextEdit::NoWrap ); } }
//! Constructor ModelicaEditor::ModelicaEditor(ProjectTab *pParent) : QPlainTextEdit(pParent) { mpParentProjectTab = pParent; setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setTabStopWidth(Helper::tabWidth); setObjectName("ModelicaEditor"); document()->setDocumentMargin(2); setLineWrapMode(QPlainTextEdit::NoWrap); // depending on the project tab readonly state set the text view readonly state setReadOnly(mpParentProjectTab->isReadOnly()); connect(this, SIGNAL(focusOut()), mpParentProjectTab, SLOT(modelicaEditorTextChanged())); connect(this, SIGNAL(textChanged()), SLOT(hasChanged())); mpFindWidget = new QWidget; mpFindWidget->setContentsMargins(0, 0, 0, 0); mpFindWidget->hide(); mpSearchLabelImage = new QLabel; mpSearchLabelImage->setPixmap(QPixmap(":/Resources/icons/search.png")); mpSearchLabel = new QLabel(Helper::search); mpSearchTextBox = new QLineEdit; connect(mpSearchTextBox, SIGNAL(textChanged(QString)), SLOT(updateButtons())); connect(mpSearchTextBox, SIGNAL(returnPressed()), SLOT(findNextText())); mpPreviuosButton = new QToolButton; mpPreviuosButton->setAutoRaise(true); mpPreviuosButton->setText(tr("Previous")); mpPreviuosButton->setIcon(QIcon(":/Resources/icons/previous.png")); mpPreviuosButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(mpPreviuosButton, SIGNAL(clicked()), SLOT(findPreviuosText())); mpNextButton = new QToolButton; mpNextButton->setAutoRaise(true); mpNextButton->setText(tr("Next")); mpNextButton->setIcon(QIcon(":/Resources/icons/next.png")); mpNextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(mpNextButton, SIGNAL(clicked()), SLOT(findNextText())); mpMatchCaseCheckBox = new QCheckBox(tr("Match case")); mpMatchWholeWordCheckBox = new QCheckBox(tr("Match whole word")); mpCloseButton = new QToolButton; mpCloseButton->setAutoRaise(true); mpCloseButton->setIcon(QIcon(":/Resources/icons/exit.png")); connect(mpCloseButton, SIGNAL(clicked()), SLOT(hideFindWidget())); mpLineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); // make previous and next buttons disabled for first time updateButtons(); }
//--------------------------------------------------------------------------- GUI_Main_XML::GUI_Main_XML(Core* _C, QWidget* parent) : QTextEdit(parent) { //Internal C=_C; //Configuration setLineWrapMode(QTextEdit::NoWrap); setReadOnly(true); }
Console::Console(QWidget *parent) : QPlainTextEdit(parent), userPrompt(QString(">> ")), locked(false), historySkip(false) { historyUp.clear(); historyDown.clear(); setLineWrapMode(NoWrap); insertPlainText(userPrompt); }
XMLTextEdit::XMLTextEdit(QWidget *parent) : QTextEdit(parent) { setViewportMargins(50, 0, 0, 0); highlight = new XmlHighlighter(document()); setLineWrapMode ( QTextEdit::NoWrap ); setAcceptRichText ( false ); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update())); connect(this, SIGNAL(textChanged()), this, SLOT(update())); }
ScriptEdit::ScriptEdit(ScriptingEnv *env, QWidget *parent, QString name) : QTextEdit(parent, name), scripted(env), d_error(false), d_changing_fmt(false) { myScript = scriptEnv->newScript("", this, name); connect(myScript, SIGNAL(error(const QString &, const QString &, int)), this, SLOT(insertErrorMsg(const QString &))); connect(myScript, SIGNAL(print(const QString &)), this, SLOT(scriptPrint(const QString &))); setLineWrapMode(NoWrap); setTextFormat(Qt::PlainText); setAcceptRichText(false); setFamily("Monospace"); new SyntaxHighlighter(document()); d_fmt_default.setBackground(palette().brush(QPalette::Base)); d_fmt_success.setBackground(QBrush(QColor(128, 255, 128))); d_fmt_failure.setBackground(QBrush(QColor(255, 128, 128))); printCursor = textCursor(); actionExecute = new QAction(tr("E&xecute"), this); actionExecute->setShortcut(tr("Ctrl+J")); connect(actionExecute, SIGNAL(activated()), this, SLOT(execute())); actionExecuteAll = new QAction(tr("Execute &All"), this); actionExecuteAll->setShortcut(tr("Ctrl+Shift+J")); connect(actionExecuteAll, SIGNAL(activated()), this, SLOT(executeAll())); actionEval = new QAction(tr("&Evaluate Expression"), this); actionEval->setShortcut(tr("Ctrl+Return")); connect(actionEval, SIGNAL(activated()), this, SLOT(evaluate())); actionPrint = new QAction(IconLoader::load("edit-print", IconLoader::LightDark), tr("&Print"), this); connect(actionPrint, SIGNAL(activated()), this, SLOT(print())); actionImport = new QAction(tr("&Import"), this); connect(actionImport, SIGNAL(activated()), this, SLOT(importASCII())); actionExport = new QAction(tr("&Export"), this); connect(actionExport, SIGNAL(activated()), this, SLOT(exportASCII())); functionsMenu = new QMenu(this); Q_CHECK_PTR(functionsMenu); connect(functionsMenu, SIGNAL(triggered(QAction *)), this, SLOT(insertFunction(QAction *))); connect(document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(handleContentsChange(int, int, int))); }
ScriptEdit::ScriptEdit(ScriptEngine *scriptEngine, QWidget *parent) : QTextEdit(parent) { document()->setDefaultFont(QFont("Courier", 11, -1, false)); setTabStopWidth(32); setLineWrapMode(QTextEdit::NoWrap); m.syntaxHighlighter = new SyntaxHighlighter(document()); m.scriptEngine = scriptEngine; m.suggesting = false; }
KConsole::KConsole(QWidget *_parent) : inherited(_parent) , pty(0) , notifier(0) , fd(-1) { setReadOnly(true); setLineWrapMode(NoWrap); if (!openConsole()) append(i18n("*** Cannot connect to console log ***")); }
void GenericCodeEditor::applySettings( Settings::Manager *settings ) { settings->beginGroup("IDE/editor"); bool lineWrap = settings->value("lineWrap").toBool(); bool showWhitespace = settings->value("showWhitespace").toBool(); bool showLinenumber = settings->value("showLinenumber").toBool(); mInactiveFadeAlpha = settings->value("inactiveEditorFadeAlpha").toInt(); QPalette palette; const QTextCharFormat *format = &settings->getThemeVal("text"); QBrush bg = format->background(); QBrush fg = format->foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Base, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::Text, fg); // NOTE: the line number widget will inherit the palette from the editor format = &settings->getThemeVal("lineNumbers"); mLineIndicator->setFont(format->font()); bg = format->background(); fg = format->foreground(); palette.setBrush(QPalette::Mid, bg.style() != Qt::NoBrush ? bg : palette.base()); palette.setBrush(QPalette::ButtonText, fg.style() != Qt::NoBrush ? fg : palette.base()); format = &settings->getThemeVal("selection"); bg = format->background(); fg = format->foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Highlight, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::HighlightedText, fg); mCurrentLineTextFormat = settings->getThemeVal("currentLine"); mSearchResultTextFormat = settings->getThemeVal("searchResult"); mHighlightCurrentLine = settings->value("highlightCurrentLine").toBool(); updateCurrentLineHighlighting(); settings->endGroup(); // IDE/editor setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap ); setShowWhitespace( showWhitespace ); setShowLinenumber( showLinenumber ); mLineIndicator->setLineCount(blockCount()); setPalette(palette); setActiveAppearance(hasFocus()); }
QSAEditor::QSAEditor(QWidget *parent) : QTextEdit(parent), qsInterp(0) { setLineWrapMode(NoWrap); QSyntaxHighlighter *hl = new QSASyntaxHighlighter(this); hl->setDocument(document()); matcher = new ParenMatcher; connect(this, SIGNAL(cursorPositionChanged()), matcher, SLOT(matchFromSender())); // #### add completion entries from highlighter readSettings(); }
void GenericCodeEditor::applySettings( Settings::Manager *settings ) { settings->beginGroup("IDE/editor"); bool lineWrap = settings->value("lineWrap").toBool(); QPalette palette; settings->beginGroup("colors"); if (settings->contains("text")) { QTextCharFormat format = settings->value("text").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Base, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::Text, fg); } if (settings->contains("lineNumbers")) { // NOTE: the line number widget will inherit the palette from the editor QTextCharFormat format = settings->value("lineNumbers").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Button, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::ButtonText, fg); } if (settings->contains("selection")) { QTextCharFormat format = settings->value("selection").value<QTextCharFormat>(); QBrush bg = format.background(); QBrush fg = format.foreground(); if (bg.style() != Qt::NoBrush) palette.setBrush(QPalette::Highlight, bg); if (fg.style() != Qt::NoBrush) palette.setBrush(QPalette::HighlightedText, fg); } mSearchResultTextFormat = settings->value("searchResult").value<QTextCharFormat>(); settings->endGroup(); // colors settings->endGroup(); // IDE/editor setLineWrapMode( lineWrap ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap ); setPalette(palette); }