MyTextEdit::MyTextEdit(QWidget *parent) : QPlainTextEdit(parent), m_contextMenu(this), m_tabulatorWidth(8) { setLineWrapMode(QPlainTextEdit::NoWrap); setTabStopWidth(40); m_lineNumbers = new MyLineNumbers(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(highlightLines())); updateLineNumberAreaWidth(0); highlightLines(); // highlightCurrentLine(); }
void CodeHighlighter::highlightBlock(const QString &text) { highlightLines(text); highlightCommentBlocks(text); }