forked from mirror/openmw-tes3mp
Make name highlighting more consistent and only for variable names
This commit is contained in:
parent
95f60d2bb3
commit
829560719e
3 changed files with 10 additions and 16 deletions
|
@ -52,7 +52,6 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|||
mMonoFont(QFont("Monospace")),
|
||||
mTabCharCount(4),
|
||||
mMarkOccurrences(true),
|
||||
mMarkOccurrencesRunning(false),
|
||||
mDocument(document),
|
||||
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
||||
{
|
||||
|
@ -90,7 +89,7 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
|||
<<CSMWorld::UniversalId::Type_Script
|
||||
<<CSMWorld::UniversalId::Type_Region;
|
||||
|
||||
connect(this, SIGNAL(selectionChanged()), this, SLOT(markOccurrences()));
|
||||
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(markOccurrences()));
|
||||
|
||||
mCommentAction = new QAction (tr ("Comment Selection"), this);
|
||||
connect(mCommentAction, SIGNAL (triggered()), this, SLOT (commentSelection()));
|
||||
|
@ -309,24 +308,20 @@ void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy)
|
|||
|
||||
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;
|
||||
|
||||
if (mMarkOccurrences)
|
||||
{
|
||||
mMarkOccurrencesRunning = true;
|
||||
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
QString word = cursor.selectedText();
|
||||
|
||||
// prevent infinite recursion with cursor.select(),
|
||||
// which ends up calling this function again
|
||||
// could be fixed with blockSignals, but mDocument is const
|
||||
disconnect(this, SIGNAL(cursorPositionChanged()), this, 0);
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(markOccurrences()));
|
||||
|
||||
QString word = cursor.selectedText();
|
||||
mHighlighter->setMarkedWord(word.toStdString());
|
||||
mHighlighter->rehighlight();
|
||||
|
||||
mMarkOccurrencesRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ namespace CSVWorld
|
|||
QFont mMonoFont;
|
||||
int mTabCharCount;
|
||||
bool mMarkOccurrences;
|
||||
bool mMarkOccurrencesRunning;
|
||||
QAction *mCommentAction;
|
||||
QAction *mUncommentAction;
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type
|
|||
index -= length;
|
||||
|
||||
QTextCharFormat scheme = mScheme[type];
|
||||
if (mMarkOccurrences && loc.mLiteral == mMarkedWord)
|
||||
if (mMarkOccurrences && type == Type_Name && loc.mLiteral == mMarkedWord)
|
||||
scheme.merge(mScheme[Type_Highlight]);
|
||||
|
||||
setFormat (index, length, scheme);
|
||||
|
|
Loading…
Reference in a new issue