Exemplo n.º 1
0
void TikzEditor::showMatchingBrackets()
{
	for (QTextBlock block = firstVisibleBlock(); block.isValid(); block = block.next())
	{
		if (blockBoundingGeometry(block).top() > viewport()->height())
			break;

		const QString text = block.text();
		const int textLength = text.length();

		for (int i = 0; i < textLength; ++i)
		{
			if (block.position() + i == m_matchingBegin || block.position() + i == m_matchingEnd)
			{
				QList<QTextEdit::ExtraSelection> extraSelectionList = extraSelections();
				if (!isReadOnly())
				{
					QTextEdit::ExtraSelection selection;
					selection.format.setBackground(m_matchingColor);
					selection.cursor = textCursor();
					selection.cursor.setPosition(block.position() + i, QTextCursor::MoveAnchor);
					selection.cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
					extraSelectionList.append(selection);
				}
				setExtraSelections(extraSelectionList);
			}
		}
	}
}
Exemplo n.º 2
0
void CodeEditor::createParenthesisSelection(int pos)
{
    QList<QTextEdit::ExtraSelection> selections = extraSelections();

    QTextEdit::ExtraSelection selection;
    QTextCharFormat format = selection.format;
    format.setBackground(Qt::green);
    selection.format = format;

    QTextCursor cursor = textCursor();
    cursor.setPosition(pos);
    cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
    selection.cursor = cursor;

    selections.append(selection);

    setExtraSelections(selections);
}
Exemplo n.º 3
0
void ScriptTextEdit::saveExtraSelections()
{
	mExtraSelections = extraSelections();
}
Exemplo n.º 4
0
void ScriptTextEdit::addExtraSelection(QTextEdit::ExtraSelection e)
{
	setExtraSelections( extraSelections() << e);
}