|
|
|
@ -49,6 +49,7 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|
|
|
|
mDefaultFont(font()),
|
|
|
|
|
mMonoFont(QFont("Monospace")),
|
|
|
|
|
mTabCharCount(4),
|
|
|
|
|
mMarkOccurrencesRunning(false),
|
|
|
|
|
mDocument(document),
|
|
|
|
|
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
|
|
|
|
{
|
|
|
|
@ -86,6 +87,8 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|
|
|
|
<<CSMWorld::UniversalId::Type_Script
|
|
|
|
|
<<CSMWorld::UniversalId::Type_Region;
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(selectionChanged()), this, SLOT(markOccurrences()));
|
|
|
|
|
|
|
|
|
|
mHighlighter = new ScriptHighlighter (document.getData(), mode, ScriptEdit::document());
|
|
|
|
|
|
|
|
|
|
connect (&document.getData(), SIGNAL (idListChanged()), this, SLOT (idListChanged()));
|
|
|
|
@ -284,6 +287,26 @@ void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy)
|
|
|
|
|
updateLineNumberAreaWidth(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::ScriptEdit::markOccurrences()
|
|
|
|
|
{
|
|
|
|
|
// prevent infinite recursion with cursor.select(),
|
|
|
|
|
// which ends up calling this function again
|
|
|
|
|
// could be fixed with blockSignals, but mDocument is const
|
|
|
|
|
if (mMarkOccurrencesRunning)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
mMarkOccurrencesRunning = true;
|
|
|
|
|
|
|
|
|
|
QTextCursor cursor = textCursor();
|
|
|
|
|
cursor.select(QTextCursor::WordUnderCursor);
|
|
|
|
|
QString word = cursor.selectedText();
|
|
|
|
|
|
|
|
|
|
mHighlighter->setMarkedWord(word.toStdString());
|
|
|
|
|
mHighlighter->rehighlight();
|
|
|
|
|
|
|
|
|
|
mMarkOccurrencesRunning = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QPlainTextEdit::resizeEvent(e);
|
|
|
|
|