StatusWidget::StatusWidget(QWidget *parent) : QPlainTextEdit(parent) { setFont(QFont("Monospace")); setReadOnly(true); setCenterOnScroll(true); }
void CodeView::toggleSourceFile() { m_mode = Sourcefile; setCenterOnScroll(false); setPlainText(m_sourceCodeData); if (m_currentSourceLine >= 0) { setLine(m_currentSourceLine); } }
QmtxLogBox::QmtxLogBox( QWidget * parent ) : QPlainTextEdit(parent) { setFont( QFont( "Consolas", 8, QFont::Normal ) ) ; setReadOnly( true ) ; setMaximumBlockCount( 1024 ) ; setCenterOnScroll( true ) ; // only first if ( single == NULL ) single = this ; }
Console::Console(MainWindow* parent) : QPlainTextEdit(parent) { setContentsMargins(50, 50, 50, 50); ensureCursorVisible(); setCenterOnScroll(false); setReadOnly(true); this->parent = parent; /* update all settings for the console */ updateSettings(); }
LogView::LogView(QWidget *parent) : QPlainTextEdit(parent) { setReadOnly(true); setMaximumBlockCount(200); setCenterOnScroll(true); setFrameStyle(QFrame::NoFrame); // Init actions m_saveToFileAction = KStandardAction::saveAs(this, SLOT(slotSaveToFile()), this); m_clearLogAction = KStandardAction::clear(this, SLOT(clear()), this); }
TCommandLine::TCommandLine( Host * pHost, TConsole * pConsole, QWidget * parent ) : QPlainTextEdit( parent ) , mpHost( pHost ) , mpConsole( pConsole ) , mSelectedText( "" ) , mSelectionStart( 0 ) { QString path; #ifdef Q_OS_LINUX path = "/usr/share/hunspell/"; #else path = "./"; #endif QString spell_aff = path + pHost->mSpellDic + ".aff"; QString spell_dic = path + pHost->mSpellDic + ".dic"; mpHunspell = Hunspell_create( spell_aff.toLatin1().data(), spell_dic.toLatin1().data() );//"en_US.aff", "en_US.dic"); mpKeyUnit = mpHost->getKeyUnit(); setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); QFont font = mpHost->mDisplayFont; setFont(font); mRegularPalette.setColor(QPalette::Text, mpHost->mCommandLineFgColor );//QColor(0,0,192)); mRegularPalette.setColor(QPalette::Highlight,QColor(0,0,192)); mRegularPalette.setColor(QPalette::HighlightedText, QColor(255,255,255)); mRegularPalette.setColor(QPalette::Base,mpHost->mCommandLineBgColor);//QColor(255,255,225)); setPalette( mRegularPalette ); mTabCompletionPalette.setColor(QPalette::Text,QColor(0,0,192)); mTabCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192)); mTabCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255)); mTabCompletionPalette.setColor(QPalette::Base,QColor(235,255,235)); mAutoCompletionPalette.setColor(QPalette::Text,QColor(0,0,192)); mAutoCompletionPalette.setColor(QPalette::Highlight,QColor(0,0,192)); mAutoCompletionPalette.setColor(QPalette::HighlightedText, QColor(255,255,255)); mAutoCompletionPalette.setColor(QPalette::Base,QColor(255,235,235)); mHistoryBuffer = 0; mAutoCompletion = false; setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setCenterOnScroll( false ); setWordWrapMode( QTextOption::WrapAnywhere ); // setMaximumBlockCount(1); setContentsMargins(0,0,0,0); }
bool CodeEditor::findNext( const QString &findText,bool cased,bool wrap ){ QTextDocument::FindFlags flags=0; if( cased ) flags|=QTextDocument::FindCaseSensitively; setCenterOnScroll( true ); bool found=find( findText,flags ); if( !found && wrap ){ QTextCursor cursor=textCursor(); setTextCursor( QTextCursor( document() ) ); found=find( findText,flags ); if( !found ) setTextCursor( cursor ); } setCenterOnScroll( false ); return found; }
LogWindow::LogWindow(QWidget *parent) : QPlainTextEdit(parent) { setCenterOnScroll(true); setReadOnly(true); setLineWrapMode(NoWrap); setTextInteractionFlags(Qt::TextSelectableByMouse); #ifdef WIN32 setFont(QFont("Consolas", 8)); #endif new Highlighter(document()); g_logWindow = this; appendPlainText(g_logBuffer.trimmed()); g_logBuffer.clear(); }
Editor::Editor(QWidget *parent) : QPlainTextEdit(parent) { propDialog = ((MainWindow *) parent)->propDialog; ctrlPressed = false; isSpin = false; expectAutoComplete = false; canUndo = false; canRedo = false; canCopy = false; lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth())); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); updateLineNumberAreaWidth(); highlighter = 0; setHighlights(); setMouseTracking(true); setCenterOnScroll(true); setWordWrapMode(QTextOption::NoWrap); currentTheme = &Singleton<ColorScheme>::Instance(); updateColors(); updateFonts(); saveContent(); connect(this,SIGNAL(cursorPositionChanged()),this,SLOT(updateBackgroundColors())); connect(propDialog,SIGNAL(updateColors()),this,SLOT(updateColors())); connect(propDialog,SIGNAL(updateFonts()),this,SLOT(updateFonts())); connect(propDialog->getTabSpaceLedit(),SIGNAL(textChanged(QString)), this, SLOT(tabSpacesChanged())); connect(this,SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); connect(this,SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); connect(this,SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); // this must be a pointer otherwise we can't control the position. cbAuto = new QComboBox(this); cbAuto->hide(); }
EditorView::EditorView(QWidget *parent) : QPlainTextEdit(parent) { highlighter = 0; setExtension("spin"); canUndo = false; canRedo = false; canCopy = false; tabOn = false; currentTheme = &Singleton<ColorScheme>::Instance(); loadPreferences(); lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth())); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); updateLineNumberAreaWidth(); setMouseTracking(true); setCenterOnScroll(true); setWordWrapMode(QTextOption::NoWrap); updateColors(); updateFonts(); saveContent(); connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(setUndo(bool))); connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(setRedo(bool))); connect(this, SIGNAL(copyAvailable(bool)), this, SLOT(setCopy(bool))); // this must be a pointer otherwise we can't control the position. cbAuto = new QComboBox(this); cbAuto->setMaxVisibleItems(10); cbAuto->hide(); }
TCommandLine::TCommandLine(Host* pHost, TConsole* pConsole, QWidget* parent) : QPlainTextEdit(parent) , mpHost(pHost) , mpConsole(pConsole) , mSelectedText() , mSelectionStart(0) , mTabCompletion() , mTabCompletionCount() , mAutoCompletionCount() , mUserKeptOnTyping() , mHunspellSuggestionNumber() , mpHunspellSuggestionList() { QString path; // This is duplicated (and should be the same as) the code in: // (void) dlgProfilePreferences::initWithHost(Host*) #if defined(Q_OS_MACOS) path = QStringLiteral("%1/../Resources/").arg(QCoreApplication::applicationDirPath()); #elif defined(Q_OS_FREEBSD) if (QFile::exists(QStringLiteral("/usr/local/share/hunspell/%1.aff").arg(pHost->mSpellDic))) { path = QLatin1String("/usr/local/share/hunspell/"); } else if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) { path = QLatin1String("/usr/share/hunspell/"); } else { path = QLatin1String("./"); } #elif defined(Q_OS_LINUX) if (QFile::exists(QStringLiteral("/usr/share/hunspell/%1.aff").arg(pHost->mSpellDic))) { path = QLatin1String("/usr/share/hunspell/"); } else { path = QLatin1String("./"); } #else // Probably Windows! path = "./"; #endif QString spell_aff = QStringLiteral("%1%2.aff").arg(path, pHost->mSpellDic); QString spell_dic = QStringLiteral("%1%2.dic").arg(path, pHost->mSpellDic); // The man page for hunspell advises Utf8 encoding of the pathFileNames for // use on Windows platforms which can have non ASCII characters... mpHunspell = Hunspell_create(spell_aff.toUtf8().constData(), spell_dic.toUtf8().constData()); mpKeyUnit = mpHost->getKeyUnit(); setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); QFont font = mpHost->mDisplayFont; setFont(font); mRegularPalette.setColor(QPalette::Text, mpHost->mCommandLineFgColor); //QColor(0,0,192)); mRegularPalette.setColor(QPalette::Highlight, QColor(0, 0, 192)); mRegularPalette.setColor(QPalette::HighlightedText, QColor(Qt::white)); mRegularPalette.setColor(QPalette::Base, mpHost->mCommandLineBgColor); //QColor(255,255,225)); setPalette(mRegularPalette); mTabCompletionPalette.setColor(QPalette::Text, QColor(0, 0, 192)); mTabCompletionPalette.setColor(QPalette::Highlight, QColor(0, 0, 192)); mTabCompletionPalette.setColor(QPalette::HighlightedText, QColor(Qt::white)); mTabCompletionPalette.setColor(QPalette::Base, QColor(235, 255, 235)); mAutoCompletionPalette.setColor(QPalette::Text, QColor(0, 0, 192)); mAutoCompletionPalette.setColor(QPalette::Highlight, QColor(0, 0, 192)); mAutoCompletionPalette.setColor(QPalette::HighlightedText, QColor(Qt::white)); mAutoCompletionPalette.setColor(QPalette::Base, QColor(255, 235, 235)); mHistoryBuffer = 0; mAutoCompletion = false; setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setCenterOnScroll(false); setWordWrapMode(QTextOption::WrapAnywhere); setContentsMargins(0, 0, 0, 0); }
int QPlainTextEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractScrollArea::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 25) qt_static_metacall(this, _c, _id, _a); _id -= 25; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< bool*>(_v) = tabChangesFocus(); break; case 1: *reinterpret_cast< QString*>(_v) = documentTitle(); break; case 2: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break; case 3: *reinterpret_cast< LineWrapMode*>(_v) = lineWrapMode(); break; case 4: *reinterpret_cast< bool*>(_v) = isReadOnly(); break; case 5: *reinterpret_cast< QString*>(_v) = toPlainText(); break; case 6: *reinterpret_cast< bool*>(_v) = overwriteMode(); break; case 7: *reinterpret_cast< int*>(_v) = tabStopWidth(); break; case 8: *reinterpret_cast< int*>(_v) = cursorWidth(); break; case 9: *reinterpret_cast< Qt::TextInteractionFlags*>(_v) = textInteractionFlags(); break; case 10: *reinterpret_cast< int*>(_v) = blockCount(); break; case 11: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break; case 12: *reinterpret_cast< bool*>(_v) = backgroundVisible(); break; case 13: *reinterpret_cast< bool*>(_v) = centerOnScroll(); break; } _id -= 14; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTabChangesFocus(*reinterpret_cast< bool*>(_v)); break; case 1: setDocumentTitle(*reinterpret_cast< QString*>(_v)); break; case 2: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break; case 3: setLineWrapMode(*reinterpret_cast< LineWrapMode*>(_v)); break; case 4: setReadOnly(*reinterpret_cast< bool*>(_v)); break; case 5: setPlainText(*reinterpret_cast< QString*>(_v)); break; case 6: setOverwriteMode(*reinterpret_cast< bool*>(_v)); break; case 7: setTabStopWidth(*reinterpret_cast< int*>(_v)); break; case 8: setCursorWidth(*reinterpret_cast< int*>(_v)); break; case 9: setTextInteractionFlags(*reinterpret_cast< Qt::TextInteractionFlags*>(_v)); break; case 11: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break; case 12: setBackgroundVisible(*reinterpret_cast< bool*>(_v)); break; case 13: setCenterOnScroll(*reinterpret_cast< bool*>(_v)); break; } _id -= 14; } else if (_c == QMetaObject::ResetProperty) { _id -= 14; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 14; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 14; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 14; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 14; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 14; } #endif // QT_NO_PROPERTIES return _id; }
MarkdownEditor::MarkdownEditor ( TextDocument* textDocument, MarkdownHighlighter* highlighter, QWidget* parent ) : QPlainTextEdit(parent), textDocument(textDocument), highlighter(highlighter), dictionary(DictionaryManager::instance().requestDictionary()), mouseButtonDown(false) { setDocument(textDocument); setAcceptDrops(true); preferredLayout = new QGridLayout(); preferredLayout->setSpacing(0); preferredLayout->setMargin(0); preferredLayout->setContentsMargins(0, 0, 0, 0); preferredLayout->addWidget(this, 0, 0); blockquoteRegex.setPattern("^ {0,3}(>\\s*)+"); numberedListRegex.setPattern("^\\s*([0-9]+)[.)]\\s+"); bulletListRegex.setPattern("^\\s*[+*-]\\s+"); taskListRegex.setPattern("^\\s*[-] \\[([x ])\\]\\s+"); this->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); setCursorWidth(2); setCenterOnScroll(true); ensureCursorVisible(); spellCheckEnabled = false; installEventFilter(this); viewport()->installEventFilter(this); wordCount = 0; lastBlockCount = 1; focusMode = FocusModeDisabled; insertSpacesForTabs = false; setTabulationWidth(4); editorWidth = EditorWidthMedium; markupPairs.insert('"', '"'); markupPairs.insert('\'', '\''); markupPairs.insert('(', ')'); markupPairs.insert('[', ']'); markupPairs.insert('{', '}'); markupPairs.insert('*', '*'); markupPairs.insert('_', '_'); markupPairs.insert('`', '`'); markupPairs.insert('<', '>'); connect(this->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onTextChanged(int,int,int))); connect(this->document(), SIGNAL(blockCountChanged(int)), this, SLOT(onBlockCountChanged(int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(onCursorPositionChanged())); connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); addWordToDictionaryAction = new QAction(tr("Add word to dictionary"), this); checkSpellingAction = new QAction(tr("Check spelling..."), this); typingPausedSignalSent = true; typingHasPaused = true; typingTimer = new QTimer(this); connect ( typingTimer, SIGNAL(timeout()), this, SLOT(checkIfTypingPaused()) ); typingTimer->start(1000); setColorScheme ( QColor(Qt::black), QColor(Qt::white), QColor(Qt::black), QColor(Qt::blue), QColor(Qt::red) ); fadeEffect = new GraphicsFadeEffect(this); fadeEffect->setFadeHeight(this->fontMetrics().height()); viewport()->setGraphicsEffect(fadeEffect); }