示例#1
0
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();
}
示例#2
0
void CodeHighlighter::highlightBlock(const QString &text)
{
    highlightLines(text);
    highlightCommentBlocks(text);
}