forked from mirror/openmw-tes3mp
Add setting for script editor tab width
This commit is contained in:
parent
a3903d374f
commit
25d9b77d10
3 changed files with 11 additions and 4 deletions
|
@ -136,6 +136,9 @@ void CSMPrefs::State::declare()
|
||||||
declareBool ("wrap-lines", "Wrap Lines", false).
|
declareBool ("wrap-lines", "Wrap Lines", false).
|
||||||
setTooltip ("Wrap lines longer than width of script editor.");
|
setTooltip ("Wrap lines longer than width of script editor.");
|
||||||
declareBool ("mono-font", "Use monospace font", true);
|
declareBool ("mono-font", "Use monospace font", true);
|
||||||
|
declareInt ("tab-width", "Tab Width", 4).
|
||||||
|
setTooltip ("Number of characters for tab width").
|
||||||
|
setRange (1, 10);
|
||||||
EnumValue warningsNormal ("Normal", "Report warnings as warning");
|
EnumValue warningsNormal ("Normal", "Report warnings as warning");
|
||||||
declareEnum ("warnings", "Warning Mode", warningsNormal).
|
declareEnum ("warnings", "Warning Mode", warningsNormal).
|
||||||
addValue ("Ignore", "Do not report warning").
|
addValue ("Ignore", "Do not report warning").
|
||||||
|
|
|
@ -52,7 +52,7 @@ CSVWorld::ScriptEdit::ScriptEdit(
|
||||||
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive)
|
||||||
{
|
{
|
||||||
wrapLines(false);
|
wrapLines(false);
|
||||||
setTabWidth();
|
setTabWidth(4);
|
||||||
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
|
setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead
|
||||||
|
|
||||||
mAllowedTypes <<CSMWorld::UniversalId::Type_Journal
|
mAllowedTypes <<CSMWorld::UniversalId::Type_Journal
|
||||||
|
@ -194,9 +194,8 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
|
||||||
return !(string.contains(mWhiteListQoutes));
|
return !(string.contains(mWhiteListQoutes));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::setTabWidth()
|
void CSVWorld::ScriptEdit::setTabWidth(const int numCharacters)
|
||||||
{
|
{
|
||||||
const int numCharacters = 4;
|
|
||||||
QFontMetrics metrics(mMonoFont);
|
QFontMetrics metrics(mMonoFont);
|
||||||
setTabStopWidth(numCharacters * metrics.width(' '));
|
setTabStopWidth(numCharacters * metrics.width(' '));
|
||||||
}
|
}
|
||||||
|
@ -232,6 +231,10 @@ void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting)
|
||||||
{
|
{
|
||||||
wrapLines(setting->isTrue());
|
wrapLines(setting->isTrue());
|
||||||
}
|
}
|
||||||
|
else if (*setting == "Scripts/tab-width")
|
||||||
|
{
|
||||||
|
setTabWidth(setting->toInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::idListChanged()
|
void CSVWorld::ScriptEdit::idListChanged()
|
||||||
|
|
|
@ -92,7 +92,8 @@ namespace CSVWorld
|
||||||
bool stringNeedsQuote(const std::string& id) const;
|
bool stringNeedsQuote(const std::string& id) const;
|
||||||
|
|
||||||
/// \brief Set tab width for script editor.
|
/// \brief Set tab width for script editor.
|
||||||
void setTabWidth();
|
/// \param numCharacters Number of characters for tab width.
|
||||||
|
void setTabWidth(const int numCharacters);
|
||||||
|
|
||||||
/// \brief Turn line wrapping in script editor on or off.
|
/// \brief Turn line wrapping in script editor on or off.
|
||||||
/// \param wrap Whether or not to wrap lines.
|
/// \param wrap Whether or not to wrap lines.
|
||||||
|
|
Loading…
Reference in a new issue