mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Add setting so feature can be turned off
This commit is contained in:
parent
a8e7628e83
commit
cbb2b8b119
@ -152,6 +152,7 @@ void CSMPrefs::State::declare()
|
||||
setRange (0, 10000);
|
||||
declareInt ("error-height", "Initial height of the error panel", 100).
|
||||
setRange (100, 10000);
|
||||
declareBool ("highlight-occurrences", "Highlight other occurrences of selected names", true);
|
||||
declareSeparator();
|
||||
declareColour ("colour-int", "Highlight Colour: Integer Literals", QColor ("darkmagenta"));
|
||||
declareColour ("colour-float", "Highlight Colour: Float Literals", QColor ("magenta"));
|
||||
|
@ -49,6 +49,7 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
||||
mDefaultFont(font()),
|
||||
mMonoFont(QFont("Monospace")),
|
||||
mTabCharCount(4),
|
||||
mMarkOccurrences(true),
|
||||
mMarkOccurrencesRunning(false),
|
||||
mDocument(document),
|
||||
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
||||
@ -233,6 +234,13 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
||||
mTabCharCount = setting->toInt();
|
||||
setTabWidth();
|
||||
}
|
||||
else if (*setting == "Scripts/highlight-occurrences")
|
||||
{
|
||||
mMarkOccurrences = setting->isTrue();
|
||||
mHighlighter->setMarkedWord("");
|
||||
updateHighlighting();
|
||||
mHighlighter->setMarkOccurrences(mMarkOccurrences);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::idListChanged()
|
||||
@ -295,16 +303,19 @@ void CSVWorld::ScriptEdit::markOccurrences()
|
||||
if (mMarkOccurrencesRunning)
|
||||
return;
|
||||
|
||||
mMarkOccurrencesRunning = true;
|
||||
if (mMarkOccurrences)
|
||||
{
|
||||
mMarkOccurrencesRunning = true;
|
||||
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
QString word = cursor.selectedText();
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.select(QTextCursor::WordUnderCursor);
|
||||
QString word = cursor.selectedText();
|
||||
|
||||
mHighlighter->setMarkedWord(word.toStdString());
|
||||
mHighlighter->rehighlight();
|
||||
mHighlighter->setMarkedWord(word.toStdString());
|
||||
mHighlighter->rehighlight();
|
||||
|
||||
mMarkOccurrencesRunning = false;
|
||||
mMarkOccurrencesRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
||||
|
@ -54,6 +54,7 @@ namespace CSVWorld
|
||||
QFont mDefaultFont;
|
||||
QFont mMonoFont;
|
||||
int mTabCharCount;
|
||||
bool mMarkOccurrences;
|
||||
bool mMarkOccurrencesRunning;
|
||||
|
||||
protected:
|
||||
|
@ -73,7 +73,7 @@ void CSVWorld::ScriptHighlighter::highlight (const Compiler::TokenLoc& loc, Type
|
||||
index -= length;
|
||||
|
||||
QTextCharFormat scheme = mScheme[type];
|
||||
if (loc.mLiteral == mMarkedWord)
|
||||
if (mMarkOccurrences && loc.mLiteral == mMarkedWord)
|
||||
scheme.merge(mScheme[Type_Highlight]);
|
||||
|
||||
setFormat (index, length, scheme);
|
||||
@ -109,6 +109,11 @@ void CSVWorld::ScriptHighlighter::highlightBlock (const QString& text)
|
||||
catch (...) {} // ignore syntax errors
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptHighlighter::setMarkOccurrences(bool flag)
|
||||
{
|
||||
mMarkOccurrences = flag;
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptHighlighter::setMarkedWord(const std::string& name)
|
||||
{
|
||||
mMarkedWord = name;
|
||||
|
@ -49,6 +49,7 @@ namespace CSVWorld
|
||||
CSMWorld::ScriptContext mContext;
|
||||
std::map<Type, QTextCharFormat> mScheme;
|
||||
Mode mMode;
|
||||
bool mMarkOccurrences;
|
||||
std::string mMarkedWord;
|
||||
|
||||
private:
|
||||
@ -94,6 +95,8 @@ namespace CSVWorld
|
||||
|
||||
virtual void highlightBlock (const QString& text);
|
||||
|
||||
void setMarkOccurrences(bool);
|
||||
|
||||
void setMarkedWord(const std::string& name);
|
||||
|
||||
void invalidateIds();
|
||||
|
Loading…
Reference in New Issue
Block a user